Use 'command -v' to detect whether and where software is installed (instead of 'which')
This commit is contained in:
parent
fc209a5944
commit
43b1d81f77
|
@ -438,7 +438,7 @@ class OC_Mount_Config {
|
||||||
*/
|
*/
|
||||||
public static function checksmbclient() {
|
public static function checksmbclient() {
|
||||||
if(function_exists('shell_exec')) {
|
if(function_exists('shell_exec')) {
|
||||||
$output=shell_exec('which smbclient 2> /dev/null');
|
$output=shell_exec('command -v smbclient 2> /dev/null');
|
||||||
return !empty($output);
|
return !empty($output);
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -464,7 +464,7 @@ class OC_Installer{
|
||||||
// is the code checker enabled?
|
// is the code checker enabled?
|
||||||
if(OC_Config::getValue('appcodechecker', true)) {
|
if(OC_Config::getValue('appcodechecker', true)) {
|
||||||
// check if grep is installed
|
// check if grep is installed
|
||||||
$grep = exec('which grep');
|
$grep = exec('command -v grep');
|
||||||
if($grep=='') {
|
if($grep=='') {
|
||||||
OC_Log::write('core',
|
OC_Log::write('core',
|
||||||
'grep not installed. So checking the code of the app "'.$appname.'" was not possible',
|
'grep not installed. So checking the code of the app "'.$appname.'" was not possible',
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
namespace OC\Preview;
|
namespace OC\Preview;
|
||||||
|
|
||||||
function findBinaryPath($program) {
|
function findBinaryPath($program) {
|
||||||
exec('which ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
|
exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
|
||||||
if ($returnCode === 0 && count($output) > 0) {
|
if ($returnCode === 0 && count($output) > 0) {
|
||||||
return escapeshellcmd($output[0]);
|
return escapeshellcmd($output[0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,12 +64,12 @@ if (!\OC_Util::runningOnWindows()) {
|
||||||
$cmd = \OC_Config::getValue('preview_libreoffice_path', null);
|
$cmd = \OC_Config::getValue('preview_libreoffice_path', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$whichLibreOffice = shell_exec('which libreoffice');
|
$whichLibreOffice = shell_exec('command -v libreoffice');
|
||||||
if($cmd === '' && !empty($whichLibreOffice)) {
|
if($cmd === '' && !empty($whichLibreOffice)) {
|
||||||
$cmd = 'libreoffice';
|
$cmd = 'libreoffice';
|
||||||
}
|
}
|
||||||
|
|
||||||
$whichOpenOffice = shell_exec('which openoffice');
|
$whichOpenOffice = shell_exec('command -v openoffice');
|
||||||
if($cmd === '' && !empty($whichOpenOffice)) {
|
if($cmd === '' && !empty($whichOpenOffice)) {
|
||||||
$cmd = 'openoffice';
|
$cmd = 'openoffice';
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1)
|
||||||
|
|
||||||
// LibreOffice preview is currently not supported on Windows
|
// LibreOffice preview is currently not supported on Windows
|
||||||
if (!\OC_Util::runningOnWindows()) {
|
if (!\OC_Util::runningOnWindows()) {
|
||||||
$whichLibreOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
|
$whichLibreOffice = ($isShellExecEnabled ? shell_exec('command -v libreoffice') : '');
|
||||||
$isLibreOfficeAvailable = !empty($whichLibreOffice);
|
$isLibreOfficeAvailable = !empty($whichLibreOffice);
|
||||||
$whichOpenOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
|
$whichOpenOffice = ($isShellExecEnabled ? shell_exec('command -v libreoffice') : '');
|
||||||
$isOpenOfficeAvailable = !empty($whichOpenOffice);
|
$isOpenOfficeAvailable = !empty($whichOpenOffice);
|
||||||
//let's see if there is libreoffice or openoffice on this machine
|
//let's see if there is libreoffice or openoffice on this machine
|
||||||
if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {
|
if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {
|
||||||
|
|
Loading…
Reference in New Issue