From: Stig Bakken Date: Thu, 9 Jan 2003 15:11:27 +0000 (+0000) Subject: * System::which() now checks .exe .bat .cmd and .com on Windows X-Git-Tag: PHP_5_0_dev_before_13561_fix~361 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=796083b936bdc9d524fc605afd489f08f842d499;p=php * System::which() now checks .exe .bat .cmd and .com on Windows --- diff --git a/pear/System.php b/pear/System.php index e9341b3db6..98754e9e17 100644 --- a/pear/System.php +++ b/pear/System.php @@ -433,15 +433,17 @@ class System // XXX FIXME honor safe mode $path_delim = OS_WINDOWS ? ';' : ':'; - $exe_suffix = OS_WINDOWS ? '.exe' : ''; + $exe_suffixes = OS_WINDOWS ? array('.exe','.bat','.cmd','.com') : array(''); $path_elements = explode($path_delim, getenv('PATH')); - foreach ($path_elements as $dir) { - $file = $dir . DIRECTORY_SEPARATOR . $program . $exe_suffix; - if (@is_file($file) && @$pear_is_executable($file)) { - return $file; + foreach ($exe_suffixes as $suff) { + foreach ($path_elements as $dir) { + $file = $dir . DIRECTORY_SEPARATOR . $program . $suff; + if (@is_file($file) && @$pear_is_executable($file)) { + return $file; + } } } return $fallback; } } -?> \ No newline at end of file +?>