Batch mode: exit 1 when a script command failed (#117) - #119
Merged
Conversation
`molterm --script f.mt --no-tui` returned 0 even when commands in the script failed. The diagnostic existed — per-failure `path:line: cmd: reason` on stderr, plus a `Script: N command(s) failed` summary — but nothing reached the process status, so a driver that surfaces output only on a non-zero return code never showed it to anyone. That is worse than a missing message: a failed command leaves the previous state in place instead of aborting, so the `:screenshot` after a failed `:color` is still written, with the old colour. The run looks clean and the figure looks plausible. A batch run now exits 1 if any command failed, 0 only if all succeeded. The script still runs to completion — only the status changes; `--strict` remains the way to stop at the first failure. An interactive (--tui) session keeps its own exit status, since there the script is setup for a session rather than the run itself. Documented under `Exit status:` in --help, README, and SCRIPTING.md, and covered by five assertions in test_script.sh. Fixes #117
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.
Fixes #117.
The bug
molterm --script f.mt --no-tuireturned 0 even when commands in the scriptfailed.
The diagnostics were all there — per-failure
path:line: `cmd`: reasononstderr plus a
Script: N command(s) failedsummary — but nothing reached theprocess status. A driver that surfaces output only on a non-zero return code
never showed any of it to the operator.
That is worse than a missing message. A failed command leaves the previous state
in place instead of aborting, so the
:screenshotafter a failed:colorisstill written, with the old colour. Both the run and the figure look fine. The
issue reports exactly this: two montages rendered byte-identical because every
:colorin one of them had failed, and the wrapper reported success.The fix
A batch run exits 1 if any command failed, 0 only if all succeeded.
The script still runs to completion — only the status changes.
--strictalready existed and remains the way to stop at the first failure; the issue
lists it as an optional extra, so this PR just documents it better rather than
adding a second spelling.
Scoped to batch runs. An interactive
--tuisession keeps its own exit status,since there the script is setup for a session rather than the run itself.
Docs
--helpgrew anExit status:section (0 / 1 / 2), and README +SCRIPTING.mdboth spell out why the code matters — that a failed command leaves a
plausible-looking wrong figure behind, so
|| exitin a driver is not optional.Verification
Five new assertions in
tests/test_script.sh, driven through the real binary:clean script exits 0; a failed command exits 1; the script still runs on past
the failure; a failure anywhere counts, not just the last command;
--strictstill exits 1. Full suite green.
The issue's exact repro now exits 1 while still writing both PNGs — the
screenshots remain byte-identical, which is the documented non-strict behaviour;
the point is that the return code now says so.
🤖 Generated with Claude Code