Change env string inject order

This commit is contained in:
crazywhalecc
2025-06-09 12:12:22 +08:00
parent 1c1f7b19dd
commit 936c4d8696

View File

@@ -45,17 +45,17 @@ class UnixShell
/* @phpstan-ignore-next-line */ /* @phpstan-ignore-next-line */
logger()->info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd)); logger()->info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd));
logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']); logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']);
$env_str = $this->getEnvString();
if (!empty($env_str)) {
$cmd = "{$env_str} {$cmd}";
}
if ($this->cd !== null) { if ($this->cd !== null) {
$cmd = 'cd ' . escapeshellarg($this->cd) . ' && ' . $cmd; $cmd = 'cd ' . escapeshellarg($this->cd) . ' && ' . $cmd;
} }
if (!$this->debug) { if (!$this->debug) {
$cmd .= ' 1>/dev/null 2>&1'; $cmd .= ' 1>/dev/null 2>&1';
} }
$env_str = $this->getEnvString(); f_passthru($cmd);
if (!empty($env_str)) {
$env_str = "{$env_str} ";
}
f_passthru("{$env_str}{$cmd}");
return $this; return $this;
} }