## 现象 双引号字符串里同时含 **命令替换** 与 **glob 元字符**(`*` `?` `[`)时,glob 元字符前多出一个未剥除的 CTLESC 载波字节 `\x11`(rubash `src/executor/markers.rs:69 CTLESC = '\u{11}'`,GNU CTLESC 的移植)。GNU Bash 5.3.0 输出干净。赋值/无 comsub/`~`/`]` 等形态均正常——触发条件是 comsum 与 glob 元字符同处一个双引号词。 在 wt/m1-here(基线 c5be7542,含 29714d5e)复现;与 #164 修复无关(改动前基线二进制同样复现,stash 验证)。 ## 最小复现(cx4.sh,LF 落盘双侧脚本文件运行) ```sh printf '%s' "a*$(echo hi)*b"; echo printf '%s' "a?$(echo hi)?b"; echo printf '%s' "a~$(echo hi)~b"; echo printf '%s' "a[$(echo hi)]"; echo printf '%s' "a[[]$(echo hi)"; echo ``` | 输入 | GNU 5.3.0 | rubash | |---|---|---| | `"a*$(echo hi)*b"` | `a*hi*b` | `a\x11*hi*b` | | `"a?$(echo hi)?b"` | `a?hi?b` | `a\x11?hi?b` | | `"a~$(echo hi)~b"` | `a~hi~b` | `a~hi~b`(正常) | | `"a[$(echo hi)]"` | `a[hi]` | `a\x11[hi]` | | `"a[[]$(echo hi)"` | `a[[]hi` | `a\x11[\x11[]hi`(每个 `[` 各带一个) | 控制组(不触发): - `printf '%s' "ab$(echo hi)cd"` → 双侧干净 `abhicd`(comsum 无 glob 字符) - `v=$(echo hi); echo "[$v]"` → 干净(赋值通道) - `'q'$(echo hi)'w'`(单引号拼接)→ 干净 - `"ab${undef:-hi}cd"` 参数展开 → 干净(仅命令替换触发) ## 杀伤面 一切 `echo "...[$(...)...]"` / `"...$(...)...*..."` 形态的诊断输出被污染控制字节;实测 makepkg/CI 类脚本常用的 `echo "X [$(cat f)]" 诊断行全部带 `\x11`(#164 验收矩阵因此被迫改用 read 取文件内容)。 ## GNU 锚点 - `subst.c:11229 expand_word_internal()` 内部可用 CTLESC 保护会被重扫的字符,但最终 argv 物化必须经过 `subst.c:4807 dequote_string()` / `subst.c:4865 dequote_word()`(剥除全部 CTLESC)——quoted word 的输出永远不携带 CTLESC。 - rubash 侧对应:29714d5e 已在 pipeline argv(command_prepare.rs materialize_expanded_command_word / pipeline_exec.rs expand_pipeline_stage_arg_words)做过 `decode_word_position_carriers`;本 bug 是 builtin echo/printf 的 argv 物化点漏了同款最终剥除(或 CTLESC 标注本不该加在 quoted 字面量段上——GNU 对 quoted word 不做 glob 重扫,无需保护)。 ## 定位建议 含 comsum 的双引号词在展开时给 glob 元字符加了 CTLESC 前缀(保护意图),但 builtin 参数物化路径没有跑最终 decode;对照 GNU:W_QUOTED 词根本不进入 pathname expansion,无需 CTLESC,应在标注侧或物化侧二选一修掉。 ## 产物 - `target/issue-suites/results/ctlesc-comsub-glob-leak/`(wt/m1-here): `cx2.sh`/`cx4.sh`(探针)、`*.rub.out`/`*.gnu.out`(原样输出)、`cx2.{rub,gnu}.od`(od -c 字节证据) - 验证命令: `target/debug/rubash.exe cx4.sh | od -c` vs `MSYS_NO_PATHCONV=1 wsl bash cx4.sh | od -c` 版本: wt/m1-here @ c5be7542(= master 29714d5e 之后),对照 WSL GNU Bash 5.3.0(1)-release。
Activity
caomengxuan666 commentedon Sep 27, 2026
已在 ef37798 修复并关闭(见 11f323ab/4f9d0a9b/6afe632a/49b7d8bf 四个 commit 的独立验收评论与矩阵产物 target/issue-suites/results/n1-exec-2026-09-26/)。474/474 + 双交叉干净。