Skip to content

Commit 3601486

Browse files
authored
Merge pull request #23 from takobell/master
Several Windows fixes.
2 parents b0c0bf3 + c12ae7b commit 3601486

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Diff for: src/Command.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,19 @@ public function setCommand($command)
148148
}
149149
if ($this->getIsWindows()) {
150150
// Make sure to switch to correct drive like "E:" first if we have a full path in command
151-
$chdrive = (isset($command[1]) && $command[1]===':') ? $command[0].': && ' : '';
152-
$command = sprintf($chdrive.'cd %s && %s', escapeshellarg(dirname($command)), basename($command));
151+
if (isset($command[1]) && $command[1]===':') {
152+
$position = 1;
153+
// Could be a quoted absolute path because of spaces. i.e. "C:\Program Files (x86)\file.exe"
154+
} elseif (isset($command[2]) && $command[2]===':') {
155+
$position = 2;
156+
} else {
157+
$position = false;
158+
}
159+
160+
// Absolute path. If it's a relative path, let it slide.
161+
if ($position) {
162+
$command = sprintf($command[$position - 1].': && cd %s && %s', escapeshellarg(dirname($command)), basename($command));
163+
}
153164
}
154165
$this->_command = $command;
155166
return $this;

0 commit comments

Comments
 (0)