Repository navigation
fix(glob): extglob quoted literals match via the CTLESC arm (Refs #3050) - #3098
Merged
Merged
Conversation
Regression pins for rubash#3050: quoted metacharacters inside an extglob group must match literally (GNU lib/glob/sm_loop.c:121-135, backslash escape removes special meaning; execute_cmd.c:3695-3729, quote_string_for_globbing with QGLOB_CTLESC). Fail-first on base 4295c85: 0 passed / 5 failed.
extglob_match_literal_with_case lacked the CTLESC escape arm the
ordinary matcher (case_pattern_atom_matches, same file) already has,
so a CTLESC-protected literal metacharacter inside an extglob group
fell into the catch-all and was compared as a literal CTLESC
character: @("a*b") never matched 'a*b'.
GNU anchors: execute_cmd.c:3695-3729 (quote_string_for_globbing with
QGLOB_CTLESC; strmatch must recognize backslash escapes) and
lib/glob/sm_loop.c:121-135 (GMATCH case L('\\'): backslash escape
removes special meaning). CTLESC is this port's spelling of that
escape; the arm added here is isomorphic to the ordinary matcher's
(trailing CTLESC falls through to the catch-all, as there).
The [[ == ]] pin cell is dropped from this PR: a quoted RHS routes
through quoted_conditional_pattern_status (conditional.rs) into
case_pattern_matches, never reaching the extglob matcher at all — a
separate routing gap in a collision-listed file, filed as #3100
(gated on the #3025 lane landing).
caomengxuan666
marked this pull request as ready for review
November 9, 2026 00:55
caomengxuan666
added a commit
that referenced
this pull request
Nov 9, 2026
test: wave-2 pins W2d (Refs #3066, #3084, #3097) 第二波「钉先行」车道 W2d 的回归钉(基底 master `f17644d7`)。三单的修法面均被在飞 PR #2968 的文件表占住(declare/assign.rs、compound_exec.rs、temporary_assignments.rs),本 PR 只落钉 + 根因/修法设计(见车道 REPORT),门开后修法车道按钉施工。 Refs #3066 — declare 通道 locale 漏斗触发次数:`declare -a`/`declare -A` 转换既有标量、复合绑定、`local` 复合绑定在 GNU 均双响(declare.def:1105 的 per-variable hack),rubash 只响一次。钉文件 `tests/issue3066_declare_conversion_locale_funnel.rs`(含 fresh/有效值/标量 declare 对照与链路读回)。 Refs #3084 — DQ 反斜杠 case 主词:`case "${v=a\ b}"` 主词在 GNU 保留反斜杠(nomatch),rubash 丢失(match)。钉文件 `tests/issue3084_case_word_dq_backslash.rs`。 Refs #3097 — locale 漏斗三残余:元素赋值与 for/标量覆数组绑定不喂漏斗(存储臂早退跳过 note);declare 通道漏斗投影判据(attr_of)与标量读路径(标记集)不同源,警告命名原始存储形。钉文件 `tests/issue3097_locale_funnel_array_channels.rs`(含 #3080 移出的 3 格原文断言)。 队长复核:A0 纯钉审计、C 腿 GNU 5.3.20 抽查(20 探针全吻合)、D 卫生(rustfmt/marker-lint 均净)、E CI 10 success + 1 skipped 均已落;B 腿 fail-first 实测:基底 5 绿/17 红(#3066 2 绿/6 红、#3084 3 绿/3 红、#3097 0 绿/8 红),头树逐 fn 完全相同(详见复核记录)。 ## 本 PR 删除了什么 无(纯测试新增)。净行数:+720 行(3 个新钉文件:`tests/issue3066_declare_conversion_locale_funnel.rs` +263、`tests/issue3084_case_word_dq_backslash.rs` +150、`tests/issue3097_locale_funnel_array_channels.rs` +307;删除 0 行)。 注意:master 已推进到 `a432632d`(#3098 合入),合入前须 update-branch。
caomengxuan666
added a commit
that referenced
this pull request
Nov 15, 2026
…3190) 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. Co-authored-by: 曹梦轩 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
根因
extglob 组内引号段字面必 NOMATCH:
extglob_match_literal_with_case(src/executor/conditional/pattern.rs)没有 CTLESC 逃逸臂,经 escaper 产出的 CTLESC 保护形落入 catch-all,被当作字面 CTLESC 字符比对。普通匹配器case_pattern_atom_matches(同文件)已有该臂;extglob 字面匹配器缺失。GNU 锚点
execute_cmd.c:3695-3729(execute_case_command):case pattern 先expand_word_leave_quoted,再经quote_string_for_globbing(..., QGLOB_CVTNULL|QGLOB_CTLESC),CTLESC 保护字符转为反斜杠逃逸;注释明言 "the strmatch() call must be able to recognize backslashes as escape characters"。lib/glob/sm_loop.c:121-135(GMATCHcase L('\\')):"backslash escape removes special meaning"——逃逸字符按字面匹配。修复
仅
src/executor/conditional/pattern.rs:extglob_match_literal_with_case增加CTLESC臂(p + 1 < len时按字面匹配pattern[p + 1]、前进两格;尾 CTLESC 落入原 catch-all 字面比对,与case_pattern_atom_matches同构)。本 PR 删除了什么
无删除:纯加法修复(一个 match 臂)+ 回归钉
tests/issue3050_extglob_quoted_literal_regressions.rs(4 格)。无公开面变动,无死代码清理。验证
4295c853上 fail-first(5 格钉 0/5;[[ ]]格另见残余);修复后 4/4 全绿。UNVERIFIED-BY-CAPTAIN残余(已另立单)
[[ == ]]带引号 RHS 的 extglob 组走不到 extglob 匹配器(quoted_conditional_pattern_status的 quoted-RHS 臂一律走case_pattern_matches)。conditional.rs正由 [bug] [[ -t a && -z b ]] returns 1, GNU returns 2 #3025 在飞车道改动,本 PR 不碰;待 [bug] [[ -t a && -z b ]] returns 1, GNU returns 2 #3025 合入后派修。Refs #3050