Skip to content

test: add fail-first regression pins for procsub brace-group body (Refs #3808) - #3812

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/3808-procsub-group-body
Nov 17, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/3808-procsub-group-body

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Refs #3808

根因

exec 3> >({ echo a; echo b; }) 在 reject_invalid_redirects 的 file-open 臂被判 ambiguous redirect。expand_redirect_target 对裸 procsub 操作数直接原样返回(#1223 守卫),不记录 #3089 字段裁决 memo;redirect_operand_ambiguous 于是落到文本门 redirect_target_is_ambiguous,它把 raw 词里未加引号的 {(组体的 {,实为复合命令 opener)误读为 brace-expansion introducer,而展开结果含空白 → 判多字段。子 shell 列表体能过只因体内无此类字符;输入侧 procsub 因已物化为 carrier 路径而不触发。

修法(src/executor/expand_word.rs):procsub 守卫命中时记录 single-field 裁决 memo;两处 ambiguity 门均先查 memo。GNU 锚点:redir.c:296-333 redirection_expand(NULL 仅当零/多字段)+ subst.c:11364-11391 expand_word_internal </> cases(extract_process_subst subst.c:1311 整体抽取、process_substitute subst.c:6362,拼入单个 /dev/fd/N 文件名)。

本 PR 删除了什么

无(仅新增 19 行修法 + 先行回归钉)。

验证

UNVERIFIED-BY-CAPTAIN:X299(Windows MSVC 原生):

Record the single-field verdict for a bare procsub redirect operand
in expand_redirect_target: GNU redirection_expand (redir.c:296-333)
returns NULL only for zero or several fields, and expand_word_internal's
`<'/`>' cases (subst.c:11364-11391) extract the substitution whole
(extract_process_subst, subst.c:1311) and splice the single /dev/fd/N
filename in, so a `{ ...; }` group body's `{` is a compound-command
opener, never a brace-expansion introducer. Without the memo, the
textual ambiguity gate misread the body's `{` and rejected
`exec 3> >({ echo a; echo b; })` as ambiguous redirect.
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3812 第1轮 — 建议:PASS
head: a86f085 base(merge-base): 969230b 文件: 2 个 +143/-0
关联 issue: #3808(状态: open,我核过的时间: 2026-11-17 本地)

机制核查:

  • 修法在 expand_redirect_target 的 operand_is_procsub 早退分支内记录 field-single 裁决 memo(src/executor/expand_word.rs:424-427);两处 ambiguity 门经 redirect_target_resolved_single_field(expand_word.rs:643-650)消费;memo 与 [bug] Redirect target joining a quoted space segment with a substitution reports "ambiguous redirect" #3089 裁决同生命周期(command_execute.rs:79 每次 execute_command 清空)。
  • GNU 锚点核实:redir.c:296-333 redirection_expand 仅在展开出零/多个字段时返回 NULL(AMBIGUOUS_REDIRECT 条件);subst.c:11364-11391 expand_word_internal 的 </> 分支经 extract_process_subst(subst.c:1311)整体抽取、process_substitute 拼入单个 /dev/fd/N 文件名——裸 procsub 恒为单字段,body 内的 { 永不进入本词展开。记录 single 裁决与 GNU 一致。无顺手改动、无桥接/shim。
  • 观察(非 F 点,提请队长知悉):fd3 钉断言的是 GNU 的少数分支结果——WSL GNU bash 5.3.20(/usr/local/bin/bash,vendored 同源 patch20)上该驱动 25 次中 24 次 rc=13(SIGPIPE:body 先退出、写端收 EPIPE 死亡),1 次 rc=0 全输出与钉逐字节一致;rubash 的 deferred-body 模型(fd: procsub-body parse restores a retired fd 0 entry (same hazard as #3706) #3731 已合入的同款驱动形状 >(echo a; echo b) 同断言)确定性取 rc=0 分支。属已接受语义的继承,非本 PR 新增面。
  • standalone 形状:GNU stderr 为 /dev/fd/63: Permission denied(EACCES),rubash-Linux 为 No such file or directory(ENOENT);钉按设计不断言 stderr/exec 诊断(文件头注明 fd 号与措辞平台相关),仅断言 stdout a\nb\ndone\n + 无 ambiguous redirect + rc=0——两侧在该断言面上一致。

腿(逐项数字):

  • 钉自跑:issue3808_procsub_group_body head 上 4/4 绿(Windows);Linux CI 同 stem 4/4 PASS(run 43965035178,job 133642108394 日志内 group_body_output_procsub_on_fd3 PASS)
  • fail-first:base 969230b(钉文件原样放入)3 绿 1 红,红名 = {group_body_output_procsub_on_fd3},stderr 为 >({ echo a; echo b; }): ambiguous redirect——与 PR 声称完全一致
  • lib 双边:head 失败名集 {api::consumer_tests::issue2084_session_end_restores_host_process_state} / base 失败名集 {同} / 差集 ∅(两侧各 1368 绿 1 红 4 忽略)
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --locked --lib --bins RC=0,0 警告
  • 卫生:rustfmt(expand_word.rs)clean;check-marker-literals.py OK(118 consts / 268 allowlist);check-utf8-boundary-hygiene.sh clean
  • CI:红任务 2 个——goldens 红 = {issue_753::case_9_declare_indexed_operand_binds_nothing, upstream_suite_slice_snapshots} 与 master 基线逐名一致;census 红 39 stems vs master@735d64d7 37 stems,差集 {issue1902_fd_alias_fact_regressions(已知 flake), issue2029_fd_offset_fold_regressions(本 head 在 WSL-Linux 实跑 10/10 绿,判 flake)};无其余新增红
  • GNU 对照:WSL /usr/local/bin/bash = Bash 5.3.20;input procsub 驱动(done < <({ echo a; echo b; }))两侧逐字节一致(got:[a] / got:[b] / rc=0);fd3 见上述观察;standalone 断言面一致。探针脚本:D:/repo/rubash-devin-y2/probes-y2/{r3808-fd3,r3808-input,r3808-standalone,gnu-3808-fd3-fast}.sh

F 点:无

续作记录:无(本轮只读验证,未动分支)

未跑/VOID 的腿:无

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.

1 participant