From 704af44600f9dc049db4acef46e1de3703b2ea32 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Fri, 5 Nov 2021 15:47:54 +0100 Subject: [PATCH] Fix ProcessRunner --- docs/api.md | 2 +- src/Component/ProcessRunner/ProcessRunner.php | 2 +- src/functions.php | 2 +- tests/e2e/recipe/misc.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index 0aa1cc8d..a4b470ac 100644 --- a/docs/api.md +++ b/docs/api.md @@ -234,7 +234,7 @@ runLocally("echo $user"); - **idle_timeout** `int|null` — Sets the process idle timeout (max. time since last output) in seconds. - **secret** `string|null` — Placeholder `%secret%` can be used in command. Placeholder will be replaced with this value and will not appear in any logs. - **env** `array|null` — Array of environment variables: `runLocally('echo $KEY', env: ['key' => 'value']);` -- **shell** `string|null` — Shell to run in. Default is `bash -c`. +- **shell** `string|null` — Shell to run in. Default is `bash -s`. ## test() diff --git a/src/Component/ProcessRunner/ProcessRunner.php b/src/Component/ProcessRunner/ProcessRunner.php index 087ed6c4..2fdef45e 100644 --- a/src/Component/ProcessRunner/ProcessRunner.php +++ b/src/Component/ProcessRunner/ProcessRunner.php @@ -38,7 +38,7 @@ class ProcessRunner 'idle_timeout' => null, 'cwd' => defined('DEPLOYER_ROOT') ? DEPLOYER_ROOT : null, 'real_time_output' => false, - 'shell' => 'bash -c', + 'shell' => 'bash -s', ]; $config = array_merge($defaults, $config); diff --git a/src/functions.php b/src/functions.php index 580b3091..877b6718 100644 --- a/src/functions.php +++ b/src/functions.php @@ -401,7 +401,7 @@ function run(string $command, ?array $options = [], ?int $timeout = null, ?int $ * @param int|null $idle_timeout Sets the process idle timeout (max. time since last output) in seconds. * @param string|null $secret Placeholder `%secret%` can be used in command. Placeholder will be replaced with this value and will not appear in any logs. * @param array|null $env Array of environment variables: `runLocally('echo $KEY', env: ['key' => 'value']);` - * @param string|null $shell Shell to run in. Default is `bash -c`. + * @param string|null $shell Shell to run in. Default is `bash -s`. * * @throws RunException */ diff --git a/tests/e2e/recipe/misc.php b/tests/e2e/recipe/misc.php index 1382a48f..383c8c58 100644 --- a/tests/e2e/recipe/misc.php +++ b/tests/e2e/recipe/misc.php @@ -5,7 +5,7 @@ namespace Deployer; require_once __DIR__ . '/hosts.php'; task('test:misc:sudo-write-user', function (): void { - $cmd = 'sudo bash -c \'echo Current user is: $USER\''; + $cmd = 'sudo bash -s \'echo Current user is: $USER\''; $output = run($cmd); writeln($output); })->shallow();