Repository navigation
fix(carrier): #728 registry single-declaration-point + #729 byte-class pattern normalization - #821
Conversation
…s pattern normalization #728 — markers.rs registry is the single declaration point: - Register the 12 carrier consts the static audit found outside MARKERS (ANSI_C_IFS_GUARD, LITERAL_CHAR_ESCAPE, FAILED_SUBSCRIPT_SENTINEL, PATTERN_LITERAL_BACKSLASH, PARSE_ERROR_FIELD_SEP, HEREDOC_WARNED_BODY_ PREFIX, QUOTED_HEREDOC_MARKER, COMSUB_PAYLOAD_PREFIX, COMPOUND_ASSIGNMENT_ MARKER, GROUP_REDIRECT_INJECTED_MARK, QUOTED_WORD_VALUE_PREFIX, HASH_ENV_FIELD_SEP) plus the parser/support.rs CASE_PATTERN_* sentinels, which move into markers.rs (governance 3.1 single declaration point). - 746 case 728.1: boundaries/user_reachable are now machine-read — registry_covers_every_carrier_const self-scans this file and fails when a carrier const is not a table row/_STR companion/documented range bound; user_reachable_rows_have_an_entry_reencode_story checks the raw-byte pair covers all 256 bytes and PUA rows sit in the E400 escape zone; boundary_claims_name_a_decoder pins which Output rows decode_to_visible_text owns vs which markers their own helper decodes. word_marker_byte_predicate_ scope_is_enforced makes the contains_word_marker_bytes 'no false negative' claim falsifiable (728 §3): C0 markers outside 0x11..=0x1f must be a documented domain exception. - Zero behavior change: full cargo test failure set is identical to the origin/master baseline (44 pre-existing env failures; bidirectional diff clean, +18 passed = exactly the new tests). #729 — the pattern matchers are now byte-exact for carried bytes: - GNU matches patterns/words as byte strings (subst.c pat_substr, sm_loop.c gmatch). Rubash transport spells one byte four ways (raw-byte marker pair, CTLESC-quoted pair, literal C0 char from a visible-text decode, __RUBASH_CSB1_ payload); two sides carrying different spellings of the same byte failed to match ([[ $v == *"\$(printf '\001')"* ]], bytes 0x0c/0x11/0x13/0x14-0x1f failing [[:cntrl:]]). - conditional/pattern.rs: two-sided byte-char normalization gate (sides_need_byte_char_matching), pattern/word flatten that collapses pair/CTLESC-quoted-pair/CSB1/literal-C0 spellings to byte-chars while keeping pattern syntax and bracket class names verbatim, byte-char-aware chars_match/comparable_char (ASCII-guarded so #735 E400-escaped user data can never be read as a byte), posix_class_matches classifies byte-chars by their byte and fixes [[:space:]] to the glibc C-locale set (adds \v — Rust is_ascii_whitespace excludes it). - glob.rs chars_match: same byte-char map (glob.c byte comparison). - execution_misc.rs: protect_command_substitution_output payload set gains the registered C0 markers below 0x10 (0x01/0x02 PROMPT_IGNORE_*, 0x03 DEFERRED_COMPOUND_BODY, 0x05 PREEXPANDED_STDIN_BODY) so a visible-text decode cannot re-inject a claimable marker byte; the sibling eligibility predicate command_substitution_value_needs_payload_protection sees the same set. - 746 ratchet: regression-catalog carrier-729-cntrl and carrier-735-escape land as must-match (verified byte-identical to WSL GNU bash 5.3.0); issue-735 promoted diverges -> must-match (it matches). - tests/carrier_byte_class_regressions.rs: 14 process-level pins incl. the 735 faces (user $'\uE401' round-trips ee 90 81; ${#x}=1 for E301). Known structural limit (documented, not papered over): $(...) bodies inside ${...} operands / [[ == RHS arrive at expand_command_substitution already quote-processed (quotes stripped, CTLESC inserted), so $(printf '\001') spells '001' there — instrumented evidence in the PR. Matcher-side normalization cannot fix a upstream-cooked body; filed for the pipeline owner. All GNU-verified faces listed in the PR disposition table. GNU anchors: parse.y:5694-5706 got_escaped_character; subst.c:4692 dequote_escapes; subst.c:4807 dequote_string; subst.c pat_subst; lib/glob/sm_loop.c BRACKET/gmatch; strtrans.c ansic_shouldquote.
… both sides (master catalog rows + carrier-729/735 rows)
…ackslash flatten_pattern_to_byte_chars() dropped the PATTERN_LITERAL_BACKSLASH (0x18) arm in the #729 rewrite, so the marker fell into the generic C0 arm and normalized to byte 0x18, which matches nothing. Any pattern carrying a literal backslash (the marker trips the byte-char gate) then silently failed to match: the exp.tests exp5.sub pattern stopped stripping its prefix, and the re-recorded exp.snap showed both pattern faces printing the input unchanged. GNU oracle (WSL bash 5.3.0 script file): [0;31m\\] then ]. The matcher owns the invariant (case_pattern_atom_matches matches the marker against a literal backslash); the flatten step must normalize the marker to the backslash byte-char first. Adds flattened_literal_backslash_marker_matches_backslash unit test. upstream_suite_slice_snapshots passes 13/13 locally.
CR #821 (评审 @
|
验证不通过:
|
| 形 | GNU bash 5.3 | master 9f512fc | 本分支 8aae39a |
|---|---|---|---|
A [[ $v == *$'\001'* ]] |
match | match | match |
B x=$(printf '\001'); [[ $v == *$x* ]] |
match | match | match |
C [[ $v == *$(printf '\001')* ]](无引号 comsub) |
match | match | nomatch(3/3 稳定) |
D [[ $v == *"$(printf '\001')"* ]](带引号,票面 scoped-out face) |
match | nomatch | nomatch(同 master,如实分歧) |
E x=…; [[ $x == a?c ]](word 侧字节) |
nomatch | nomatch | nomatch |
F case $v in *$'\001'* |
match | match | match |
C 形在 master 上已与 GNU 一致,被本分支改坏。根因指针:execution_misc.rs 的 protect_command_substitution_output 把 0x01(PROMPT_IGNORE_START)加入保护集后,comsub 输出的字面 0x01 改走 __RUBASH_CSB1_01; payload 拼写;而 conditional/pattern.rs 的两侧归一化 gate(sides_need_byte_char_matching)没有覆盖"[[ == ]] 模式侧来自无引号 comsub"的组合——模式侧带 payload、word 侧是字面字节,正是本票要消灭的"同一字节两种拼写不匹配"泄漏类,只是在新的拼写组合上重现。B 形(变量携带,同为 word 侧字面字节)仍 match,说明仅 comsub→模式路径受影响。
问题 2(棘轮行接线缺陷):carrier-735-escape must-match 行在本仓 runner 下结构性告警
python scripts/regression-catalog/runner.py --only carrier-729-cntrl,carrier-735-escape,issue-735 实测:
carrier-729-cntrl match
carrier-735-escape DIVERGES ← ALARM (must-match)
issue-735 DIVERGES (diverges 行,预期内)
diff 内容:$'\uE401' 的 od 与 ${#x}——GNU 输出 5c 75 45 34 30 31/len=6,本分支输出 ee 90 81/len=1。这不是 shell 行为分歧:runner 对 GNU oracle 硬编码 LC_ALL=C(runner.py:167),C locale 下 GNU 自身无法编码 PUA、落字面量回退;LC_ALL=C.UTF-8(含 WSL 默认)下 GNU 与本分支逐字节一致(ee 90 81/len=1/self-match=0 双侧同)。但效果是:该行在本 runner 下任何主机、永远 ALARM(runner exit 1),棘轮失去信噪。case 体是 locale-conditional 的,runner 的 oracle 是 locale-pinned 的,两者不匹配。修法任一:case 体顶部显式 export LC_ALL=C.UTF-8(对 rubash 侧惰性)、或 runner oracle 侧升 C.UTF-8、或该行降级并注记 locale 条件。carrier-729-cntrl 行不受影响(locale-robust,实测 match)。
通过面(供对照)
- markers.rs registry is not the single declaration point: 12 consts outside MARKERS, boundaries/user_reachable never read, contains_word_marker_bytes invariant unfalsifiable #728 全部落实:12 个 carrier consts 入 MARKERS 表、CASE_PATTERN_* 迁入 markers.rs、三个可证伪注册表测试(
registry_covers_every_carrier_const/user_reachable_rows_have_an_entry_reencode_story/boundary_claims_name_a_decoder)+word_marker_byte_predicate_scope_is_enforced全绿(lib markers 18/18)。 - carrier consumer inventory: 64 of 110 carrier files unguarded, 29 RISK sites (28 marker-silent), and a second copy of the fast-path carrier class in command_substitution_values.rs #729 受保护面:
carrier_byte_class_regressions14/14;邻域 9 套(patsub/case-pattern/glob×4/nounset/read-carrier 等)78/78 绿;与 master 同批次失败集逐名 diff 为空(master 侧同 64 测试全绿 + markers 14,分支精确 +18,与票面 5373+18=5391 口径闭合)。 - 746 棘轮:carrier-729-cntrl must-match 实测 match;manifest 的 issue-735
diverges行为 master 侧另一 face(${x@Q},Post-merge review triage of #790/#789/#791: user-reachable wrapper flag, getppid() race in PID namespaces, carrier-blind quote simulation #794/2026-10-18 PR wave: 3 byte-level regressions vs GNU 5.3.0 (comsub assign guard byte, @K trailing space, kill-then-wait notice) #796),与本票 carrier-735-escape must-match 行并存,语义不冲突(票面"promoted"描述的是分支时点,最终树以两行并存为准——建议票面补一句)。 - scoped-out 诚实性:
${v#*$(printf '\001')}/${v//…/X}两面分支==master==divergent(如实文档化)。 - 与 fix(executor): inline tput arm — Windows-only whitelist answers byte-equal to GNU ncurses (#800 face A) #884(已合并 4dcb7ff)文件集无交叠,rebase 无虞。
结论
#728 主体与 #729 的受保护面验证通过,但 C 形回归是本票要消灭的泄漏类的再现(且把 master 上已 GNU 正确的形改坏),问题 2 是随票落地的棘轮行接线缺陷。两条都修掉(C 形需要把 comsub→[[ ]] 模式路径纳入两侧归一化 gate,或保护集对模式上下文豁免后另行处理)即可直接进合并流程;届时 carrier-735-escape 行应能在 runner 下转绿。
… catalog case locale Two blocking items from the PR #821 verification review: 1. `[[ $v == *$(printf '\001')* ]]` (unquoted comsub byte inside a `[[ == ]]` glob pattern) regressed match -> nomatch. The #729 protect widening makes comsub output carry 0x01 as the `�` payload spelling, which is all printable ASCII, so literal_pattern_equality / simple_glob_matches admitted the pattern on `pattern.bytes()` alone and verdicted before sides_need_byte_char_matching could decode the payload. GNU matches patterns and words as byte strings (subst.c glob_pattern_patscan, gnulib strmatch.c gmatch walks `unsigned char` buffers), so the byte-spelling normalization gate now runs BEFORE the pattern-only fast paths in both case_pattern_matches and case_pattern_matches_nocase. This also gives `?` the correct arity against pair-encoded / CTLESC-quoted word bytes (GNU: `x=$'\x11'; [[ $x == ? ]]` -> 0). 2. `carrier-735-escape` must-match row could never pass under the catalog runner: runner.py pins the GNU oracle to LC_ALL=C, under which bash cannot encode PUA codepoints and falls back to literal `\uXXXX` text, while rubash always runs the UTF-8 model. The case now exports LC_ALL=C.UTF-8 so both sides run the UTF-8 domain where they already agree byte-for-byte (`ee 90 81`, len=1, self-match=0); the export is inert on the rubash arm. Also restores LF endings on the carrier-729/735 manifest rows (CRLF slipped in via the merge-conflict resolution in 5878cff). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Rework @
|
|
Correction to the known-gap line above: the repro is u=$'\uE401' followed by [[ $u == ? ]] -- returns 1 on ac23cbb; GNU bash 5.3.0: 0. (Markdown ate a backslash.) |
Independent re-verification @
|
| form | GNU 5.3.0 | ac23cbb |
|---|---|---|
[[ $v == *$(printf '\001')* ]] (C-form) |
0 | 0 (was 1 on 8aae39a3) |
x=$(printf '\001'); [[ $v == *$x* ]] |
0 | 0 |
[[ $v == *$'\001'* ]] |
0 | 0 |
case $v in *$'\001'*) |
match | match |
x=$(printf '\001'); [[ $x == a?c ]] |
1 | 1 |
x=$'\x11'; [[ $x == ? ]] |
0 | 0 |
[[ 'abc' == *$(printf '\001')* ]] (neg ctl) |
1 | 1 |
| nocasematch C-form | — | 0 |
Root cause confirmed per the review: __RUBASH_CSB1_01; is all printable ASCII with no glob syntax, so literal_pattern_equality / simple_glob_matches verdicted on pattern.bytes() alone before sides_need_byte_char_matching could decode the payload. Moving the gate first closes the class — [[ ]], nocasematch, and the ?-vs-pair-encoded side-effect all now take flatten_*_to_byte_chars.
Unchanged scoped-out faces: quoted comsub pattern ([[ $v == *"$(printf '\001')"* ]]) still 1 = master; u=$'\uE401'; [[ $u == ? ]] still 1 (the flatten layer does not fold U+E400+escaped char — out of scope for this ticket, unchanged from 8aae39a3).
Item 2 — carrier-735-escape ratchet wiring
export LC_ALL=C.UTF-8 at case top is inert on the rubash arm and moves the LC_ALL=C-pinned GNU oracle into the UTF-8 domain where both sides already agree. Focused run:
carrier-729-cntrl match
carrier-735-escape match (was: permanent ALARM on every host)
issue-735 DIVERGES (declared diverges — expected)
Full catalog run: exit 0, zero ALARMs. Sensitivity check: temporarily flipping issue-735 to must-match reproduces ALARMS: issue-735 (#735) and exit 1 — the ratchet still goes red on real divergence. Reverted; tree clean.
One unrelated pre-existing note: the full run prints PROMOTE: lim-f5-fd-cap (#773) — the case now matches (via #884-era fd work) while its manifest row still says diverges. Present on master too; left untouched as out of scope, flagging for the catalog owner.
No-regression
carrier_byte_class_regressions15/15 (incl. newunquoted_comsub_byte_in_conditional_pattern)- lib
markers18/18 - Neighbors 60/60: issue354, issue372, issue311, issue868, comsub_nonascii_span, issue349_350, issue361, issue386; plus issue277/323/843/707/322/316/377/369/148 (82/82)
- Failure-set diff vs
8aae39a3: empty.cargo test --no-fail-fastnon-green targets are identical by name on both commits — 23cli_tests(examples/fd_redirects/tilde/coproc), 6executor_tests(host-path/env assertions), and one each in issue526/647/680/705/path_contract/regression — all environment-bound on this host, none touched by this diff.
Diff scope
8aae39a3..ac23cbb0 touches only: conditional/pattern.rs (gate reorder in both match fns), tests/carrier_byte_class_regressions.rs (+1 test), cases/carrier-735-escape.sh (locale pin), manifest.tsv (CRLF→LF on the two carrier rows). No flatten_* changes — the B1 remainder is untouched as agreed.
Generated with Devin
|
终审结论:再退(基座漂移阻塞,非上轮两项打回点的问题——那两项在自身基座上审读成立,见第 3 节)。head ac23cbb 现在无法落地上 master:上轮验收后,master 已于 10-21 落地 #947(E400-aware sentinel decode family),comsub 载荷拼写从 1. 阻塞一:PR 对 master 已 CONFLICTING,CI 从未在 head 上跑过
2. 阻塞二:#947 语义对撞,naïve 合并不可编译
3. 上轮两项打回点(在自身基座 8aae39a 上)——审读成立,带过不重开
返工清单(建议):merge origin/master → execution_misc.rs 按"扩展字节集 × sentinel 拼写"解冲突 → markers.rs/pattern.rs 的 #729 机制重指向 sentinel(3 处 const 引用 + decode 语义)→ manifest 双方行集合并(LF)→ 重建 arm 重跑全量 catalog(exit 0 零 ALARM、carrier-735-escape 行 match)+ 注假 diverge 仍红(negctl)+ carrier 定向 cargo 套件 → push 后 CI 才会真正起跑(冲突解除后 pull_request 事件恢复触发)→ 绿后再约终审。 本轮未合并、未推送、未动主树;review worktree 已删净。 |
…chanism at the U+E319 sentinel #947 retired the ASCII `__RUBASH_CSB1_<hex>;` payload spelling in favour of `U+E319<hex><hex>;` (COMSUB_PAYLOAD_SENTINEL, markers.rs). Resolution keeps the #729 extension and swaps only the spelling: - execution_misc.rs protect_command_substitution_output: extended byte set preserved (registered C0 markers 0x01/0x02/0x03/0x05 + 0x10..=0x1f), emitted as sentinel+hex+';' per #947's grammar. - conditional/pattern.rs: sides_need_byte_char_matching gates on COMSUB_PAYLOAD_SENTINEL (its 0xEE lead-byte probe already covered the E3xx plane); decode_payload_prefixes_to_pairs rewritten as decode_payload_sentinels_to_pairs with the same E400-aware grammar as execution_misc decode_command_substitution_payload. The four case_pattern_matches* entry points all use the wider gate (master's narrower either_side_needs_byte_char_matching removed; the '[' exclusion dropped — flattened_literal_backslash_marker_matches_backslash requires the gate to fire on '['-bearing patterns). - markers.rs: stale COMSUB_PAYLOAD_PREFIX MarkerInfo row deleted (the sentinel row already carries Output+Storage); the boundary-owner list and first-codepoint honesty table repointed to the sentinel names. - manifest.tsv: union — master's issue rows + the two carrier-729/735 rows (LF). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The case invokes "$THIS_SH" -c recursively; rubash exports THIS_SH at
Executor::new, but the runner's GNU arm (wsl env LC_ALL=C bash probe.sh)
has no harness variable, so the row was a structural ALARM on every host:
probe.sh: line N: : command not found, rc=127 -> permanent DIVERGES on a
must-match row. Same wiring class as the carrier-735-escape locale pin.
`: "${THIS_SH:=bash}"` is inert on the rubash arm (auto-detected value
kept) and resolves `bash` on the GNU arm the same way the runner itself
resolves the oracle.
Verified: with a clean env (unset THIS_SH BASH_ENV WINUXSH_ROOT) the
case now measures match; the dirty-env THIS_SH=<winuxcmd bash.exe> leak
that made the arm spawn the old shim (which still decodes the retired
__RUBASH_CSB1_ spelling) is a host artifact, not a product path.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Rework round 2 @
|
终审结论:再退(1 个新阻塞面;其余清单项全过)head 阻塞项:无引号 comsub 夹于字面之间入
|
| 字节 | GNU 5.3.0 | master f17feb5 | head 11544e4 |
|---|---|---|---|
| 0x01 | 0 | 0 | 1(新回归) |
| 0x02 | 0 | 0 | 1(新回归) |
| 0x03 | 0 | 1(master 固有) | 1(与 master 持平,不计) |
| 0x04 | 0 | 0 | 0 |
| 0x05 | 0 | 0 | 1(新回归) |
| 0x06 / 0x11 / 0x17 | 0 | 0 | 0 |
机制上正是本票要消灭的"同一字节两种拼写不匹配"泄漏类:rework 把 0x01/0x02/0x05(PROMPT_IGNORE_START/END、PREEXPANDED_STDIN_BODY)纳入 protect_command_substitution_output 保护集后,comsub 输出以 U+E319<hex>; payload 拼写进模式;payload 夹在两个字面之间(a$(…)c)时模式侧与 word 侧归一化失配 → nomatch。round 2 的探针矩阵与钉子测试 unquoted_comsub_byte_in_conditional_pattern 覆盖的全是星号/通配形(*$(…)*、?$x、整词 $(…)、[c1-c2] 范围、?$(…)?,实测全过),夹字面形是矩阵盲区。
交叉定位:同形对 0x10..=0x1f(master 原保护集,如 0x11 exact=0 双方一致)与 0x04(未注册不保护)均 match——恰好只有 #729 扩宽新增的三个注册 C0 标记回归,把回归钉死在"扩宽 × 新拼写 × 夹字面"组合上。根因指针:pattern 侧 payload 与字面相邻时按 E400 literal-char 转义对到达(protect_command_substitution_output 自身注释即言明 bare / E400-escaped 两种到达方式),而 decode_payload_sentinels_to_pairs 按 #840 契约必须把 E400 转义的 sentinel 当用户数据跳过 → payload 永不归一;整词 comsub 形无相邻字面 → bare sentinel → match。修法方向(择一):[[ ]] 模式装配路径区分 protocol/escaped sentinel;或模式上下文对这三个字节豁免保护集(回到 master 形态);或 flatten 层把 E400 转义对折叠使 word/pattern 两侧对称(顺带消掉在案的 B1.1 余项)。
终审清单(独立复跑)
- 冲突解决审读:过。重算 merge 冲突恰为 4 文件(manifest.tsv、pattern.rs、execution_misc.rs、markers.rs),解法与 commit message 一致自洽;
COMSUB_PAYLOAD_PREFIX在 src/ 零残留(唯一出现是 issue824 测试 doc 注释里的历史 panic 文本,属记录性引用);CSB1 退役干净(a__RUBASH_CSB1_15;b原样直通有钉子);E319 sentinel 与 raw-byte 对(E000-E100)、byte-char(E100-E1FF)、hygiene widen allowlist 占域互斥,无新增as char位点;either_side_*无残留、[-exclusion 移除与 flattened_literal_backslash 依赖相符。 - comsub-0x01:未达(见阻塞项)。星形逐字节 60 探全 match,
?/范围/!=/nocase 全 match;带引号 comsub 形维持与 master 相等的 1(在案 scoped-out,如实);夹字面形 0x01/0x02/0x05 回归。 - carrier-735-escape + THIS_SH:过。locale pin(case 内
export LC_ALL=C.UTF-8)dirty/clean env 双跑均 match;init.rs:525+keep-inherited 例外(sh/bash basename + is_file)为本 PR 零改动的 master 既有逻辑;dirty-envTHIS_SH=<winuxcmd bash.exe>host artifact 现场复现——arm 侧$THIS_SH -c子进程落到旧 shim、旧 shim 解码已退役 CSB1 拼写(__RUBASH_CSB1_41;→A),diff 与 commit message 逐字吻合;clean env(env -u THIS_SH BASH_ENV WINUXSH_ROOT)下 issue-948 match。 - 全量 catalog + negctl + manifest:过。clean env 全量 54/54 行命中声明预期,exit 0;注入假 diverge($BASH_VERSION 探针行 must-match)实测 ALARM + exit 1;manifest 52+2=54 行 +header、LF 结尾、carrier-729-cntrl / carrier-735-escape 两行均 match。
- markers.rs registry is not the single declaration point: 12 consts outside MARKERS, boundaries/user_reachable never read, contains_word_marker_bytes invariant unfalsifiable #728/carrier consumer inventory: 64 of 110 carrier files unguarded, 29 RISK sites (28 marker-silent), and a second copy of the fast-path carrier class in command_substitution_values.rs #729 成果不回退:过。
registry_covers_every_carrier_const等 markers 注册表测试全绿;carrier_byte_class_regressions15/15(含 unquoted_comsub_byte_in_conditional_pattern);fix(executor): word-side byte-char gate for carried-byte patterns #983 钉子word_byte_char_matching_regressions4/4;邻居 decode_to_visible_text 7/7、issue880 10/10、issue824 9/9。 - CI:过。run 39651199093 head_sha 核验即 11544e4,5/5 SUCCESS(bash-upstream-progress 为 lane 设计内 skipped)。因再退,无合并后 master CI 一项。
建议返工
在新基座上修掉 3 个回归形(三个修法方向取最小不扩界者由修复方裁量),把夹字面形补进钉子测试(至少 0x01/0x02/0x05 的 exact 形),再约终审。阻塞项消除后其余各项已就绪(merge-base 与 master tip 持平,冲突面已解)。
本轮:未合并、未推送、未动主树;两个 review worktree 已删净并重列复核。
…yload bytes (rubash#729 rework) Round-3 review blind spot: an unquoted comsub payload SANDWICHED between literals (`[[ $v == a$(printf '\001')c ]]`) carries no glob syntax, so conditional_pattern_or_string_matches verdicted the `U+E319<hex>;` transport spelling with plain `left == right` equality — the same "same byte, two spellings" leak class as the star-flanked forms, one fast path earlier. Bytes 0x01/0x02/0x05 (the #729-widened registered C0 markers) regressed to nomatch where master and GNU 5.3.x both match. Fix by root-cause subsystem, not by symptom: the byte-spelling gate (sides_need_byte_char_matching) now also admits the no-glob compare in conditional_pattern_or_string_matches, so a glob-free pattern carrying a marker spelling is normalized by flatten_*_to_byte_chars before the literal compare — verdict-identical for marker-free inputs. GNU anchor: execute_cmd.c:4043 patmatch -> cond_expand_word -> shmatch.c:585 xstrmatch -> sm_loop.c internal_strmatch on unsigned-char buffers. The same leak sat in two sibling arms, both new regressions vs master (probed against the master binary): - extglob entries: `shopt -s extglob` routes EVERY pattern through extglob_case_pattern_matches*, which staged raw chars and skipped the gate entirely — `a$(…)c`, `+(a$(…)c)`, `?(a)$(…)c` and case arms all failed. All four entries now run the gate and flatten before extglob_matches_at_with_case; the *_with_word_chars twins re-materialize the word only on gate-fire (lazy, per the LAZY cell contract). - `=~`: compile_conditional_regex now decodes the payload spelling to the carried byte before regcomp, and the subject side decodes the same way in conditional_regex_match{,_status} / conditional_quoted_regex_match_status (execute_cmd.c:4137 sh_regmatch regexec's the expanded operands). Probe matrix (debug build, script files, master A/B): exact-byte 0x01/0x02/0x05 -> 0 (were 1); 0x03 stays 1 (master-inherent divergence, unchanged); 0x04/0x06/0x11/0x17 stay 0; star/var/negctl/quoted/!=/ nocasematch/case forms preserved; extglob faces fixed; `=~` sandwich fixed; `x=$'\x11'; [[ $x == ? ]]` under extglob now 0 (GNU-correct; master diverged there). New pin: unquoted_comsub_byte_sandwiched_in_conditional_pattern. carrier_byte_class_regressions 16/16; lib 766/766; neighbor and conditional-adjacent suites green (issue354/372/311/868/ comsub_nonascii_span/349_350/361/386 plus case/extglob/regex set). Pre-existing note: issue843 literal_typed_glyph_in_replacement_body fails identically at unmodified head 11544e4 on this host — not from this diff. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Rework round 4 @
|
| form | GNU 5.3.x | master | head 11544e4 | 66635b7 |
|---|---|---|---|---|
a$(printf '\001')c exact (0x01/0x02/0x05) |
0 | 0 | 1 | 0 |
| 0x03 | 0 | 1 (inherent) | 1 | 1 (unchanged, master-inherent) |
| 0x04/0x06/0x11/0x17 | 0 | 0 | 0 | 0 |
*$(…)*, ?$x-style, !=, nocasematch, case, quoted |
match | — | preserved | preserved |
extglob a$(…)c / +(a$(…)c) / ?(a)$(…)c / case arm |
0 | 0 | 1 | 0 |
=~ a$(…)c |
0 | 0 | 1 | 0 |
negctl 'abc'==*$(…)* |
1 | 1 | 1 | 1 |
u=$'E401'; [[ $u == ? ]] |
0 | 1 | 1 | 1 (documented known gap, unchanged) |
${v#a$(…)} / ${v%$(…)c} |
strip | keeps | keeps | keeps (scoped-out face, master-parity) |
Bonus via the same gate: x=$'\x11'; shopt -s extglob; [[ $x == ? ]] now 0 (GNU-correct; master diverges at 1).
Tests
- New pin
unquoted_comsub_byte_sandwiched_in_conditional_pattern(0x01/0x02/0x05 exact forms + wrong-byte negctl + star/case symmetry). carrier_byte_class_regressions16/16;word_byte_char_matching_regressions4/4; issue824 9/9; issue880 10/10; decode_to_visible_text 7/7; lib 766/766; neighbors + conditional-adjacent set all green (issue354/372/311/868/comsub_nonascii_span/349_350/361/386/322/332/389/517/675/505/336/381/385/413/369/377/148/799).- manifest.tsv unchanged: header + 54 rows, LF throughout.
- Honesty note:
issue843::literal_typed_glyph_in_replacement_bodyfails identically at unmodified11544e4bon this host (verified via stash+rebuild;a<E400><E312>xcvs expecteda<E312>xc— E400 escape leaking to output in${v/b/…}replacement). Pre-existing on this branch, not from this diff — flagging for visibility. - Full catalog run / fake-diverge negctl deferred to CI: local WSL oracle is off-limits in this workspace; the runner is unchanged and the arm-side fixes are covered by the probe matrix + pin test above.
Generated with Devin
终审通过(第四轮返工 · 根因定点修复 @ 66635b7)独立复跑全部终审项,结论:修法成立,合并为 f45e889(squash → master)。 1. 修法审读(diff 全量,13 文件 +1111/−76,真 delta 基于 f17feb5)
2. comsub-0x01 独立实测(本机 GNU bash 5.3.0(1) 逐字节对照,批量落文件方式)
3. 前三轮成果不回退
4. 棘轮验证:向 5. issue843: 6. CI:PR checks 5/5 pass(Rust tests、Rust tests (macOS)、GNU regression goldens and canaries、Cross-target check、Shell functionality tests);"Bash upstream test progress" 按声明 skipping(全量 catalog/negctl WSL 腿由 goldens/canaries 覆盖)。master CI 于 f45e889 复核(见下)。 7. 合并: 审查环境说明:独立克隆(非主树、非 PR 作者 worktree),全程未动 D:/repo/rubash;GNU oracle 走本地 bash 5.3.0 批量落文件,未用 wsl.exe;未跑全量 cargo test(targeted + 失败集对照:issue843 失败集 head≡master)。审查用克隆与 master 对照 worktree 已删净并复核。 |
Closes #728, closes #729 (partial: 26 of 29 RISK sites closed guarded/tested/documented-safe; 3 faces of one structural defect documented with instrumented evidence and scoped out).
Independent worktree: `D:/repo/rubash-wt-729-728`, branch `fix/729-728`, rebased on origin/master (7047baf).
#728 — the registry is the single declaration point
#729 — pattern matchers are byte-exact for carried bytes
GNU matches patterns/words as byte strings (subst.c pat_substr, lib/glob/sm_loop.c gmatch). Rubash transport spells one byte FOUR ways: raw-byte marker pair (E000+E0xx), CTLESC-quoted pair (quote-protected span), literal C0 char (a visible-text decode re-materializing the byte), and `__RUBASH_CSB1_xx;` payload. Two sides carrying DIFFERENT spellings of the same byte failed to match — that was the leak class behind the marker-silent RISK sites.
Boundary fixes (per the issue's own §3.2 direction — class-level, not one guard per site):
Disposition table (29 RISK sites; guarded = fixed at the class boundary + tested)
Structural defect discovered and scoped out (3 faces: ${v#*\$(printf '\001')}, ${v//\$(printf '\001')/X}, [[ == "\$(printf '\001')" ]]):$(...) bodies inside $ {...} operands / [[ == RHS arrive at expand_command_substitution already quote-processed — instrumented: body `printf '\001'` reaches the comsub as `printf CTLESC\\001`, so printf formats "001". Matcher-side normalization cannot repair an upstream-cooked body; fixing it means expanding those operands from the raw word (pipeline reorder in a hot, heavily-tested path). Evidence: temporary instrumentation transcript in the PR thread; left out of scope rather than papered over. These 3 faces stay divergent until that pipeline fix.
Baseline comparison (bidirectional, full `cargo test --no-fail-fast`)
Artifacts: `target/issue-suites/results/{baseline_full.txt,final_full.txt,baseline_failures.txt,final_failures.txt,probe729/}` (probe transcripts GNU-vs-rubash per face; the registry self-audit runs in-tree, so it survives rebases).
#746 ratchet
#735 safety (explicit)
Every normalization path refuses E400-escaped user data: the gate keys on C0/0xEE/CSB1 shapes (an E400 escape is none of them), flatten never consumes an E400 pair, chars_match's ASCII guard blocks PUA-as-byte, and the protect widening only touches C0 bytes. Pinned by `user_pua_data_roundtrips_verbatim`, `user_pua_length_counts_one_char`, `user_e401_not_stripped_by_guard_paths` + the must-match carrier-735-escape catalogue case.
#811 conflict check
PR #811 (open, fix/795-796-wave-regressions) touches assignment_expansion.rs / command_prepare.rs / command_words.rs / limit_builtins.rs + tests — file-set intersection with this branch is empty. A `git merge-tree HEAD pr811` trial merge shows one conflict in `tests/regression/snapshots/nquote.snap`, which is #811-vs-master (this branch does not touch any snapshot). Semantically: #811's fragment-boundary guard strip handles the E401 guard (PUA), untouched by this branch's C0 protect widening; its `v2=$'p\nq'\$(echo r)s` shape carries no C0 bytes and is unaffected.