Skip to content

fix(engine): exit non-zero on a masked set -u crash#52

Merged
ecukalla merged 1 commit into
mainfrom
feature/ISSUE-45-crash-exit-code
May 30, 2026
Merged

fix(engine): exit non-zero on a masked set -u crash#52
ecukalla merged 1 commit into
mainfrom
feature/ISSUE-45-crash-exit-code

Conversation

@ecukalla
Copy link
Copy Markdown
Owner

Closes #45. The EXIT trap inherited the script exit status, so a set-u abort (which enters the trap with status 0 on macOS Bash 3.2) made a crashed run exit 0 — green to the docker wrapper, CI, and humans. The exit code now derives from the explicit OUTCOME signal: a propagated failure keeps its code; only a run that reached OUTCOME=green may exit 0. Adds a cross-version bats regression. Built by feature-loop (green, iteration 1); the Co-Authored-By trailer was stripped pre-push.

The EXIT trap (on_exit) inherited the script's $?, so any abort that left
$?==0 made a crashed run exit 0 — green to the docker wrapper, CI, and
humans. The masking class is a `set -u` fatal expansion (unbound scalar or
empty-array) on macOS's stock Bash 3.2, which enters the trap with $?==0;
this is what let the broken first cut of the #41 fix read as green.

Derive the exit code from the explicit OUTCOME signal instead of $?: a
propagated failure (set -e / exit N / 127 / INT-TERM re-exits) keeps its
code, otherwise only a run that reached OUTCOME=green may exit 0.

Add a regression test that drives the exact trap state ($?==0 with OUTCOME
never green) deterministically and cross-version — Bash 5.x leaves $?==1 on
a real set -u abort, so the test aborts the engine mid-gate with a parent
`exit 0` instead and asserts a non-zero exit with no green DONE banner.
@ecukalla ecukalla merged commit 1528e0e into main May 30, 2026
5 checks passed
@ecukalla ecukalla deleted the feature/ISSUE-45-crash-exit-code branch May 31, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engine: set -u abort exits 0 — on_exit trap masks a crashed run as green (Bash 3.2)

1 participant