Skip to content
Browse files

Merge pull request #8 from lornajane/crossplatform-paths

* Find path variables on different operating systems.
  • Loading branch information...
2 parents 8fdaaef + b78491d commit 339461c6874b95faed353462f60ceffeeec941ce @mgatto mgatto committed Mar 25, 2013
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/VersionControl/Hg/Executable.php
View
13 src/VersionControl/Hg/Executable.php
@@ -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;
}
}

0 comments on commit 339461c

Please sign in to comment.
Something went wrong with that request. Please try again.