installer: preserve explicit exit status in exit trap

This commit is contained in:
Ryan Hughes
2026-06-04 18:35:01 -04:00
parent 2bf3315719
commit 9feab5081f
+5 -3
View File
@@ -74,8 +74,10 @@ restore_outputs() {
# Error handler # Error handler
catch_errors() { catch_errors() {
# Store exit code before any conditionals or assignments overwrite $?. # Store exit code before any conditionals or assignments overwrite $?. EXIT
local exit_code=$? # 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 # Prevent recursive error handling
if [[ $ERROR_HANDLING == "true" ]]; then 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 # Only run if we're exiting with an error and haven't already handled it
if (( exit_code != 0 )) && [[ $ERROR_HANDLING != "true" ]]; then if (( exit_code != 0 )) && [[ $ERROR_HANDLING != "true" ]]; then
catch_errors catch_errors "$exit_code"
else else
stop_log_output stop_log_output
show_cursor show_cursor