Skip to content

fix(executor): keep ${param OP word} rhs separators as one-word affixes - #3754

Merged
caomengxuan666 merged 6 commits into
masterfrom
devin/alternate-rhs-seps
Nov 17, 2026
Merged

caomengxuan666 merged 6 commits into
masterfrom
devin/alternate-rhs-seps

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Refs #3605

根因

${param OP word} 的 rhs 在 GNU 里是一个 word(subst.c:7840-7860 param_expand 经普通 word machinery 展开 rhs):${0+ "$@" } = 前缀 + "$@" + 后缀 ,词间空白作为 affix 文本 glue 到 $@ 的边界 field 上,再由 expand_word_list_internal/expand_word_internal 末尾的统一字段切分处理。

expand_alternate_word_fragment 把片段重新词法解析成 __rubash_parameter_alternate__ <fragment>,lexer 丢掉了词间空白:"$@" 变成裸 "$@",IFS='' 或非空白 IFS 下产生 <a b>/<c>,GNU 是 < a b>/ <c >(dollar-at-star9.sub ${0+ "$@" } 族)。

修法(fb1422fa rework — 审计 F1/F2)

按 vendored subst.c:12026-12160 的完整真值表实现 unquoted-outer rhs:

  • 单 istring + 延迟切分(F1):unquoted outer 下整个 word(所有 raw 片段 + separators)先合成一个字符串,quote 产生的文本以 CTLESC 保护(protect_ifs_field_chars),扩展产出的 IFS 字符不受保护、参与切分(emit_alternate_scanned_text 扫描层)。
  • 词级 W_NOSPLIT2 rejoin(F2):has_dollar_at && !quoted_dollar_at && ifs 非空 && ifs[0]!=' '(subst.c:12090/12123)→ list_string+string_list 式 rejoin,整词收成一个 field(fuse_alternate_word_fields);ifs[0]==' ' 或 IFS 空 → 走调用方常规切分;quoted_dollar_at(如 "$@" piece)→ split on IFS 且元素保护。$*/[*] 不置 has_dollar_at,正常切分。
  • had_quoted_null(subst.c:12026-12035):quoted word 展开为空仍贡献一个空 field(n "${foo-$@}" → 1)。
  • BracedAlternate 嵌入路径同步建模;marker 走 registry(无裸 \u{EXXX} 字面量,marker-lint 净)。

本 PR 删除了什么

原 fuse_alternate_list_segment(词级 fuse 上位后死代码)与 per-piece fuse 逻辑。

验证(全部对 GNU Bash 5.3.20 逐字节)

  • 4 套探测矩阵(bare-$@/$* × IFS=':';IFS=' :'、IFS=''、IFS='!';\ 转义;嵌入 braced alternate):ALL_MATCH。
  • 受影响 suite 逐 suite 对 HEAD 基线零净回归(star8:0, star9:6, star10:0, at-star5:2, at-star9:0, star7:4, at-star3:2 —— 残余均为已登记独立族)。
  • pin tests/issue3605_alternate_fragment_separators.rs 6/6 绿;fmt、marker-lint 净。

相邻残余(不修,另族)

  • n "$(true)$@" → 0 vs GNU 1:HEAD 上既存分歧,非 alternate-scoped。

GNU carries the whole alternate of ${param-OPword} as ONE word
(subst.c:7840-7860 param_expand feeds the rhs through the ordinary word
machinery): `${0+  "$@"  }` is affix ` ` + `"$@"` + affix ` `, so the
whitespace around and between the fragment's words glues to the
boundary fields and expand_word_list_internal splits only unquoted-IFS
-whitespace runs of the assembled result.

expand_alternate_word_fragment re-lexed the fragment as
`__rubash_parameter_alternate__ <fragment>`, and the lexer dropped the
inter-word whitespace: ` "$@" ` tokenized to a bare `"$@"`, yielding
`<a b>`/`<c>` where GNU yields ` < a b>`/` <c >` under IFS='' or a
non-whitespace IFS (dollar-at-star9.sub ${0+ "$@" } family).

Recover each separator as the source gap between consecutive word raws
and merge fields across word boundaries: a separator byte is a field
delimiter only when it is ambient-IFS whitespace (unset IFS: space/
tab/newline; set IFS: its whitespace members); inside a double-quoted
outer word every separator is literal text.

