Repository navigation
fix(builtins): #844/#848 popd,pushd readonly bindpwd verdict + real out-of-range operand word - #855
Merged
Merged
Conversation
…dict and name the real out-of-range word #844 — GNU cd.def:136-175 bindpwd: cd_builtin's post-chdir OLDPWD/PWD refresh fails with err_readonly's "VAR: readonly variable" (error.c:453-456 via bind_variable, variables.c:3131-3136) when either variable is readonly, and the failure surfaces as cd_builtin's EXECUTION_FAILURE with the chdir itself standing. pushd.def routes every cd through cd_builtin — cd_to_string (pushd.def:562-574), change_to_temp (pushd.def:577-586) and the Dir branch's direct call (pushd.def:301) — so popd/pushd inherit the verdict: - popd top: pushd.def:400-403 returns BEFORE the free — rc 1, the stack keeps both entries, the display's cwd slot still moves to the chdir target, and nothing prints (WSL GNU 5.3.0(1): `readonly OLDPWD; popd` -> rc 1, dirs "<new top> <new top>"). - pushd swap/rotate: the swap (pushd.def:203-215) and rotation (pushd.def:256-286) land in the list before change_to_temp, so they survive the failure while the display and rc 0 stay behind its EXECUTION_SUCCESS gate. - pushd dir: cd_builtin fails before add_dirstack_element (pushd.def:296-316) — the element never joins, nothing prints. - the -n forms never cd and stay rc 0. bindpwd_write mirrors cd.rs's existing readonly bind (one diagnostic per variable, OLDPWD first); success paths are byte-identical to before. #848 — the range diagnostics echo the OFFENDING ±N WORD instead of args.last(): popd's walk records which_word (pushd.def:374-377) and hands it to pushd_error (:382/:414), pushd checks its operand inline (:235-244), so `popd +5 -n` reports "+5" and `pushd +9 -n` reports "+9" — never a trailing option. pushd_error (pushd.def:540-546) also says "directory stack empty" while the offset is 0 for pushd itself (`pushd +9` fresh, WSL GNU 5.3.0(1) probe 2026-10-19), which the old pushd arm never had; popd already did (#830). part_025's `pushd +9` expectation is re-pinned to that oracle verdict. tests/issue844_848_popd_pushd_readonly_range_regressions.rs: 12 spawn-level regressions (readonly OLDPWD/PWD x popd/pushd-dir/swap/rotate + the -n controls; the three ticket message forms plus the empty-stack variants) next to the #830 file.
Member
Author
独立代码评审 — PR #855 (fix/844-848, 05d9849)结论:APPROVE 单提交 05d9849,父 = master 头 8e9c7c0(#852 合入后),无夹带。以下全部为本评审代理独立实做(自建 worktree D:/repo/rubash-cr-855,评审后已删)。 GNU 语义核对(WSL GNU bash 5.3.0(1) oracle 自跑,双侧 stderr 逐字节归一比对)
#848 文案
栈状态审计失败后 回归
夹带扫描5 文件全部在题内(pushd.rs / pushd/parse.rs / pushd/stack.rs / part_025 / 新回归文件);无 Cargo.toml/docs/CHANGELOG 搭车;新测试无进程击杀代码;pushd.def/cd.def 仅以语义坐标(path:line)与注释引用出现,无 GPL 源码移植。 非阻塞备注(不挡合并)
不合并不 squash,交由维护者处置。 |
This was referenced Oct 19, 2026
Closed
Merged
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 #844. Closes #848.
What
#844 — readonly OLDPWD/PWD now fail popd/pushd's inner cd like cd's own
GNU spec (vendored bash
bash.git @b4608166, 5.3 patch 15; WSL GNU bash 5.3.0(1)-release probes 2026-10-19):bindpwd: cd_builtin's post-chdir OLDPWD/PWD refresh fails with err_readonly's `VAR: readonly variable` (error.c:453-456 via bind_variable, variables.c:3131-3136); the chdir stands, the failure returns as cd_builtin's EXECUTION_FAILURE.New
bindpwd_writemirrors cd.rs's existing readonly bind verbatim (one diagnostic per variable, OLDPWD first); success paths are byte-identical to before.#848 — the range diagnostic names the actual out-of-range word
popd's walk records
which_word(pushd.def:374-377) and hands it to pushd_error (:382/:414); pushd checks its operand inline (:235-244). The parse now carries the raw word:popd +5 -nreports "+5",pushd +9 -nreports "+9" — never a trailing option. pushd_error (:540-546) also says "directory stack empty" while the offset is 0 for pushd itself (pushd +9/pushd -9fresh) — the old pushd arm never had that variant; popd already did (#830). part_025'spushd +9expectation is re-pinned to that oracle verdict (probe: `bash: line 1: pushd: directory stack empty`, rc 1).GNU oracle A/B (WSL bash 5.3.0(1), script file via stdin, byte-normalized)
popd +5 -n,popd -n +5,pushd +9,pushd +9 -n, fresh-stack variants, both-vars).pwd-witness lines on the readonly-PWD forms (the pwd builtin's $PWD fast path — executor/pwd_loop_builtins.rs — prints the stuck variable where GNU cd.def:478-483 prints the tracked cwd; reproducible on master with plain `readonly PWD; cd ../b`, so popd/pushd are now family-consistent with cd.rs) and 4pwd -Plines on the -n controls (master's pushd never moves the process cwd — popd default pop changes the stack and PWD but does not chdir: 'pushd -n ./sub; popd' leaves the process cwd behind (GNU cds into ./sub) #830 deliberately scoped that fix to popd).Verification
Notes for review