From 9feab5081f5d5ab4d9b910afa0e8136ea670f890 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Fri, 22 May 2026 13:29:10 -0400 Subject: [PATCH] installer: preserve explicit exit status in exit trap --- install/helpers/errors.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install/helpers/errors.sh b/install/helpers/errors.sh index 5a4c596d..9ce8e266 100644 --- a/install/helpers/errors.sh +++ b/install/helpers/errors.sh @@ -74,8 +74,10 @@ restore_outputs() { # Error handler catch_errors() { - # Store exit code before any conditionals or assignments overwrite $?. - local exit_code=$? + # Store exit code before any conditionals or assignments overwrite $?. EXIT + # trap callers pass their already-preserved code because calling this function + # would otherwise reset $? before we can read it. + local exit_code="${1:-$?}" # Prevent recursive error handling if [[ $ERROR_HANDLING == "true" ]]; then @@ -147,7 +149,7 @@ exit_handler() { # Only run if we're exiting with an error and haven't already handled it if (( exit_code != 0 )) && [[ $ERROR_HANDLING != "true" ]]; then - catch_errors + catch_errors "$exit_code" else stop_log_output show_cursor