Verified byte-for-byte against GNU Bash 5.3.20 (probe /tmp/probe_final.sh):
default IFS unchanged, IFS='' and IFS=':' glue edges to $@ boundary
fields, empty-expanding words glue through, double-quoted outer words
never split. Gate sweep of 101 dollar/quote/posixexp/array .sub files:
dollar-at-star9 18 -> 6 residual lines, zero regressions elsewhere.

Refs #3605

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】s2

PR #3754 第1轮 — 建议:FAIL(草稿,未合并、未关 #3605)
head: 0b13f8f;base(merge-base): 0a405d8;文件 3 个 +293/-6
关联 issue: #3605(伞目录,保持 OPEN)

机制核查:

  • 正确的一半:${param OP word} 的 rhs 在 GNU 里确是一个 word(subst.c:10464 param_expand 把 rhs 交回普通 word 机制;subst.c:2957 string_list_dollar_at 决定 $@ 元素与 separator 的拼接)。把片段按源文 raw 复原 separator、再按字段合并,方向是对的。
  • 错误的一半(F1):merge_fragment_fields 的 is_delimiter 只承认「ambient-IFS 空白」为字段分隔符,注释也写「separator 字节只有当它是 ambient-IFS whitespace 时才是字段分隔符」。GNU 的字段切分按 $IFS 全部字符进行,非空白 IFS 字符同样分隔字段(subst.c:12397 word_list_split → split_at_delims,其注释明写 "Non-whitespace chars in DELIMS delimit separate fields")。实测在 IFS=: 下,rhs 里字面出现的 : 会被切分成字段,而本 PR 把它当字面 affix 粘住。
  • F2(outer-dquote 分支同错):outer_double_quoted = true 时函数对所有 separator 直接返回 false(永不切分),但 GNU 在 "${u- x:"$@" }" 里仍按 IFS 把字面分隔符切开(见下复现),本 PR 把 x:a 粘成一个字段。

F 点:

  • F1: src/executor/command_prepare.rs merge_fragment_fields 的 is_delimiter(本次新增)排除非空白 IFS。
    复现(脚本 target/s2/probes/alt3754e.sh):
    set -- a b
    unset u
    IFS=:
    set -- ${u- x:"$@" }
    echo "n=$#"
    printf '<%s>' "$@"; echo
    
    GNU bash 5.3.20:n=3 / < x><a><b >;rubash(head):n=2 / < x:a><b >。
    同族:IFS=:; show ${u- a:"$@":b } → GNU < a><a><b><b > vs rubash < a:a><b:b >;
    IFS=' :' 同形 → GNU <a><a><b><b> vs rubash <a:a><b:b>。
  • F2: 同函数 outer_double_quoted 早退。
    复现:同上脚本第二段 set -- a b; unset u; IFS=:; set -- "${u- x:"$@" }" → GNU q_n=3 / < x><a><b >;rubash q_n=2 / < x:a><b >。
  • 附:PR 正文声称「16-case × 3-IFS 探针 0 diff」,但所测 IFS 组合不含「非空白 IFS + rhs 内字面分隔符」这一族,故未暴露。不是「红得多」,是机制前提本身与 GNU 不符。

腿:

  • 钉自跑:issue3605_alternate_fragment_separators 5/5 pass(head;钉本身覆盖 unset/空/空白 IFS,未覆盖非空白 IFS 字面分隔符,故钉绿不能证明 F1)。
  • fail-first:base 0a405d8 同文件 3 passed / 2 failed,红名 = {null_ifs_glues_separators_to_boundary_fields, non_whitespace_ifs_keeps_separators_literal}(第二个名字本身就是把错误前提钉成期望)。
  • lib 双边:本 PR 未单跑完整 lib(FAIL 已由 GNU 对照定案;钉与 GNU 探针已足够),记为未跑。
  • -D warnings / fmt / hygiene:未跑(同上,FAIL 定案优先)。
  • CI:gh pr checks 3754 未逐格归因(草稿、且已有 F1/F2 定案),记为未跑。
  • GNU 对照:WSL GNU bash 5.3.20(1);alt3754.sh 20 形状里 18 个一致(unset/空/空白 IFS 全对),2 个 IFS=':' 字面分隔符形状分歧;alt3754c/d/e.sh 进一步定位到 F1/F2。探针路径已给。

续作记录:无(本 lane 不改代码)

