Repository navigation
feat(launch): announce the shell options --command inherits (#707) - #721
Merged
Merged
Conversation
--command runs with errexit ALREADY enabled, and `set -uo pipefail` does not clear it — so a script opening with that idiomatic line, believing it chose its own error policy, actually runs -e -u -o pipefail. The failure mode is silent and actively misleading: the script exits BEFORE the line that would have reported why. Two ordinary idioms are the casualties — a SIGPIPE'd pipeline under pipefail (`... | head -n N` returns 141) and `wait $pid` on a failed background job, which is specifically a pattern for CAPTURING a failure and which -e destroys at the moment it matters. It cost the reporter four r8gd.8xlarge runs and three misdiagnoses, one of which reached a published page and had to be withdrawn. Printed rather than changed, which is what they asked for: fail-fast is a defensible default and running on after a broken step until TTL would be worse. Two lines now open /var/log/spawn-command.log — the real $- and a note that set -uo pipefail will not clear errexit, with `set +e` as the opt-out. The --command help says the same, so it is discoverable before a run rather than after one. That also answers the optional third ask without a new flag: `set +e` as the first line of the user's script already takes over error handling, because the command is appended to the same script that sets -e. It was never undiscoverable by design, only undocumented. I nearly shipped something worse than the bug. The first version piped both announcement lines to `tee -a /var/log/spawn-command.log` — but this script runs as $LOCAL_USERNAME via su and cannot write there, and under the set -e at the top of the same script a failed tee would have killed the command BEFORE it started. Every --command launch, broken by the line explaining why commands break. The caller already pipes the script's combined output through tee as root, so plain stdout reaches the log anyway. That was caught by EXECUTING the generated script rather than reading it, which is also how the tests work: one runs the real heredoc under bash and reproduces the reporter's measurement ($-=ehBc, still ehuBc after set -uo pipefail), and a second gates the tee from coming back, naming why. Both verified to fail when reverted. Backticks in a Go raw string broke the build again on the way — third time this session. Prose in these templates cannot use them.
scttfrdmn
force-pushed
the
fix/707-announce-shell-options
branch
from
October 5, 2026 17:53
4935656 to
82a56bb
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Closes #707. Your ask (1) — the one you said would have ended your afternoon — plus (2), and it turns out (3) needed no flag.
What lands now
Two lines at the top of
/var/log/spawn-command.log:Printed rather than changed, as you asked. Fail-fast is a defensible default and running on after a broken step until TTL would be worse — the problem was never the policy, it was that the policy was invisible.
The
--commandhelp now says the same thing, including that... | head -n Nandwait $pidare the common casualties, so it is discoverable before a run rather than after one.Ask (3) turns out to be free
You offered
--no-errexitas optional. It isn't needed: your command is appended to the same script that sets-e, soset +eas your first line already takes over error handling. It was never undiscoverable by design, only undocumented — so the announcement names it and the flag help repeats it. If you'd still prefer an explicit flag, say so and I'll add one, but I'd rather not add surface for something a one-line idiom already does.I nearly shipped something worse than the bug
Worth telling you because it bears on how the fix is tested. My first version piped both announcement lines through
tee -a /var/log/spawn-command.log. But the command script runs as$LOCAL_USERNAMEviasuand cannot write that path — and under theset -eat the top of the very same script, a failedteewould have killed the command before it started. Every--commandlaunch, broken by the line explaining why commands break.The caller already pipes the script's combined output through
teeas root, so plain stdout reaches the log anyway.I only caught it because I executed the generated script instead of reading it — which is also how the tests work:
$-=ehBc, and stillehuBcafterset -uo pipefail, so the inheritedeis asserted rather than assumed;teefrom returning, naming why it would be fatal;That first test also pins the claim honestly: if errexit ever stops surviving
set -uo pipefail, it fails — because the announcement would then be telling users something untrue.On your accounting
You noted the project's own notes already recorded that a task command runs under
set -e, in therm -f/EPERMcontext, and that you didn't connect it tolaunch --command. That connection was ours to make, not yours: the note lived in task-run territory and nothing on the--commandpath said a word. Four runs and a withdrawn page is a steep price for a line of output we could have printed on day one, and the$-probe you wrote is now effectively shipped as that line.One incidental for the record: backticks in a Go raw string broke the build on the way — third time this session. Prose inside these generated-shell templates can't use them.