Skip to content

fix(executor): vanished-words null command expands numbered-fd heredoc bodies in the shell (Refs #2761) - #3842

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/3362-absorb-vanished-words
Nov 17, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/3362-absorb-vanished-words

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #2761 — absorbs the surviving remainder of Uarz #3362 after #3715 merged (487c745).

What survives from #3362

One product hunk, src/executor/command_execute.rs:548 (vanished-words arm): clone cmd, clear words, and hand the wordless node to execute_empty_words_command. GNU's words==0 check (execute_cmd.c:4626-4640) runs on the EXPANDED word list, which is empty here — the node is a null command, and the force-fork rule (execute_cmd.c:4210-4216: fd-0 / REDIR_VARASSIGN only) leaves a numbered-fd body expanding in the shell, so := persists. Before this hunk the classifier saw the raw ["$EMPTY"] word, forked the expansion, and $EMPTY 3<<EOF with ${v:=bound} lost the binding.

What was dropped (already in master via #3715)

Pins

tests/issue2761_heredoc_null_command_expansion.rs, 9 cells — the shapes #3715 lacks: the discriminating vanished_words_numbered_heredoc_assign_persists (red on master by code trace, green after this hunk) plus eight coverage pins (arithmetic ×2, two-heredoc order ×2, arith-error ×2, fd0-fatal ×1, post-alias ×1). The other 8 of #3362's 17 pins duplicate #3715's and were dropped. The rest of #2761's face is pinned by #3715's tests/issue2761_heredoc_empty_words_regressions.rs.

Guard scan

Open PRs touching command_execute.rs / command_prepare.rs: only #3755 (touches command_prepare.rs only, hunks at 2648–6572 — this PR does not touch that file) and #3362 itself (the source). No hunk within 1000 lines of this PR's hunk. Clear to proceed.

Verification (owed)

No cargo/rustc on this VM and the X299/server routes are down, so no local leg ran. Pin red/green is established by code trace (full trace in REPORT.md at the workdir; comparison report ~/workspace/fix-uarz-compare/REPORT.md §2). CI census (which runs all stems) adjudicates on this PR: expect the discriminating pin green here, and the 8 coverage pins green throughout.

本 PR 删除了什么

无。新增一个 product hunk + 9 个回归钉。从 #3362 原案中略去的 hunks 本就未合入,不构成对 master 的删除。作者:Uarz(原 #3362 作者,本次吸收保留其作者身份);吸收与裁剪由本次车道执行。

Uarz and others added 3 commits November 17, 2026 09:08
…c bodies in the shell (Refs #2761)

The vanished-words arm of the empty-words dispatch passed `cmd` with
its raw words (`["$EMPTY"]`) to `execute_empty_words_command`, so the
heredoc fork classifier saw an effective word and expanded a
numbered-fd body in a fork, discarding `:=`. GNU's words==0 check
runs on the EXPANDED word list, which is empty here — the node is a
null command, and the force-fork rule (fd-0 / REDIR_VARASSIGN only)
leaves a numbered-fd body expanding in the shell, so `:=` persists.
Hand the node to the null-command path wordless, as GNU sees it.

GNU anchors (audit tree bash-5.3, verified):
- execute_cmd.c:4626-4640 — `words == 0` dispatches to
  execute_null_command.
- execute_cmd.c:4210-4216 — force-fork only for REDIR_VARASSIGN or
  a redirect targeting fd 0 / bash input; fd-3 does not force it.

Absorb note: this is the surviving remainder of Uarz #3362 after
#3715 merged (487c745). Dropped as already-in-master: both
visibility changes (`abort_on_expansion_errors`,
`preexpand_command_stdin`) and the `command_prepare.rs` insertion
block (superseded by #3715's 61-line version with the funsub-exit
latches). `preexpand_command_stdin` keeps master's `Option<i32>`
return (the #2763 latch); #3362's `()` signature was NOT taken.
Pins trimmed from 17 to the 9 shapes #3715 lacks: the
discriminating `vanished_words_numbered_heredoc_assign_persists`
(red on master by code trace, green after this hunk) plus eight
coverage pins (arithmetic x2, two-heredoc order x2, arith-error x2,
fd0-fatal x1, post-alias x1).

Verification: no cargo/rustc on this VM and the X299/server routes
are down, so no local leg ran. Pin red/green is established by code
trace (see REPORT.md); CI census (which runs all stems) adjudicates
on the PR.
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3842 第1轮 — 建议:PASS
head: aa27a2d(审计期间从 94919a6 前进到本值:分支上叠了两次 master merge,产品 commit 仍是 a766c96)base(merge-base): ccb8614 文件: 2 个 +165/-1
关联 issue: #2761(状态:open,我核过的时间:2026-11-17 18:14 CST)

机制核查:

  • GNU execute_simple_command 先 expand_words(execute_cmd.c:4617),再判 words == 0 → execute_null_command(simple_command->redirects, ...)(execute_cmd.c:4628-4641)——判据确实是展开后词表。本 PR 的 vanished-words 臂正是「展开后为空」的节点,比照 GNU 应按 null command 分类。
  • execute_null_command 的 force-fork 规则(execute_cmd.c:4209-4216):仅 REDIR_VARASSIGN 或 redirector.dest == 0(含 fd_is_bash_input)才 fork;否则当前 shell 内 do_redirections(RX_ACTIVE|RX_UNDOABLE)(execute_cmd.c:4268)。rubash 侧 null_command_redirects_force_fork(command_execute.rs:1983)与 preexpand_command_stdin(command_execute.rs:2345)→ heredoc_bodies_expand_in_fork_context(command_execute.rs:2265)的建模一致。
  • 病灶属实:vanished 臂原样传 cmd(words 仍存原始 ["$EMPTY"]),effective_command_word(command_execute.rs:1910)把它当命令词 → command_word_runs_in_current_shell 判 external → fork 上下文 → with_forked_heredoc_expansion 丢弃 :=。修复 clone+words.clear() 后走 null_command_redirects_force_fork 分支,与 GNU 的 words==0 分类一致。其余两个 execute_empty_words_command 调用点(command_execute.rs:319、:726)都有 cmd.words.is_empty() 前置守卫,本臂是唯一漏口。
  • 副作用面已核:清空 words 后 parameter_assignment_error/parameter_expansion_error 的 words 预扫不再重扫已展开文本——GNU 本就单次展开无二次裁决(subst.c:11229 expand_word_internal),原扫描对未取值分支只会误报,清空更贴 GNU;command_has_no_effect 因本臂必有 assignments/redirects/heredoc 而仍判 false,行为不变;word_metadata/word_kinds 残留条目在本路径无消费者(均按 words 迭代或 .get()),有先例 lone_word_function_head_candidate(parser/support.rs:1262)同样 clone+clear。
  • diff 里无可疑/无关改动;无桥接/翻译层。

腿(逐项给数字与名字):

  • 钉自跑(head aa27a2d,Windows):issue2761_heredoc_null_command_expansion → test result: ok. 9 passed; 0 failed; 0 ignored(9 个测试名全 ok:vanished_words_numbered_heredoc_assign_persists、null_heredoc_fd0_arithmetic_discarded、numbered_heredoc_arithmetic_persists、two_heredocs_both_expand_in_order、numbered_bodies_expand_in_order、arith_error_fd0_status_1_survives、arith_error_numbered_status_1_survives、fd0_fatal_body_error_contained、post_alias_empty_heredoc_comsub_executes)。
  • fail-first:base ccb8614 上同 stem 8 passed; 1 failed,红名 = {vanished_words_numbered_heredoc_assign_persists}(left v=unset / right v=bound),与 PR 声称的「discriminating pin 红、8 coverage 绿」完全一致。
  • lib 双边:head 失败名集 {api::consumer_tests::issue2084_session_end_restores_host_process_state}(1374 passed/1 failed/4 ignored)/ base 失败名集 {同左}(1374/1/4)/ 差集 ∅。issue2084 为 Windows 环境基线红(master 尖同红,与本 PR 面无关)。
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --locked --all-targets → Finished,无警告(0)。
  • 卫生:rustfmt --edition 2021 --check 两个 PR 文件 → clean;check-marker-literals.py → OK (118 registry consts, 269 allowlisted sites);check-utf8-boundary-hygiene.sh → clean。
  • CI(head aa27a2d run 44059047037/44059047053):红 = GNU regression goldens and canaries、Regression pin stem census、niubash builds against this tree。归因:master@ccb8614 自身 run 44057994618/44057994854 同三红(goldens+census、niubash api-ledger.md cmp byte 62406 差异)→ 基线。census 逐测试名 diff:仅-in-PR {issue1902_fd_alias_fact_regressions::issue1902_stdin_bound_to_regular_file_follows_the_binding、issue371_assoc_assignment_transform::at_sign_at_a_quoted_with_colon_ifs_does_not_split、issue371_assoc_assignment_transform::at_sign_at_a_quoted_with_null_ifs_splits_on_space},仅-in-master {issue1630_async_trap_table_regressions::issue1630_forwarded_table_stays_reset_no_inherited_firing、issue371…::scalar_at_a_at_a_at_q_quoted_unchanged}——issue1902/issue371 为调度方登记 flake,issue1630 反向出现(master 红 PR 绿),均与本 PR 产品面(heredoc/null-command)无语义交集,判 flake/基线。新 stem 在 CI 全 9 格 PASS。
  • GNU 对照:WSL /usr/local/bin/bash?实为 wsl bash = GNU bash 5.3.20(1)-release (x86_64-pc-linux-gnu),脚本文件 target/e3-probes/p3842-gnu.sh(LF)。9 形状逐一复跑:vanished-numbered-assign→v=bound/rc=0;fd0-arith→n=10;numbered-arith→n=11;two-bodies-order→first\nsecond;numbered-order→b=fromA;arith-error-fd0/numbered→rc=1 survived+stderr 1/0: division by 0;fd0-fatal→rc=1 alive+stderr UNDEF_Z: boom;post-alias→alias_ran.txt。与钉期望逐字节一致;另加 $_ 探针 target/e3-probes/underscore-vanished.sh:GNU underscore=[] v=bound,本 PR head 同输出——全一致(Linux fork/expand 语义为 WSL 实测,平台差异面小,队长可按需复核)。

F 点:无。

续作记录:无(纯审核,未动代码)。

未跑/VOID 的腿:无。

备注:PR 正文「Verification (owed)」自承本机无 cargo 腿——本轮已补齐上述全部腿。正文有关单词扫描:Refs #2761 规范;「absorbs … #3362」为陈述非关单。建议合入前由队长裁定 draft→ready。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-BATCH-SUMMARY】
lane e3 批次汇总(2026-11-17,worktree D:\repo\rubash-devin-e3,master 权威 ccb8614)

PR 轮次 建议判词 要点/阻塞
#3842 1 建议 PASS vanished-words → null-command 分类修复;钉 9/9 head、base 8/9(判别钉红);lib 双边差集 ∅;CI 3 红全基线;GNU 9 形状逐字节一致。等队长 ready/合入裁定。
#3583 2 建议 PENDING(缺腿) 钉质量合格、期望经 GNU 5.3.20 逐字节核;但 #3295 产品修法未落地(master 实测仍红),Windows 本机 cfg(unix) 0 格执行;维持草稿待修法。
#3561 2 建议 PENDING(缺腿) head 本体机制/钉/腿全核合格(钉 8/8+6/6、base fail-first 6 红判别有效、lib 差集 ∅、GNU 24 形状一致);但 mergeable=CONFLICTING——parameter_errors.rs 与已合入 #3465 的 master 重写语义冲突,解冲突属队长合入顺序裁定(PR 正文 Owed 节自承)。另:正文尾部 Fixes #3496/#3497/#3498 关单行需队长确认口径。
#3452 2 建议 FAIL 维持队长 FAIL;文件含禁碰 src/lexer/continuation.rs,本 lane 不可续作;head 未变。
#3362 2 建议 PENDING(只读) Uarz 旧案;逐 hunk 比对 master:其全部产品增量已被 master(#3715 更新版,含 #2763 exit 闩锁)+ #3842(words.clear() 同构 hunk)吸收,无未覆盖语义残余;是否关闭由队长裁定。

未触碰:禁碰清单 12 个 PR、队长专属 open PR 均未动;未合入/未关单/未 approve;未 force-push;未改 continuation.rs。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 17, 2026 10:52
@caomengxuan666
caomengxuan666 merged commit 23c0afc into master Nov 17, 2026
9 of 12 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