Permalink
Browse files

finding path variables on different operating systems and adding dire…

…ctory separators so that the complete paths are correct
  • Loading branch information...
1 parent 8fdaaef commit b78491da54d28906fe5d4c6acd9c1ed5dfae9049 @lornajane committed Mar 16, 2013
Showing with 7 additions and 6 deletions.
  1. +7 −6 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 b78491d

Please sign in to comment.