From e8e8fcea027c5939c1b23bfaffc8e49edfa486d8 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 21 May 2025 16:31:30 +0100 Subject: [PATCH] bundle/commands/exec: fix exit code handling. In some `brew tests` runs, `$CHILD_STATUS` can be `nil`. Let's handle this and avoid these flaky tests. --- Library/Homebrew/bundle/commands/exec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/bundle/commands/exec.rb b/Library/Homebrew/bundle/commands/exec.rb index 543d84114b..103706dd76 100644 --- a/Library/Homebrew/bundle/commands/exec.rb +++ b/Library/Homebrew/bundle/commands/exec.rb @@ -178,7 +178,9 @@ module Homebrew exit_code = 0 run_services(@dsl.entries) do Kernel.system(*args) - exit_code = $CHILD_STATUS.exitstatus + if (system_exit_code = $CHILD_STATUS&.exitstatus) + exit_code = system_exit_code + end end exit!(exit_code) else