未跑/VOID 的腿:lib 双边、-D warnings、fmt/卫生、CI 逐格(原因:GNU 对照已定案 FAIL,未继续消耗构建)

Address audit findings F1/F2 on the emit-model rework: the rhs of an
unquoted braced alternate is assembled as ONE word and split once, not
segmented per piece (GNU expand_string_for_rhs runs the rhs under
W_EXPANDRHS|W_NOSPLIT2, subst.c:4462-4501, so add_ifs_character leaves
expansion-produced IFS bytes raw for the deferred split,
subst.c:11950-11980, :12098-12160).

- fuse_alternate_word_fields: word-level W_NOSPLIT2 rejoin
  (subst.c:12123-12148) — has_dollar_at without quoted_dollar_at under a
  set IFS not starting with ' ' splits the assembled word on the IFS
  chars then rejoins with ' ' into ONE field; quoted pieces are
  IFS-protected like GNU's CTLESC and `\<char>` escapes stay glued.
- emit_unquoted_alternate_fields + emit_alternate_scanned_text:
  expansion-produced text under an unquoted outer is re-scanned for
  ambient-IFS chars — `${q:-$*}` under IFS=: splits the $* join bytes,
  unquoted $@ element internals split under a ' '-first IFS, and
  element boundaries stay hard under an empty IFS. Carrier bytes keep
  their payload opaque.
- embedded `"pre${name OP rhs}post"` alternates carrying a $@-class
  list resolve through BracedAlternate segments precomputed against
  &mut self (Fn-closure constraint), with the had_quoted_null
  empty-field for a quoted word whose rhs produced nothing
  (subst.c:12026-12035): `n "${foo-$@}"` yields one empty arg.
- protected_lists narrowed to genuinely quoted contexts — under an
  unquoted outer every expansion byte is unprotected (subst.c:12153).

Gate replay (macOS, GNU bash 5.3.20 oracle): dollar-* subs match the
pre-rework baseline per-sub; 4 probe matrices (fuse/separator/embedded/
escape) byte-identical; 6/6 pin tests green.

Refs #3605

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

@caomengxuan666 F1/F2 返工完成,fb1422fa 已推。

F1(is_delimiter 只认 ambient-IFS 空白):emit 流改为按 GNU 真值表重构 —— unquoted-outer 下 rhs 组装成单个 istring 后整体切分(W_NOSPLIT2,subst.c:4462-4501),add_ifs_character 让 expansion 产出的 IFS 字节保持 raw 待延迟切分(subst.c:11950-11980, :12098-12160),所以 $*-join 出的 :、list 元素内部的 都会切。非空白分隔符仍按 emit_delims 裁决(unquoted outer 恒真 / quoted outer 仅 has_dollar_at 时)。

F2(outer_double_quoted 早退):不再是外层早退 —— unquoted outer 的 $@ 走 word-level W_NOSPLIT2 rejoin(subst.c:12123-12148:has_dollar_at && !quoted_dollar_at && ifs 非空且首字符非 ' ' → 整词按 IFS 切后以 ' ' 重接为一个字段),"${u- x:"$@" }" 走 quoted_dollar_at 分支(subst.c:12153)逐元素受保护切分。embedded "pre${v- x:"$@" }post" 走 BracedAlternate segment 预计算字段 + had_quoted_null 空字段(subst.c:12026-12035,n "${foo-$@}" → 1)。

验证:4 组探针矩阵(fuse / ' '-first IFS / IFS='' / \ 转义)对 GNU 5.3.20 逐字节一致;run-dollars 全 29 个 dollar-* sub 与 base 逐行对齐(残余 star9/star7/at-star3/at-star5 各行均为已登记的独立族,非本 PR 域);pin 6/6;fmt/marker-lint 净。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】t2 批次汇总(S 波收尾,5 条)

阻塞/移交项:#3754 全腿验证待补;#3741 需定位 stale FileFd 句柄生产者(候选:spawn fd transport / carrier 探测路径)后重制定修;#3747 ? 尾修复面在 scan_error_value/parameter_expansion_error_in_word_context 系。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3754 第2轮 — 建议:FAIL(两枚确定性回归,钉外既有 guard 被打破)
head: 90a9b90(本 lane 合并 origin/master 5d253cf + E0061 修复提交;原 head fb1422f 的回归在合并前已存在,已在 fb1422f 上复验)base(merge-base): 0a405d8 文件: 4 个 +1288/-21
关联 issue: #3605(状态:open,伞目录,本轮不关单;核于 2026-11-17 本地)

