Skip to content

test: pin extglob quoted bracket literal in group scanners (Refs #3189) - #3190

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3189-extglob-bracket-pins
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3189-extglob-bracket-pins

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Refs #3189 — test-only pin (no product code).

What this pins

Quoted literal characters inside an extglob group never match when the
quoted character is structural to the group scanners: a quoted [
starts the bracket skip in the group-end scanner and runs past the
group end, a quoted ( inflates its depth counter, a quoted ) ends
the group early, and a quoted | splits the alternative in the
alternative splitter. Root cause (both scanners in
src/executor/conditional/extglob.rs): extglob_group_end has a
backslash escape arm but no CTLESC arm, and
extglob_split_alternatives has neither — while both literal matchers
already treat a CTLESC-quoted character as an opaque literal (the
extglob one since #3098). The alternatives therefore never reach the
literal matchers intact.

GNU semantics (vendored bash 5.3 source): quote_string_for_globbing
(pathexp.c:212, convert_to_backslash branch :246-272) rewrites every
CTLESC-quoted glob character — [ included, per glob_char_p
(pathexp.c:164) — as a backslash escape before matching, and every
pattern scanner checks the escape first (PATSCAN
lib/glob/sm_loop.c:697-700 before the bracket case at :709; GMATCH
escape arm sm_loop.c:121 before the bracket arm at :327).

Pin contents (tests/issue3189_extglob_quoted_bracket_literal.rs)

11 test functions, script-file harness as in the issue3050 pin;
expectations verified byte-for-byte against the GNU bash 5.3.20
oracle and against base (pre-#3098) and current master (with #3098)
binaries:

  • RED on current master: @("a[b") and its single-quote / mid-word /
    group-position / operator (* + ? !) / [[ == ]] variants;
    @("a(b"), @("a)b"); the quoted-pipe and escaped-paren
    alternative-split shapes.
  • LOCK (already correct, must stay correct): the shapes fix(glob): extglob quoted literals match via the CTLESC arm (Refs #3050) #3098
    repaired (quoted ] / !), the accidentally-rescued shapes
    (@("a[b]c"), @("a(b)c")), unquoted bracket-class controls,
    plain (non-extglob) quoted [, plain negation, and the
    NOMATCH negative controls.

One adjudication note: the p8 ( shape was recorded as MATCH on the
#3098 head during that lane, but is deterministically NOMATCH on the
same head binary and on current master across 170+ repeat runs, as
the scanner model predicts — it is pinned RED here.

Fail-first status: the lane's five attempts to run this pin on base
a432632 were all voided by a build-environment write fault in the
lane's cell (cargo dies at its own bookkeeping writes —
.fingerprint/*/invoked.timestamp and the global-cache DB return
"Operation not permitted" / disk I/O errors — reproduced with and
without the build slot and the scrubbed-cargo wrapper; the fault is
in the cell's storage layer, not in this pin). Per-cell expectations
were instead verified directly against the real base and #3098-head
binaries, script file by script file; the full matrix and the fault
characterisation are in the lane report. The pin still needs one
harness run on a healthy machine:
cargo test --locked --test issue3189_extglob_quoted_bracket_literal
on a432632 — expected: the 7 RED functions fail, the 4 LOCK
functions pass.

本 PR 删除了什么

无(纯测试新增,一个测试文件;无产品代码改动)。

The extglob group-structure scanners (extglob_group_end and
extglob_split_alternatives in src/executor/conditional/extglob.rs) do
not honour the CTLESC escape, so a quoted structural character inside
an extglob group is read as pattern structure: a quoted '[' starts
the bracket skip and runs past the group end, a quoted '(' inflates
the depth, a quoted ')' ends the group early, and a quoted '|' splits
the alternative. The literal matchers already carry the CTLESC arm
(#3098 for the extglob one); the alternatives just never reach them
intact.

GNU: quote_string_for_globbing (pathexp.c:246-272) rewrites every
CTLESC-quoted glob char as a backslash escape, and every pattern
scanner checks the escape first (PATSCAN lib/glob/sm_loop.c:697-700;
GMATCH escape arm sm_loop.c:121 before the bracket arm at :327).

11 test functions, script-file harness as in the issue3050 pin:
RED cells for the group-end face, the alternative-split face, all
five group operators and the [[ == ]] face; LOCK cells for the
shapes #3098 fixed and for the accidentally-rescued shapes.
Expectations verified byte-for-byte against GNU bash 5.3.20.
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3190 第1轮 — 建议:PASS
head: 0679342 base(merge-base): a432632 文件: 1 个 +235/-0(纯测试)
关联 issue: #3189(open,核于 2026-11-15;修复未落地,本 PR 为先钉后修)

机制核查:

  • 钉的根因描述与 GNU 侧一致:case 模式经 quote_string_for_globbing(execute_cmd.c:3724)→ convert_to_backslash(pathexp.c:246-272)把 CTLESC 引用的 glob 字符改写为反斜杠转义,GNU 各模式扫描器先判转义(lib/glob/sm_loop.c:697-700 PATSCAN、:121 GMATCH)。rubash 的 extglob_group_end 缺 CTLESC arm、extglob_split_alternatives 无 escape arm —— 锚点抽查与 third_party/bash 相符。
  • diff 无可疑/无关改动(单个新测试文件)。钉标注 RED/LOCK 格清楚,含对「MATCH12 历史记录异常」的诚实说明。

腿:

  • 钉自跑(head,Windows 本机可跑):11 tests → 4 passed / 7 failed。红名 = {extglob_quoted_bracket_never_matches, extglob_quoted_bracket_group_positions, extglob_quoted_bracket_all_operators, extglob_quoted_paren_group_end, extglob_quoted_bracket_conditional_face, extglob_quoted_pipe_is_one_literal, extglob_escaped_paren_alternative_split};绿名 = {rescued_shapes_stay_green, metachars_fixed_by_3098_stay_green, bracket_class_controls, negative_controls}。红/绿分布与文件注释的 RED/LOCK 标注逐格一致——缺陷格全红、锁格全绿,无废钉、无假绿。
  • fail-first:diff 为 tests-only,head 即 base src(merge-base a432632)→ 上面的 7 红即 base 红,每格失败方向与 GNU 分歧一致(base 一律 NOMATCH,GNU MATCH)。
  • GNU 对照(WSL bash 5.3.20(1)-release,脚本 target/probe-pr3190/gnu.sh):全部 37 个格逐字节复跑,与钉断言完全一致,包括 !() 否定格(N1 MATCH/N2 NOMATCH)、负对照(D13/D14 NOMATCH)、获救形状锁格。
  • lib 双边:tests-only,lib 未动。
  • -D warnings:lib 零改动;测试文件编译干净(cargo test 构建无警告)。
  • 卫生:rustfmt --check rc=0。
  • CI(run 42544762029/43):全绿。注意 CI「Rust tests」job 只跑 lib tests,本 stem 未被 CI 执行——其红要靠修复 PR 落地后常规集成跑确认。
  • 修复未落地:[bug] extglob quoted literal '[' never matches: case 'a[b' in @("a[b")) should match (#3050 family residual) #3189 open,钉在 head/master 均红 = 先钉后修预期形态,钉已就位、等修复。

F 点:无。

未跑/VOID 的腿:无(本 stem Windows 可跑,全部腿已跑)。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 15, 2026 02:05
@caomengxuan666
caomengxuan666 merged commit 31238bc into master Nov 15, 2026
11 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-FIX】P1b 批次汇总(2026-11-15)

issue 结果 PR squash 钉 CI 红
#3189 已修复并关闭 #3682 fc1b848 issue3189_extglob_quoted_bracket_literal 11/11(37 cells) 仅 issue2875 签名(=master 基线)
#2709 已修复并关闭 #3693 b85db89 issue2709_globstar_empty_component_regressions 3/3 仅 issue2875 签名
#2664 复核留置(6/6 全绿,缺陷持续缺席,未关闭) — — issue2664_extglob_slash_bracket_regressions 6/6(#3189 合并后复跑仍绿) —

要点:

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