Repository navigation
fix(startup): #422+#430 nits — posix $ENV exit skips the login greeting tail; rbash×loader pin; typeahead comment truth; clippy cast - #432
Merged
Conversation
Member
Author
Independent review: APPROVE-WITH-NITSVerified independently on #422-1 — posix
|
caomengxuan666
added a commit
that referenced
this pull request
Oct 19, 2026
Conflict resolution (crates/niubash-runtime/src/repl.rs, two hunks): 1. Unread type doc — both sides kept: #432's MSDN tail-append framing is the primitive's truth (WriteConsoleInput APPENDS, it cannot prepend); the merged text states that #417's face wraps that primitive with a drain-and-rewrite (requeue_console_input) so the re-queued events land at the head slot, the position the probe took them from. 2. win_unread record construction — the #417 general synthesis kept (fields.*); #432's clippy-cast deletion survives inside it (the '0x0D as u16' cast no longer exists anywhere — UnicodeChar comes from a u16 field; the necessary char casts live in key_press_records). Stale #432 derivations of the old tail-append behavior updated to the compensated face (comments still cite the MSDN append as the primitive): the unread field doc (tail-write claim -> drain-and-rewrite, and why the #417 writeback needs the head slot: a plain append would shred a burst into 'ead...'), with_scripted_queue (head slot is now a production guarantee, not a test-only fidelity upgrade), enter_opens_chunk (the requeued partner CR is the next submit nothing has to drain past), and typeahead_guard::requeue_console_input's doc (same primitive as the guard's reinjection; the guard can settle for the bare append — its queue is empty at reinjection — this face buys the head slot). Verification (this host, Win10 19045, --test-threads=1) on the merge result: runtime lib 560/0; interactive 85/0 (5 ignored, unix-only legs; includes #432's two new tests and both #417 echo-proof regressions); issue373 3/0; cargo fmt --check clean; RUSTFLAGS='-D warnings' cargo check clean. niubash#434 (control-chord synthesis arm) intentionally NOT touched here — separate ticket.
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 #422, closes #430. Four small items bundled, no behavior beyond the one early return.
#422-1 — posix
$ENVexit now early-returns before the login tail (shell.rs)The login posix branch ran
update_completion_state/finish_startup/ greeting hooks afterexecute_env_file("ENV")had already ended the invocation with a top-levelexit— inconsistent with the sibling profile-exit and rc-exit paths, which return the jump status immediately. Undersh -l -ithe ENV file'sexitcould still emit greeting output before the session ended.GNU oracle (WSL GNU Bash 5.3.0, scratch HOME, profile sets
PS1):sh -l -iwith$ENV=echo ENV-RAN; exit 7→ printsENV-RAN, exits 7, the first prompt never renders.sh -l -i -cwith the same ENV → marker, exit 7, command line never runs.Fix:
return Some(status)straight out of the ENV gate, before the login tail (same shape as the profile/rc exit paths).Double proof on the local side:
login_posix_env_exit_skips_the_greeting_startup_tail): a greeting hook that would exportGREETING_RANmust NOT run after the jump; plus a no-exit control that must still run it. Mutation-checked: reverting the early return fails the pin.tests/interactive.rs,sh.exeface +-l, REPL dispatch): ENV exit ends the session with status 7 and zeroP1>renders (PS1 staged inside the ENV file so the no-prompt assertion is meaningful on a login face); the control reaches the prompt and answers a command line.#422-2 — rbash × generated-loader combo pin (tests/rc_readonly_loader.rs, now 14 tests)
rbash_named_session_loads_the_generated_loader_then_restricts(NIU_INVOKED_AS=rbash,-i -c): loader body runs before the rc and before restrictions arm (aHISTFILE=assignment first in the loader body fails readonly if the ordering ever moves), body seesloaded|rc|+ restricted$-, the five maybe_make_restricted variables (PATH/SHELL/ENV/BASH_ENV/HISTFILE) each fail readonly in subshells, and startup stays zero-write (config inventory, rc identity, loader bytes).#430-1 — typeahead reinjection comments say tail, not head
WriteConsoleInputWappends behind the pending events (MSDN); the old wording ("exactly as if they had waited in the queue the whole time", "BACK at the head of the input stream") misled on ordering. Corrected intypeahead_guard.rs(module doc +disarm_and_reinject) and therepl.rsrequeue docs (unreadfield,Unreadalias,enter_opens_chunk, the #420 test doc,with_scripted_queue): the difference is benign — canonical wedge has an empty queue (tail = head); a multi-line burst migrates the requeued empty-line CR to the burst's end while non-empty lines stay strictly ordered. The scripted test queue'spush_frontis now documented as modeling the head semantics — slightly stronger fidelity than production's tail append.#430-2 —
repl.rs0x0D as u16cast removedclippy::unnecessary_cast; the literal infers
u16. (Clippy is not a CI gate — noted in the issue — and master carries pre-existing clippy findings elsewhere; no new lints are introduced by this diff.)Verification
cargo test -p niubash-runtime --lib --locked -- --test-threads=1→ 554 passed / 0 failed (552 + 2 new pins; one unrelated flaky failure in an earlier run, two subsequent full runs green)cargo test --test interactive --locked -- --test-threads=1→ 83 passed / 0 failed (81 + 2 new probes)cargo test --test startup_files --locked -- --test-threads=1→ 29 passed / 0 failed;rc_readonly_loader→ 14 / 0cargo fmt --all --checkclean;RUSTFLAGS="-D warnings" cargo build+cargo test --no-runclean