续作记录(本轮动过代码):

  • 18bb708 Merge remote-tracking branch 'origin/master' into HEAD —— 原 head 在 CI merge-ref 上 E0061 编译失败(master 给 push_body_piece 加了 in_at_span 第三参 src/executor/command_substitution_values.rs:2331,PR 新增 BracedAlternate 调用点 :2206 仍传 2 参);文本合并干净但语义断裂,全 CI job 编译即挂。
  • 90a9b90 fix(executor): pass in_at_span at merged BracedAlternate call site —— 该调用点位于 quoted_body_positional_at_segments 的 "..." body 扫描内,同函数全部兄弟调用点均传 true(唯一 false 在另一函数的整词快路径 :2297),取值无歧义。已推 origin/devin/alternate-rhs-seps(push 前 gh api 确认远端 head 仍 fb1422f)。

机制核查:

  • 方向维持第1轮结论:rhs 按 word 机制展开、separator 按 IFS 真值表切分(subst.c:4462-4501 W_NOSPLIT2、:11950-12160 delay split、:12026-12035 had_quoted_null),F1/F2 返工属实。
  • 但 rework 在「alternate OP 的 rhs 本身是带空首元的 quoted slice」这一族上丢了空字段,见 F1/F2。

腿(逐项数字):

  • 钉自跑(合并 head 90a9b90,Windows):issue3605_alternate_fragment_separators → 6 passed / 0 failed
  • fail-first:origin/master 5d253cf + 钉文件原样 → 3 passed / 3 failed,红名 = {non_whitespace_ifs_keeps_whitespace_separators_literal, non_whitespace_ifs_separators_delimit_list_bearing_rhs, null_ifs_glues_separators_to_boundary_fields},与 PR 声称修复面一致(钉有效)
  • lib 双边(cargo test --lib --test-threads=2):head 1360p/3f {issue2084_session_end_restores_host_process_state, windows_virtual_system_root_arguments_keep_option_b_shapes_verbatim, windows_virtual_system_root_arguments_shell_wrapped_children_verbatim} / base(master 5d253cf) 1359p/4f {issue2084 同名 + windows_memoized_miss_self_heals_via_probe_grid, windows_virtual_system_root_argument_shape_class, windows_virtual_system_root_arguments_legacy_dialect_reverts};executor::path::tests::windows_* 各组失败名逐次漂移(复跑同 head path 子集 8 红且名集再变)→ 本机环境性 flaky,非本 PR 账;差集按名集 = {}(issue2084 两侧同名环境失败)
  • -D warnings:CARGO_INCREMENTAL=0 RUSTFLAGS="-D warnings" cargo check --locked --lib --bins → 0 警告
  • 卫生:rustfmt --edition 2021 --check 4 个涉改文件全 OK;marker-lint OK(118 consts, 268 allowlisted);utf8-hygiene clean
  • CI(新 head 90a9b90,run 43916978963):Rust tests / Windows compile check / Compatibility CLI / Shell functionality / Cross-target linux / niubash builds / API ledger 全 pass;红 = GNU goldens {issue_753::case_9_declare_indexed_operand_binds_nothing, upstream_suite_slice_snapshots}(与 master 基线同名同数 → 基线)+ census(见下)+ darwin/macOS 仍 pending
  • census 逐名归因(head 91 红 vs master 08979f2 基线 88 红):
    • 本 PR 账 2 名(见 F1/F2):issue315_guard_alternate_regressions::guard_slice_fans_out_in_argv_and_for、arrdefault_quoted_array_default_regressions::guard_147_idioms_stay_green
    • 时序性 flaky 1 名:issue2053_coproc_wait_race_regressions::dead_coproc_vars_disposed_after_loop_iterations(本机复跑 4/4 绿)
    • 陈旧基线 1 名:issue3575_posix_pwd_same_file(修复 9defebd 在本 head 合并点 5d253cf 之后,squash 后自然消)
    • master 侧多出 issue2657_unset_assoc_quoted_key(基线时点旧,本 head 已绿)
  • GNU 对照:WSL /usr/local/bin/bash 5.3.20(1)-release x86_64-pc-linux-gnu,脚本 target/u1-probes/alt3754.sh(14 形状:unset/置空/置位 × IFS=':'/ ' :' / '' / '!' × unquoted/quoted outer × $@/$* × 转义空格 × 嵌入 braced × had_quoted_null × ${0+...})→ stdout+stderr 逐字节一致,双方 rc=0。F1/F2 原复现形状 P1(n=3 < x>)P2(q_n=3)均一致。

