finding path variables on different operating systems #8

Merged
merged 1 commit into from Mar 26, 2013
@@ -220,11 +220,14 @@ public function setExecutable($path = null)
{
$executables = array();
- /* Set the binary name per platform */
+ /* Set the binary name and paths per platform */
if(substr(strtolower(PHP_OS), 0, 3) == "win") {
$binary = 'hg.exe';
+ $env_paths = explode(PATH_SEPARATOR, $_SERVER['Path']);
} else {
$binary = 'hg';
+ $env_paths = explode(PATH_SEPARATOR, $_SERVER['PATH']);
+
}
/* use the user provided path to an executable */
@@ -240,11 +243,9 @@ public function setExecutable($path = null)
if ( ( empty($executables) ) || ( null === $path ) ) {
/* iterate through the system's path to automagically find an
* executable */
- $paths = explode(PATH_SEPARATOR, $_SERVER['Path']);
-
- foreach ( $paths as $path ) {
- if (is_executable($path . $binary)) { //DIRECTORY_SEPARATOR .
- $executables[] = $path . $binary;
+ foreach ( $env_paths as $path ) {
+ if (is_executable($path . DIRECTORY_SEPARATOR . $binary)) {
+ $executables[] = $path . DIRECTORY_SEPARATOR . $binary;
}
}