Skip to content

fix(executor): admit [*]/* operator segments to the quoted-aware list path - #3632

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3581-star-join-quoted-null
Nov 16, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3581-star-join-quoted-null

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #3581

A quoted one-"" [*]/ * pattern-removal segment inside a mixed word
(X"${a[*]#...}"Y) stayed silent where GNU diagnoses bad substitution:
the AtModified segment classifier admitted only @/name[@], so the
star forms fell through to the scalar braced path, whose removal gate
hardcodes empty_is_silent = true and never sees the quoted flag. GNU
applies the operator per element for [*]/ * exactly as for [@]/@
and joins afterwards (subst.c:10119-10128 chk_atstar covers both).

Fix (src/executor/command_substitution_values.rs only):

Legs (head debcf8a5 on tip 55fd6a02):

Note: master has since moved to ca89c83a (#3577 merged); its files
(array_assignment_exec.rs, dynamic_arrays.rs, job_builtins.rs,
state_views.rs, unset_arrays.rs) do not intersect this change, so
the merge round's update-branch should apply cleanly.

…list path (Refs #3581)

A quoted one-"" `[*]`/` *` pattern-removal segment inside a mixed word
(`X"${a[*]#...}"Y`) stayed silent where GNU diagnoses `bad substitution`:
the `AtModified` segment classifier admitted only `@`/`name[@]`, so the
star forms fell through to the scalar braced path, whose removal gate
hardcodes `empty_is_silent = true` and never sees the quoted flag. GNU
applies the operator per element for `[*]`/` *` exactly as for `[@]`/`@`
and joins afterwards (subst.c:10119-10128 chk_atstar covers both; the
#1456 "the String path already does the join" rationale only holds for
the VALUE, not the quote-sensitive removal gate at subst.c:10320-10327,
which reads the QUOTED_NULL-marked joined word, 10133-10140). The fix
admits `*`/`name[*]` to `at_modified_segment_body` and routes leading-`*`
inners to `positional_modified_word_values` in `at_modified_segment_values`;
all other paths are untouched. Regression pin
tests/issue3581_star_join_quoted_null.rs: 27/27 on head (fail-first on
base: 23/27, the 4 affixed removal cells red).

Refs #3581
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 16, 2026 13:01
@caomengxuan666
caomengxuan666 merged commit 88fd543 into master Nov 16, 2026
8 of 11 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3632 第1轮 — 建议:PASS(已合)
head: debcf8a base(merge-base): 55fd6a0 文件: 2 个 +305/-18
关联 issue: #3581(状态:CLOSED,早于本次审计已关闭;我核过的时间:2026-11-23 00:45 本地)→ 本轮不再关单,只在 issue 下补一条「残差已清」的说明。

机制核查:

  • 与 GNU 一致:chk_atstar(subst.c:7635-7639)在 parameter_brace_expand 的算子分发之前就覆盖 [@]/@ 与 [*]/*,所以 [*]/ * 的算子也是逐元素应用后再按 IFS[0] 连接(subst.c:2902 string_list_dollar_star);#/% 的删除闸(subst.c:10320-10327)在 *value == '\0' 时跳过 pattern 展开 —— 带引号的单 "" 列表带 QUOTED_NULL,join 后的词非空,因此 pattern 会被展开、坏替换要诊断;/ 与 ^/,(subst.c:9362-9367、9604-9608)只测 value == 0。PR 把 at_modified_segment_body 的白名单扩到 */name[*](仍是纯文本解析器 + 变量名白名单,rubash#117 纪律),并把 leading-* 路由到 positional_modified_word_values,与 @ 同构;不是按症状加守卫。
  • 无关改动:无。改动只在 src/executor/command_substitution_values.rs + 新钉。未碰 src/lexer/continuation.rs。
  • 跨 master 复核(关键):本 PR 的 base 55fd6a02 之后,master 对同一文件另有 +147/-24(fix(executor): GNU UNQUOTED null-word discard for inner quoted nulls #3748 等)。我在本地做了 origin/master(154a95ac) + pr3632 的试合并(git merge-tree rc=0,无文本冲突;本地分支 merge-3632,未 push),在试合并树上重跑钉 27/27 绿、GNU 24 形状逐字节一致 —— 说明 fix(executor): GNU UNQUOTED null-word discard for inner quoted nulls #3748 的未加引号 null-word 改动与本次 [*] 白名单扩容不冲突、语义叠加正确。

腿:

  • 钉自跑:issue3581_star_join_quoted_null head(debcf8a) 27 passed / 0 failed;试合并树 27 passed / 0 failed
  • fail-first:base 55fd6a0 上 23 passed / 4 failed,红名 = {array_star_prefix_removal_diagnosed_when_one_empty_quoted, array_star_suffix_removal_diagnosed_when_one_empty_quoted, positional_star_prefix_removal_diagnosed_when_one_empty_quoted, positional_star_suffix_removal_diagnosed_when_one_empty_quoted},与 PR 声称的 23/27、4 个 affixed #/% 格完全一致
  • lib 双边(Windows 本机):试合并树 1356 passed / 1 failed(失败名 {api::consumer_tests::issue2084_session_end_restores_host_process_state})/ base 55fd6a0 1350 passed / 1 failed(同一名)/ 差集 ∅;head 与 base 的计数差只来自 master 新增的单测
  • -D warnings:试合并树 RUSTFLAGS="-D warnings" cargo check --locked --lib --bins rc=0,0 警告
  • 卫生:rustfmt --check 2 文件 clean;marker-lint OK;utf8 clean
  • CI(run 43615687505,head debcf8a):红 3 项,唯一红均为 api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell(基线);其余全绿。该 CI 基于旧 master,故另以本机试合并树补跑(见上)。
  • GNU 对照:GNU bash 5.3.20(1)-release(WSL x86_64)。脚本 target/probe-3632.sh(24 形状:[*]/* × #/% × 混合词/整词/双空/复合赋值、//^ 坏替换、[@]/@ 守卫、未加引号静默、空列表静默、有效逐元素删除 a=(xx hyy); "${a[*]#h}" → [xx yy])→ 试合并树 rubash 与 GNU 逐字节一致(诊断词 *a=${-y} / ${-y}、rc=1;静默格 XY rc=0;有效格 [xx yy])。

F 点:无
续作记录:未动代码(未 push 任何分支;试合并分支仅本地,merge-3632 已可删)。
squash: 88fd543(fix(executor): admit \[]`/`` operator segments to the quoted-aware list path (Refs #3581)`),head debcf8a 未变即合。
关单:#3581 已 closed(非本轮动作),改为在 issue 下补 squash 说明。
未跑/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