F 点:

  • F1: tests/issue315_guard_alternate_regressions.rs::guard_slice_fans_out_in_argv_and_for 确定性红(head 与原 head fb1422f 均红,master 9defebd 绿,测试文件 merge-base..master 零改动)。脚本:b=( "" foobar ); set -- ${b[@]+"${b[@]:0:2}"}; echo argc=$#; printf '[%s]' ${b[@]+"${b[@]:0:2}"} → GNU 5.3.20 实测 argc=2 / [][foobar];head 输出 argc=1 / [foobar]——alternate + 的 rhs "${b[@]:0:2}" 产出的空首元素被丢。属本 PR 域(alternate rhs word-list 的空字段保持,had_quoted_null/边界 field 语义)。
  • F2: tests/arrdefault_quoted_array_default_regressions.rs::guard_147_idioms_stay_green 确定性红(同上三方对照)。脚本末格 b=("" x); for f in ${b[@]+"${b[@]:0:2}"}; do echo "[$f]"; done → 期望 [] + [x] 两行,head 只出 [x]——同一空首元素丢失族。
  • 两格均为既有 pin(非本 PR 新增),GNU 期望已由我方 WSL 5.3.20 复核(guard315.sh 实测 argc=2 / [][foobar] / iter=[foobar])。合入会往 master 落 2 个确定性红格。

未跑/VOID 的腿:CI darwin cross-target 与 Rust tests (macOS) 在写报告时仍 pending(run 43916978963 未完成);不影响判词——F1/F2 已由本机确定性复现定案。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】u1 批次汇总(U 波收尾,5 条)

阻塞/移交:#3754 待返工(空首元素族);#3747 待返工(? 尾解析后判定,special+named 源);#3741 待返工(stale FileFd 根因定位);#3740 待队长三选一裁定;#3724 已落地。

