Skip to content

fix(script-driver): expose grouped-reader exit-jump verdict; exit --help continues (GNU CHECK_HELPOPT) - #1453

Merged
caomengxuan666 merged 1 commit into
unixwin:masterfrom
Catapult291:fix/grouped-reader-exit-jump-verdict
Oct 24, 2026
Merged

caomengxuan666 merged 1 commit into
unixwin:masterfrom
Catapult291:fix/grouped-reader-exit-jump-verdict

Conversation

@Catapult291

Copy link
Copy Markdown
Contributor

Summary

Two engine gaps that leave the interactive shell in the wrong state after a top-level exit:

  1. The grouped reader (; / && / alias-bearing lines) already computed the (status, exit_shell) verdict inside script_driver, but the public wrapper threw the second half away. Callers (notably niubash's REPL) therefore never learned that true; exit 3 had decided to leave the shell.
  2. exit --help returned ExitAction::Exit(EX_USAGE): it printed help and jumped to top level. GNU builtins/exit.def runs CHECK_HELPOPT first and returns EX_USAGE without jump_to_top_level (bash -c 'exit --help; echo AFTER' prints AFTER; interactive exit --help keeps prompting). Without this, bubbling exit jumps would kill the session on exit --help (regression against niubash D1).

Changes

  • script_driver: add run_script_with_history_at_line_offset_tracked returning the grouped reader's (status, exit_shell) verdict (exit/FatalFunctionError jump or errexit break; parse aborts excluded — same classification run_script_with_history_in_tracked documents). The untracked wrapper now delegates and keeps its old signature.
  • builtins/exit: --help returns Continue(EX_USAGE) instead of jumping; only a parsed status word takes the EXITPROG path.
  • tests/executor_command_chaining/part_041.rs: the two exit --help assertions now expect continuation + $?=2 (GNU form).

Test plan

Probe After
cargo test --test executor_tests exit 21 passed, 0 failed (incl. updated part_041)
bash -c 'exit --help; echo AFTER' (reference) prints AFTER
paired niubash REPL probe (this PR + companion niubash PR) true; exit 3 / alias / function end the session with the right rc; exit --help keeps prompting

Companion host PR: unixwin/niubash fix/interactive-exit-jump-bubble (records the verdict as session_exit_jump and ends the REPL). Follow-up to niubash defect log R1 (niubash-remaining-defects-2026-10-24).

cherry-picked from local d0006706.

…inue (niubash defects 2026-10-24)

script_driver gains run_script_with_history_at_line_offset_tracked: the
grouped reader's (status, exit_shell) verdict as a public result. The
untracked wrapper already computed it and dropped the second half, which
is exactly what left niubash's REPL prompting after `true; exit 3` had
unwound (niubash R1). Same classification run_script_with_history_in_tracked
documents: real exit/FatalFunctionError jump or errexit break, parse
aborts excluded.

exit --help now returns ExitAction::Continue(EX_USAGE) instead of
Exit(EX_USAGE). GNU builtins/exit.def exit_builtin runs CHECK_HELPOPT
first: the help prints and the builtin RETURNS EX_USAGE without
jump_to_top_level (probe: bash -c 'exit --help; echo AFTER' prints
AFTER; interactive `exit --help' keeps prompting). Only a parsed status
word takes the EXITPROG path. part_041's two tests asserted the old
jump and now assert ok + $?=2.
@Catapult291

Copy link
Copy Markdown
Contributor Author

Companion host PR: unixwin/niubash#544 (fix/interactive-exit-jump-bubble) — records this engine verdict as session_exit_jump and ends the interactive REPL. Land together.

@caomengxuan666
caomengxuan666 merged commit 4f40a3b into unixwin:master Oct 24, 2026
8 checks passed
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.

2 participants