Repository navigation
fix(exec): entry-poisoned shells store no logical cwd so cd prints the chdir line - #4282
Merged
Merged
Conversation
…e chdir line
A shell born in a deleted cwd seeded its logical cwd as Some(""):
the empty adoption was stored as a live value. GNU keeps tcwd NULL
in that state, and the cd entry re-derivation gate
(get_working_directory "chdir", cd.def:529-534) is exactly
logical_cwd.is_none() -- mid-session poisoning (#3574) uses None and
prints the chdir: line, birth poisoning used Some("") and never did.
Both seeding points (Executor::new, in-process subshell seeding) now
store None for an empty adoption, sharing the single poisoned-state
representation. Healthy shells are unaffected (non-empty values are
identical). Adds 5 pins; fail-first verified on base.
Refs #4120 (not Fixes).
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.
fix(executor): store failed-birth logical cwd as None so the cd entry re-derivation fires
Refs #4120
UNVERIFIED-BY-CAPTAIN
Root cause
A shell born in a deleted cwd (entry poison) printed the
shell-init:line at startup but never thechdir:line on thefirst
cd, where GNU bash 5.3.20 prints both. The mid-sessionpoison (a failed
pwd -Pvia resetpwd, rubash#3574) did print it.The fresh-shell seed stored the failed birth capture's empty
logical cwd as
Some("")(Executor::new, and the in-processchild seed in
external_finish). GNU'sset_pwd(variables.c:907) leaves
the_current_working_directoryNULL inthis state, and the cd entry re-derivation
(builtins/cd.def:529-534 → get_working_directory ("chdir")) is
gated on exactly that NULL — rubash's
logical_cwd.is_none().Some("")read as a live base instead: no entry line, andrelative destinations were built against the empty string.
Fix
Both fresh-shell seed points now store the empty adoption as
None— the same representation the resetpwd poison alreadyuses, so "no logical cwd known" has a single state for every
reader (cd entry, pwd's poisoned arm, transport).
src/executor/init.rs:logical_cwd: (!startup_logical_cwd.is_empty()).then_some(startup_logical_cwd)src/executor/external_finish.rs: same mapping for the child seed.本 PR 删除了什么
No code deleted and no mechanism added: the birth seed is aligned
to the existing None representation instead of carrying a second
spelling (empty string) for the same state.
Net lines
Production +16/−4; tests +181 (new pin file + aggregator line).
Pins
tests/issues_3900_4199/issue4120_entry_poisoned_cd_chdir_line.rs:entry-poisoned
cd .(onechdir:line),cd .twice (stillone),
cd ..(one), entry-poisonedpwdguard (unchanged face),and the form-A self-poison guard (the verbatim arm's
cd:line,one per
cd .).Evidence
(entry poison) before: stderr =
shell-init:only. After:shell-init:+ onechdir:line, byte-identical to GNU fordot/dot2/dotdot; the pwd form already matched and still does.
Form A probes (d01–d06) unchanged.
exactly the missing line; all five cells pass after the fix.
cargo test --lib: 1341 passed, 0 failed.base
60ed70e512310 tests vs fixed 12319): both sides carrythe same 663-name local-environment failure background; the
symmetric difference is 8 names, all in known rotation families
(issue3949 coproc members on both sides, coproc-family
issue387/issue1632, issue2771, issue1631, issue2972), none in
the change surface; 0 signal-terminated tests on either side.
(The change is the identity for every non-empty startup value,
so healthy-shell behaviour cannot move.)
Not in this PR
The $PWD value bound by a relative cd from the poisoned state
(GNU binds the spelled
./..against the NULL base; rubashbinds a resolved destination — visible in the d06
/.face andthe form-B dotdot
pwdoutput) is the separate PWD-valueresidual already recorded with rubash#3574's cells. Diagnostics
only here, per the issue's acceptance.