docs(cli): correct the stated cause of a bootstrap that never returns - #1183
Merged
Conversation
I wrote that source is a POSIX special builtin and that a syntax error in the sourced file therefore terminates the shell. Measured, that is wrong: set +e, syntax error source returns 1, execution continues set -e, syntax error shell exits (2) set +e, bare exit 3 shell exits (3) So the two modes have different causes. A syntax error makes source return non-zero like any other command, and the shell only dies because set -e is active at that point. A bare exit ends the shell regardless. The marker and EXIT trap still cover both and stay fork-free, but the alternative I dismissed -- set +e around the source, then check the status -- would have caught the syntax-error case; it just would not catch a bare exit. The conclusion held, the reasoning did not. Comments only; no behaviour change. Corrections also posted on #1179 and #1181.
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.
🤔 Background
#1179 and #1181 state that
sourceis a POSIX special builtin and that a syntaxerror therefore terminates the shell. Measured, that is wrong:
set +e, syntax errorsourcereturns 1, execution continuesset -e, syntax errorset +e, bareexit 3A syntax error makes
sourcereturn non-zero like any other command; the shellonly dies because
set -eis active at that point. A bareexitends itregardless.
💡 Changes
set +e, source, check status) would have caught the syntax-error case; it just would not catch a bareexit. The conclusion held, the reasoning did not