]> granicus.if.org Git - php/commitdiff
* System::which() now checks .exe .bat .cmd and .com on Windows
authorStig Bakken <ssb@php.net>
Thu, 9 Jan 2003 15:11:27 +0000 (15:11 +0000)
committerStig Bakken <ssb@php.net>
Thu, 9 Jan 2003 15:11:27 +0000 (15:11 +0000)
pear/System.php

index e9341b3db614f595a004f3c196ca0e111a745460..98754e9e1729a35c2ea647f8fc0fd29351986d59 100644 (file)
@@ -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
+?>