diff --git a/src/Interpreter/Executors/Bash/Executor.php b/src/Interpreter/Executors/Bash/Executor.php index 332af409..16fb0aa4 100644 --- a/src/Interpreter/Executors/Bash/Executor.php +++ b/src/Interpreter/Executors/Bash/Executor.php @@ -17,7 +17,8 @@ public function exec(string $script, array $args = [], string $cwd = null, array ]; $pipes = []; - $process = proc_open($this->buildCommand($script, $args, $cwd), $descriptorSpec, $pipes, null, array_merge($_ENV, $env)); + $currentEnv = $this->buildEnv() ?: []; + $process = proc_open($this->buildCommand($script, $args, $cwd), $descriptorSpec, $pipes, null, array_merge($currentEnv, $env)); $status = 255; if (is_resource($process)) { @@ -44,7 +45,8 @@ public function capture(string $script, array $args = [], string $cwd = null, ar ]; $pipes = []; - $process = proc_open($this->buildCommand($script, $args, $cwd), $descriptorSpec, $pipes, null, array_merge($_ENV, $env)); + $currentEnv = $this->buildEnv() ?: []; + $process = proc_open($this->buildCommand($script, $args, $cwd), $descriptorSpec, $pipes, null, array_merge($currentEnv, $env)); $output = ''; $status = 255; @@ -95,4 +97,12 @@ private function buildCommand(string $script, array $args, ?string $cwd): array ...array_values($args), ]; } + + /** + * @return array + */ + private function buildEnv(): array + { + return getenv(); + } }