Repository navigation
test(executor): pin GNU exit-unwind semantics through AND-OR lists - #122
Merged
caomengxuan666 merged 1 commit intoSep 24, 2026
Merged
Conversation
GNU builtins/exit.def:157 exit_builtin calls jump_to_top_level (EXITPROG), handled at execute_cmd.c:1622: exit unwinds every enclosing AND-OR list, function and brace group to the shell's top level; only true subshell boundaries (parentheses, pipeline stages, command substitutions) contain it. c5c9768 fixed a regression where ExitCode was downgraded to a plain status inside AND-OR list execution, which let the classic '[ -f x ] || exit 1' guard silently no-op (niubash shell-quirks doc Q3). These tests pin the fixed semantics so the unwind cannot regress unnoticed again: - exit terminates from: mid-list, list head, or-guard, function body, brace group, loop guard (the Q3 repro shape) - exit stays contained in: parentheses, pipeline stages, command substitutions (assignment carries the substitution status) - guarded 'false && exit 1' under set -e still does not fire errexit
daiaji
force-pushed
the
test/exit-and-or-unwind-regressions
branch
from
September 24, 2026 04:48
cdbb02f to
24c45b6
Compare
Member
|
Thank for your test case! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds 10 executor unit tests pinning GNU
exit-unwind semantics through AND-OR lists (builtins/exit.def:157jump_to_top_level (EXITPROG)→execute_cmd.c:1622). Only true subshell boundaries — parentheses, pipeline stages, command substitutions — may contain anexit; every enclosing AND-OR list, function and brace group must unwind to the shell's top level.Covered:
true && exit 5/exit 0 && …/[ … ] || exit 1Err(ExitCode(n)), shell terminates&&list / brace group / loop guardErr(ExitCode(n))— brace groups and functions are not subshells(exit 5); echo afterOk— subshell boundary contains itexit 5 | cat; echo afterOk— pipeline-stage boundaryv=$(true && exit 5; echo hi)Ok, status 5, substitution killed beforehiset -e; false && exit 1; echo okOk, 0 — guarded context keeps errexit suppressedWhy
c5c97683fixed a real regression whereExecuteError::ExitCodewas downgraded to a plain status inside AND-OR list execution. On the affected builds the classic[ -f x ] || exit 1guard silently no-op'd (documented as niubash shell-quirks Q3), and nothing caught it because no test exercisedexitinside an AND-OR list — theset -esuites masked it (errexit fires at the next command). This locks the unwind in so it cannot regress unnoticed again.Notes
2bb0277c(verified compiling). Heads-up: current master tipa81c1d2does not compile standalone —cargo test --libfails with 5 × E0599 oncomsub_body_alias_splice(from thecomsub: heredoc <<-/quoted delimiterscommit) — worth a look before the next release.builtins::test::…modified_since_read…,substitution_metadata::…expanded_word_tracks…,…readback_preserves…) reproduce on clean2bb0277cwithout this change; 428→438 passing here with zero new failures.