Repository navigation
fix(repl): consume the engine's PROMPT_COMMAND exit jump and end the session (niubash#191) - #232
Merged
Merged
Conversation
…session (niubash#191)
caomengxuan666
added a commit
that referenced
this pull request
Oct 10, 2026
- Delete docs/eco-harvest-resume-wt97b.md: point-in-time lane resume/handoff snapshot; the harvest/test line now runs on GitHub Actions (eco-harvest-ci.yml) and the diagnosis lives in git history. - CHANGELOG: add Unreleased entries for strip (#228), setup help/non-tty banner (#229), bundled niugit/ripgrep/fd + setup detection (#230/#231), PROMPT_COMMAND exit jump (#232), PS0 stderr (#233), bracketed paste (#234). Co-authored-by: docs-audit <[email protected]>
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 #191
Summary
PROMPT_COMMAND='exit'must end the interactive session. The engine half shipped in rubash#433 (4b6234c5): the pre-prompt PC runner re-armsexit_jump_pendingwhen the PC text raises a top-level unwind (exit, or the errexit break — evalstring.c:396-403 + :618-619 re-raise after theout:cleanup), and the engine's own piped--ireader consumes it. The remaining niu-side gap was the product REPL:run_bash_prompt_command(shell.rs) dropped the re-armed state, so the session re-armed the prompt and lived on.Fix
shell.rsrun_bash_prompt_commandnow consumes the engine's re-armed jump and reports it; on the jump path the pre-PC$?snapshot restore is skipped (parse.y:3021's restore is longjmped past in GNU), so the jump's status survives inlast_exit_code(PC='exit 5'keeps rc 5).shell.rsrun_precmd_hookspropagates the jump and skips the remaining pre-prompt work (prompt re-sync, title hooks).repl.rs— both REPL loops (reedline and--noediting) consume the jump at the pre-prompt hook point: the EXIT trap runs with the jump's status and the process exits with it, the same shape as the engine's piped-iroute (src/main.rs run_interactive_stdin). A plain failing PC or a PC parse error re-arms nothing: the session continues with the pre-PC$?.Tests
tests/interactive.rs(ConPTY,NIU_INTERACTIVE_TESTS=1): mid-sessionPC='exit 5'ends the session rc 5 with the follow-up input line never run;PC='false'keeps the session alive; aPC='exit 7'from the rc kills a--noeditingsession before the first prompt renders (newspawn_custom_with_argsdriver entry).tests/issue191_prompt_command_exit_jump_repl.rs(black-box): piped--ipins for the engine contract the REPL fix leans on (rc 5 / no follow-up line; plain-failure survival);-cand script forms pin that a non-interactive shell never executes the PC (it is a pre-prompt hook) and that plainexit Nstatus propagation is untouched.Suite status
interactive 38/38;
niubash-runtimelib 385/385 (the 3plugins::sourcesgit-dependent tests needgiton PATH — they pass with niugit prepended);repl_command,startup_files,theme_preview_channel,issue117_foreign_ps1all green.cargo fmtclean.