…(Refs #3605)

An unquoted `${param OP word}` rhs whose word is a `"..."` piece
containing a `$@`/`$*`-class list was routed through the unquoted-segment
emitter, so its literal interior spaces turned into word boundaries and
the field text lost them (`IFS=:; set -- ${u- "x $* y" }` gave
`< xa:by >`, GNU `< x a:b y >`).  Only a double-quoted outer needs that
route: parameter_brace_expand_rhs strips embedded unescaped `"` there
(subst.c:7977-7984 string_extract_double_quoted SX_STRIPDQ), so the rhs
behaves as one double-quoted string whose literal IFS bytes delimit the
deferred split (subst.c:12098-12160).  Under an unquoted outer the piece
is an ordinary double-quoted word, so expand it with the word machinery
(subst.c:7966-7990 expand_string_for_rhs, quoted == 0).

Also carry the quoted context into alternate_list_fields so a
`${name[@]<op>}` token scanned from a quoted piece expands as
`"${name[@]<op>}"`, keeping empty elements (subst.c:7840-7860
param_expand propagates `quoted`); the unquoted path keeps the bare
expansion.  This restores the guard_slice_fans_out / guard_147 empty
first element (GNU argc=2, `[][foobar]`).

Verified against WSL GNU bash 5.3.20 byte-for-byte on 24-shape and
6-shape matrices; pins issue3605_alternate_fragment_separators 6/6,
issue315_guard_alternate_regressions 5/5,
arrdefault_quoted_array_default_regressions 11/11,
issue1993_dollar_star_regressions 5/5.
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 17, 2026 06:02
@caomengxuan666

Copy link
Copy Markdown
Member Author

【o1 收网验证 · 建议 PASS】head d155a196(远端一致;未重做 WIP,从验证接手)

机制锚点:unquoted-outer 下 rhs piece 是普通 "..." word,走 word machinery(subst.c:7966-7990 expand_string_for_rhs quoted==0);仅 outer 为双引号时 parameter_brace_expand_rhs 才剥离内嵌 "(subst.c:7977-7984 string_extract_double_quoted SX_STRIPDQ)需旧的 unquoted-segment route。alternate_list_fields(quoted) 让 "..." piece 内的 ${name[@]op} 按 "${name[@]op}" 展开(subst.c:7840-7860 param_expand 传播 quoted),恢复空首元素。

腿(Windows,本机):

  • 钉 issue3605_alternate_fragment_separators 6/6;issue315_guard_alternate_regressions 5/5(含 guard_slice_fans_out_in_argv_and_for);arrdefault_quoted_array_default_regressions 11/11(含 guard_147_idioms_stay_green);issue1993_dollar_star_regressions 5/5。两枚历史 census 回归均绿。
  • fail-first(base f02d7299):钉 3 failed / 3 passed,红名为 non_whitespace_ifs_keeps_whitespace_separators_literal、non_whitespace_ifs_separators_delimit_list_bearing_rhs、null_ifs_glues_separators_to_boundary_fields → 有效。
  • lib 双边:head 1372P/1F,base 1372P/1F,失败名集合差 空;唯一红 api::consumer_tests::issue2084_session_end_restores_host_process_state 在本机 shell 注入的 __RUBASH_CURRENT_LINE=1 下必红(base 同样红,CI 绿)→ 环境绑定,非本 PR。
  • RUSTFLAGS=-D warnings cargo check 净;rustfmt --check src/executor/command_prepare.rs 净。
  • GNU 对照:WSL GNU bash 5.3.20 脚本文件 18 形状(default/IFS=''/IFS=':' × $@ 前后缀 × outer-dquote × x:"$@" × "x $* y" × a=('' foobar) slice)逐字节 ALL_MATCH;F1(非空白 IFS 字面分隔符在 rhs 内切分)、F2(outer-dquote 仍按 IFS 切分)两族均覆盖且一致。
  • CI 归因:census 86 红 vs 同窗口 master run 44027140238 90 红,PR-only 仅 issue1902_...(登记 flake),master-only 5 名(master 侧 flake/已修);goldens 红两边同为 issue_753::case_9 + upstream_suite_slice_snapshots(基线)。无本 PR 引入红。

关联 #3605:伞目录,保持 OPEN。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】o1 续作 — 判词:PASS(修复审计第2轮的两枚确定性回归)

head: d155a196e(branch devin/alternate-rhs-seps,远端 head 已核 = d155a19,ff 无覆盖)
merge-base/base: f02d7299d(当前 master 尖,无新 master 需合)
机制: 仅 src/executor/command_prepare.rs:unquoted outer 下的 "..." rhs piece 不再走 unquoted-segment emitter,改由 word machinery 展开(subst.c:7966-7990 expand_string_for_rhs, quoted==0;SX_STRIPDQ 剥离仅属 dquote outer,subst.c:7977-7984);alternate_list_fields 增 quoted 形参,quoted 上下文按 "${name[@]<op>}" 展开以保留空元素(subst.c:7840-7860 param_expand 传播 quoted)。是上下文分类的机制修法,不是个案守卫。

腿:

  • 钉 issue3605_alternate_fragment_separators 6/6;
  • 审计两枚回归:issue315_guard_alternate_regressions 5/5(含 guard_slice_fans_out_in_argv_and_for)、arrdefault_quoted_array_default_regressions 11/11(含 guard_147);issue1993_dollar_star_regressions 5/5;
  • fail-first(base f02d729 原样钉文件):3 passed / 3 failed,红名 = non_whitespace_ifs_keeps...、non_whitespace_ifs_separators_delimit...、null_ifs_glues...,与 head 修好的三格一一对应;两枚 guard 钉在 base 亦绿(证明是本 PR 曾打破、现修复);
  • lib 双边:head 1372 passed / 1 failed(api::consumer_tests::issue2084_session_end_restores_host_process_state),base 同 1372/1 同名列 → 差集 ∅(环境性,非本 PR);
  • RUSTFLAGS=-D warnings cargo check:0 warning;
  • rustfmt --check src/executor/command_prepare.rs:OK;git diff --check 无 CRLF/空白问题;
  • GNU 5.3.20 脚本文件对照 16 形状(default IFS / IFS=: / IFS='' × quoted-outer / unquoted-outer × $@ / $* / leading-interior : / '...' 字面 / + 型)逐字节一致(diff 空)。

F 点:F1(非空白 IFS 字面分隔符在 rhs 内切分)与 F2(outer dquote 下 $@ 类仍产生多 field)已由 S5–S9/S6/S15 形状覆盖(x:"$@" → < x> <a b> <c >;"${v- x:"$@" }" 同形)。

CI(run 44028311144, head d155a19):红 = goldens + census,逐格与同窗口 master run 44027140238(f02d7299)比对:

  • goldens 双边同为 issue_753::case_9、upstream_suite_slice_snapshots(已知基线);
  • census stem 集合:master 38 / PR 38,差集仅 PR 多 issue1902_fd_alias_fact_regressions(已知 flake),PR 少 issue2235_list_input_procsub_regressions(master 红、PR 绿);issue315_guard_*、arrdefault_* 在 census 中 16 次出现、0 FAIL。→ PR 引入红 0。

关联 issue:#3605 伞目录,不关。

@caomengxuan666
caomengxuan666 merged commit 76bb364 into master Nov 17, 2026
10 of 12 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

【o1 收网】第3轮 — 判词 PASS,已合并 mergeCommit 76bb3644f182bebb04da950a63cc8ad2fc067b2d(state=MERGED 复核)

head: d155a19(在 90a9b90 上叠 2 个 commit:d8d10d051 合入 origin/master 5d253cf..a0a6d78,d155a196e 修 F1/F2 + 新族)
base(merge-base) 0a405d8;关联 issue #3605(伞目录,保持 OPEN)

F 点回应

  • F1(issue315_guard_alternate_regressions::guard_slice_fans_out_in_argv_and_for 空首元素丢失):已修,d155a196e。
    根因不是 alternate 合并层,而是 rhs 里被扫描出的 ${name[@]<op>} token 丢失了「它在 "..." piece 内」这一 quoted 上下文:alternate_list_fields 把它按裸 token 展开,${b[@]:0:2} 元素级引号丢失,空元素被当无字段。GNU param_expand 把 quoted 传播进 rhs(subst.c:7840-7860 parameter_brace_find_indir/parameter_brace_expand_word,subst.c:7966 parameter_brace_expand_rhs 在 Q_DOUBLE_QUOTES 下按双引号串展开 rhs),故按上下文分类:quoted 上下文展开为 "${name[@]<op>}",裸上下文保持裸展开。机制修法,不是个案补丁。
  • F2(arrdefault_quoted_array_default_regressions::guard_147_idioms_stay_green 同族):同一根因,同 commit 修掉;for f in ${c[@]+"${c[@]:0:2}"} 恢复 [] + [x] 两行。

本轮自查新发现并修掉的同 PR 族(上轮审计未覆盖)

  • 非引号 outer 下 rhs 的 "..." piece(内含 $@/$* 列表)被错走到 unquoted-segment 发射器,piece 内字面空格变 WordBoundary 被吃掉:IFS=:; set -- ${u- "x $* y" } head 得 < xa:by >,GNU < x a:b y >("x $@ y" 同理:GNU < x a><b y >)。GNU 只在 quoted outer 才把 rhs 当双引号串并剥内嵌引号(subst.c:7977-7984 string_extract_double_quoted SX_STRIPDQ);unquoted outer 的 piece 就是普通双引号 word(subst.c:7966-7990 expand_string_for_rhs,quoted==0)。修法:该分支加 outer_double_quoted 前提,unquoted outer 的 piece 交回词机制。

腿(全部本轮实跑,Windows MSVC + WSL GNU 5.3.20(1))

  • 钉 issue3605_alternate_fragment_separators:6 passed / 0 failed(head)
  • fail-first:origin/master a0a6d78 + 钉文件原样 → 3 passed / 3 failed,红名 {non_whitespace_ifs_keeps_whitespace_separators_literal, non_whitespace_ifs_separators_delimit_list_bearing_rhs, null_ifs_glues_separators_to_boundary_fields}(与上轮审计同名)
  • 回归钉:issue315_guard_alternate_regressions 5/5、arrdefault_quoted_array_default_regressions 11/11、issue1993_dollar_star_regressions 5/5
  • lib 双边:head 1372 passed / 1 failed(唯一失败 api::consumer_tests::issue2084_session_end_restores_host_process_state,既存环境失败);base(origin/master a0a6d78) 1372 passed / 1 failed(同名同数)→ 失败名集差 ∅
  • RUSTFLAGS="-D warnings" cargo check --locked 0 警告;rustfmt --edition 2021 --check src/executor/command_prepare.rs OK;LF 无 CRLF
  • GNU 对照:脚本文件 target/u1-probes/alt3754-matrix.sh(24 形状:unset/置空/置位 × IFS :/ :/``/!/`,` × unquoted/quoted outer × `$@`/`$*` × 转义空格 × 嵌入 braced × had_quoted_null × `${0+...}` × 数组 slice 守卫 × 元素内 IFS 字符)+ `alt3754-qpiece.sh`(6 形状)→ stdout+stderr 与 GNU 5.3.20 逐字节一致(diff 空,双方 rc=0)
  • CI(run 44028311144,head d155a19):Rust tests / Windows compile / Cross-target linux+darwin / Rust tests macOS / Shell functionality / Compatibility CLI / niubash / API ledger 全 pass;goldens 红 = issue_753::case_9_declare_indexed_operand_binds_nothing + upstream_suite_slice_snapshots(基线,232 passed/2 failed,与 master 同两格);census 84 failed / 10623 vs 同窗口 master(run 44027140238, f02d729)88 failed / 10617:
    • 仅 head 红 1 名:issue1902_stdin_bound_to_regular_file_follows_the_binding(协议登记 flake 族 issue1902)
    • 仅 master 红 5 名:issue2235_list_input_procsub_regressions::issue2235_last_numbered_input_wins_both_producers_run、issue371_assoc_assignment_transform::{at_sign_at_a_quoted_with_null_ifs_splits_on_space, element_assigned_indexed_array_keeps_at_a_body, indexed_star_at_a_quoted_is_one_word, scalar_at_a_at_a_at_q_quoted_unchanged}(协议登记 flake 族 issue371/issue2235)
    • 上轮 2 枚确定性回归在 CI census 上均已 PASS(issue315_guard_alternate_regressions::guard_slice_fans_out_in_argv_and_for、arrdefault_quoted_array_default_regressions::guard_147_idioms_stay_green)

未跑腿/说明:git merge origin/master 为文本干净合并(无冲突);#3605 伞目录按规程保持 OPEN。

caomengxuan666 added a commit that referenced this pull request Nov 17, 2026
…#3605)

Ports the remaining dollar-star7 mechanism onto the master emit-stream
model (original-branch commits ba33521 + a6a7003, re-resolved
against #3754's emit stream and the family-A $@ arms):

- markers.rs: SPLIT_ON_SPACES_SENTINEL (PUA E31C) + contains/strip
  helpers — the in-band port of GNU's W_SPLITSPACE word flag.
- expand_braced_special.rs: unquoted ${*} under a set-null IFS joins on
  ' ' with element whitespace marked and emits the sentinel; quoted
  (extquote context), assignment-RHS and NO_SPLIT_DOLLAR_STAR contexts
  keep string_list_dollar_star's concat join (subst.c:10612-10670,
  2902-2930).
- expand_braced_replacement.rs: NO_SPLIT_DOLLAR_STAR thread-local;
  parameter_patterns.rs sets it for ${paramOPword} pattern RHS
  (expand_string_for_pat, subst.c:4518).
- embedded_{parameters,mutations}.rs: bare $@/$* arms take the
  element-wise string_list_dollar_at model — per-element whitespace
  marking under set-null IFS, sentinel emission, quoted-piece concat —
  merged with the family-A in_double protect_ifs_field_chars path.
- arrays.rs field_split_values_with_ifs: sentinel forces the split
  charset to " " (IFS set) / " \t\n" (unset) regardless of a later
  mid-word IFS bind (subst.c:11535 -> 12103-12107).
- parameter_words.rs: extend the rubash#1169 pre-scan freeze to
  IFS-dependent fragments (fragment_depends_on_ifs) so earlier ${*}/${@}
  pieces render under the pre-bind IFS; embedded walkers add ' ' to the
  quoted-span protected set when the word carries the sentinel.

Verified byte-for-byte vs WSL GNU bash 5.3.20(1) on the star7 puzzle
matrix and quoted/unquoted $*/${*}/$@ probe shapes. Pins:
issue3605_star7_splitspace_ifs_regressions 4/4 (was 1/4),
dollar_at_star_ifs_separators 8/8, quoted_null_anchor 4/4,
operator_value_ctlnul 8/8, alternate_fragment_separators 6/6.
Residual: quoted bare "$*" inside a mixed word under null IFS still
joins on ' ' (concat expected) — same class as the recorded star7
line-4 residual on #3605.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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