Changeset View
Changeset View
Standalone View
Standalone View
src/future/exec/PhutilExecPassthru.php
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | $call_id = $profiler->beginServiceCall( | ||||
| 'type' => 'exec', | 'type' => 'exec', | ||||
| 'subtype' => 'passthru', | 'subtype' => 'passthru', | ||||
| 'command' => $command, | 'command' => $command, | ||||
| )); | )); | ||||
| $spec = array(STDIN, STDOUT, STDERR); | $spec = array(STDIN, STDOUT, STDERR); | ||||
| $pipes = array(); | $pipes = array(); | ||||
| if ($command instanceof PhutilCommandString) { | |||||
| $unmasked_command = $command->getUnmaskedString(); | |||||
| } else { | |||||
| $unmasked_command = $command; | |||||
| } | |||||
| $env = $this->env; | |||||
| $cwd = $this->cwd; | |||||
| $options = array(); | $options = array(); | ||||
| if (phutil_is_windows()) { | if (phutil_is_windows()) { | ||||
| // Without 'bypass_shell', things like launching vim don't work properly, | // Without 'bypass_shell', things like launching vim don't work properly, | ||||
| // and we can't execute commands with spaces in them, and all commands | // and we can't execute commands with spaces in them, and all commands | ||||
| // invoked from git bash fail horridly, and everything is a mess in | // invoked from git bash fail horridly, and everything is a mess in | ||||
| // general. | // general. | ||||
| $options['bypass_shell'] = true; | $options['bypass_shell'] = true; | ||||
| // Since we are not using CMD anymore, set the escaping mode accordingly | |||||
| if ($command instanceof PhutilCommandString) { | |||||
| $command->setEscapingMode(PhutilCommandString::MODE_WIN_PASSTHRU); | |||||
BYK: We need this mode for all `'bypass_shell' => true`. The current implementation may not be the… | |||||
| } | } | ||||
| } | |||||
| if ($command instanceof PhutilCommandString) { | |||||
Not Done Inline ActionsThis change of order was needed because of the mode change above. Could have kept the ordering and added another phutil_is_windows but that seemed wasteful. BYK: This change of order was needed because of the mode change above. Could have kept the ordering… | |||||
| $unmasked_command = $command->getUnmaskedString(); | |||||
| } else { | |||||
| $unmasked_command = $command; | |||||
| } | |||||
| $env = $this->env; | |||||
| $cwd = $this->cwd; | |||||
| $trap = new PhutilErrorTrap(); | $trap = new PhutilErrorTrap(); | ||||
| $proc = @proc_open( | $proc = @proc_open( | ||||
| $unmasked_command, | $unmasked_command, | ||||
| $spec, | $spec, | ||||
| $pipes, | $pipes, | ||||
| $cwd, | $cwd, | ||||
| $env, | $env, | ||||
| ▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines | |||||
We need this mode for all 'bypass_shell' => true. The current implementation may not be the greatest way to achieve this.