Skip to content

Commit

Permalink
Keep fix for env
Browse files Browse the repository at this point in the history
  • Loading branch information
kierenevans committed Feb 20, 2024
1 parent 27f712b commit 00ab2a4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Interpreter/Executors/Bash/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -95,4 +97,12 @@ private function buildCommand(string $script, array $args, ?string $cwd): array
...array_values($args),
];
}

/**
* @return array<string,string>
*/
private function buildEnv(): array
{
return getenv();
}
}

0 comments on commit 00ab2a4

Please sign in to comment.