Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finding path variables on different operating systems #8

Merged
merged 1 commit into from
Mar 26, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/VersionControl/Hg/Executable.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -220,11 +220,14 @@ public function setExecutable($path = null)
{ {
$executables = array(); $executables = array();


/* Set the binary name per platform */ /* Set the binary name and paths per platform */
if(substr(strtolower(PHP_OS), 0, 3) == "win") { if(substr(strtolower(PHP_OS), 0, 3) == "win") {
$binary = 'hg.exe'; $binary = 'hg.exe';
$env_paths = explode(PATH_SEPARATOR, $_SERVER['Path']);
} else { } else {
$binary = 'hg'; $binary = 'hg';
$env_paths = explode(PATH_SEPARATOR, $_SERVER['PATH']);

} }


/* use the user provided path to an executable */ /* use the user provided path to an executable */
Expand All @@ -240,11 +243,9 @@ public function setExecutable($path = null)
if ( ( empty($executables) ) || ( null === $path ) ) { if ( ( empty($executables) ) || ( null === $path ) ) {
/* iterate through the system's path to automagically find an /* iterate through the system's path to automagically find an
* executable */ * executable */
$paths = explode(PATH_SEPARATOR, $_SERVER['Path']); foreach ( $env_paths as $path ) {

if (is_executable($path . DIRECTORY_SEPARATOR . $binary)) {
foreach ( $paths as $path ) { $executables[] = $path . DIRECTORY_SEPARATOR . $binary;
if (is_executable($path . $binary)) { //DIRECTORY_SEPARATOR .
$executables[] = $path . $binary;
} }
} }


Expand Down