From 0eea5d31e0fc39c5c67c9035508a0bbb49232036 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com> Date: Tue, 29 Apr 2025 10:59:10 +0200 Subject: [PATCH] run-tests.php: Remove extra env vars in the generated .sh file (#18306) --- run-tests.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/run-tests.php b/run-tests.php index a90681c7ff7..03616272567 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2735,8 +2735,14 @@ $output if (!$passed || $leaked) { // write .sh if (strpos($log_format, 'S') !== false) { - $env_lines = []; + // Unset all environment variables so that we don't inherit extra + // ones from the parent process. + $env_lines = ['unset $(env | cut -d= -f1)']; foreach ($env as $env_var => $env_val) { + if (strval($env_val) === '') { + // proc_open does not pass empty env vars + continue; + } $env_lines[] = "export $env_var=" . escapeshellarg($env_val ?? ""); } $exported_environment = "\n" . implode("\n", $env_lines) . "\n"; @@ -2745,7 +2751,7 @@ $output {$exported_environment} case "$1" in "gdb") - gdb --args {$orig_cmd} + gdb -ex 'unset environment LINES' -ex 'unset environment COLUMNS' --args {$orig_cmd} ;; "lldb") lldb -- {$orig_cmd}