Skip to content

Commit

Permalink
Use fromShellCommandline
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Nov 28, 2019
1 parent 64b9d8a commit f25b2aa
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/RemoteProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function getProcess($host, Task $task)
$env = $this->getEnvironment($host);

if (in_array($target, ['local', 'localhost', '127.0.0.1'])) {
$process = new Process(explode(' ', $task->script), null, $env);
$process = Process::fromShellCommandline($task->script, null, $env);
}

// Here we'll run the SSH task on the server inline. We do not need to write the
Expand All @@ -46,25 +46,21 @@ protected function getProcess($host, Task $task)
}

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$process = new Process(['ssh', $target, '-T']);
$process = Process::fromShellCommandline("ssh $target -T");

$process->setInput(
implode(PHP_EOL, $env)
.'set -e '.PHP_EOL
.str_replace("\r", '', $task->script)
);
} else {
$process = new Process([
'ssh',
$target,
'bash',
'-se',
"<< \\$delimiter".PHP_EOL
$process = Process::fromShellCommandline(
"ssh $target 'bash -se' << \\$delimiter".PHP_EOL
.implode(PHP_EOL, $env).PHP_EOL
.'set -e'.PHP_EOL
.$task->script.PHP_EOL
.$delimiter,
]);
.$delimiter
);
}
}

Expand Down

0 comments on commit f25b2aa

Please sign in to comment.