Skip to content

fix(glob): GLOBIGNORE pathname matching for slash brackets and extglob (Refs #2664) - #3705

Merged
caomengxuan666 merged 2 commits into
masterfrom
ai-fix/rubash-2664
Nov 17, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
ai-fix/rubash-2664

Conversation

@arookieofc-ai

Copy link
Copy Markdown
Contributor

Fixes rubash#2664 (Murase run-glob-bracket suite, GNU bash 5.3.20 oracle; verified against GNU bash 5.2.21 on the test box).

Root cause

GNU matches a GLOBIGNORE pattern against a candidate pathname with ONE strmatch call carrying FNM_PATHNAME (pathexp.c glob_name_is_acceptable). Rubash's port (strmatch_pathname in src/executor/glob.rs) had two divergences:

1. Brackets could never match /. GNU BRACKMATCH (lib/glob sm_loop.c) has no blanket bar: members are scanned in order, returning on the first match, but a member followed by / voids the whole bracket. So ab[/]cd/efg, ab[/a]cd/efg, ab[!a]cd/efg and ab[.-0]cd/efg all exclude ab/cd/efg, while [a/] and [c/d] match nothing (a range matched before the slash, [a-c/], still matches a). Rubash barred [...] from matching / outright, and wrongly let [a/] match a.

2. Extglob patterns bypassed FNM_PATHNAME. GLOBIGNORE extglob patterns were routed through the case-pattern engine, which has no FNM_PATHNAME, so * crossed / and *@(/)cd/efg wrongly ignored ab/cd/efg (suite case #20). All GLOBIGNORE patterns now go through strmatch_pathname, which gained an extglob-aware EXTMATCH port (sm_loop.c: @/?/*/+/! groups, plus the collapse-loop ?(/*( arms) and an exclusive star retry bound (n < endp).

Verification

Known limitation — needs maintainer direction, NOT fixed here

The suite still halts at #22 (rc=127, empty stderr): after the pcheck section it builds the strmatch loadable builtin and calls it. Rubash's loader accepts the .so (RTLD_LAZY, as in GNU) but the host exports no strmatch symbol, so the first call dies on lazy binding. The bracket cases themselves all match GNU (see the wave-2 pins); making the check section runnable would need either failing the load loudly or exporting strmatch — an ABI-surface decision for maintainers.

…b (Refs #2664)

GLOBIGNORE patterns are matched by one strmatch call with FNM_PATHNAME (pathexp.c glob_name_is_acceptable), but rubash had two divergences in its port (strmatch_pathname):

- Brackets could never match /: GNU BRACKMATCH lets a bracket match / unless a member is followed by /, which voids the whole bracket. So ab[/]cd/efg, ab[/a]cd/efg, ab[!a]cd/efg and ab[.-0]cd/efg exclude ab/cd/efg, while [a/] and [c/d] match nothing. Rubash barred [...] from matching / outright and wrongly let [a/] match a.

- Extglob patterns were routed through the case-pattern engine, which has no FNM_PATHNAME, so *@(/)cd/efg wrongly ignored ab/cd/efg (a * must never carry a following group across /). All GLOBIGNORE patterns now go through strmatch_pathname, with an extglob-aware EXTMATCH port (sm_loop.c) and an exclusive star retry bound.

The Murase run-glob-bracket suite now matches GNU on all 21 pcheck lines (was 5 divergent); the suite still halts at #22 because rubash exports no strmatch symbol for the loadable builtin (first call dies with silent exit 127) - a loader/export question for maintainers, not a glob defect.

Tests: new tests/issue2664_glob_extglob_slash_regressions.rs (6 tests; 4 fail on baseline); existing wave-2 pins, lib suite (1249 passed) and the 130-file glob/pattern subset green except 3 pre-existing baseline failures in the 1253 errexit tests.
@caomengxuan666 caomengxuan666 added the bug Something isn't working label Nov 15, 2026
@caomengxuan666 caomengxuan666 self-assigned this Nov 15, 2026
@caomengxuan666 caomengxuan666 added P2-medium 中:次要缺陷或边缘路径,排期修复 area:glob pathname expansion, shopt glob options, collation gnu-baseline Tracked by the GNU Bash 5.3.0 true-baseline ledger labels Nov 15, 2026
@caomengxuan666

Copy link
Copy Markdown
Member

Thank you, @arookieofc-ai — intake note from the community bot (first contact; the captain reviews external PRs first, per the owner's rule — this is a first pass, not a merge review).

Home: Refs #2664, which is OPEN (bug / gnu-baseline / P2-medium) — glob family, 1.5.1 audit programme. Labels applied here to match: bug, P2-medium, area:glob, gnu-baseline; assignee caomengxuan666.

What I checked:

  • Scope: 3 files, +459/−38. The core change is in src/executor/glob.rs: all GLOBIGNORE patterns now go through the FNM_PATHNAME port strmatch_pathname (extglob-aware) and the case-pattern-engine route is removed; the bracket slash rule follows GNU BRACKMATCH (a member followed by / voids the bracket); the star retry bound is now exclusive (n < endp); new helpers for extglob @/?/*/+/! groups. conditional.rs only re-exports two existing helpers. 6 new tests in tests/issue2664_glob_extglob_slash_regressions.rs, driven by real rubash-binary probes with GNU-derived expectations, plus boundary locks (extglob-off literal, plain glob / [[ == ]] unchanged).
  • CI (runs 43736497263 / 43736497213), failed cells named from the logs: Rust tests (Linux + macOS) and goldens fail on exactly one cell — api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell, the known baseline red (also red on the base, not introduced by this PR). The niubash canary fails at the "Ledger covers everything niubash consumes" step, matching the known ledger drift that rubash docs(ledger): record Session::cwd #3704 / niubash [bug] exec N< <(slow-producer) blocks until producer exits (GNU returns immediately) #1021 are addressing. CLI tests, shell functionality tests, cross-target checks and the Windows compile check are green.

Not verified by me — left for captain review: the Murase-suite claim (first 24 lines byte-identical to GNU), a local run of the new tests, and the Windows build (not run on the author's box either).

Open question carried from the PR body: the suite still halts at #22 (rc=127 — the strmatch loadable builtin has no exported symbol). That needs a maintainer decision (fail the load loudly vs. export strmatch) and is not fixed here; flagging it for the captain/owner rather than deciding it in intake.

Queued for captain review with CI watched. No dates promised.

@caomengxuan666

Copy link
Copy Markdown
Member

【WIN-AGENT-AUDIT】PR #3705 第1轮 — 建议:FAIL

head: 3c9e0c5 base(merge-base): e81a1af 文件: 3 个 +459/-38
关联 issue: #2664(状态:closed,2026-11-16T00:02:58Z 由 caomengxuan666 以 completed 关闭,我核过的时间:2026-11-16 本地)。关闭评论写明「the defect was already absent when this issue was filed」,已由 #3160 的钉 tests/issue2664_extglob_slash_bracket_regressions.rs 覆盖;该 6 钉在本 PR head 上仍全绿。

机制核查:

  • extglob 半边与 GNU 一致:GLOBIGNORE 的匹配面是 pathexp.c:546-552 glob_name_is_acceptable() 以 FNM_PATHNAME|FNMATCH_EXTFLAG|FNMATCH_NOCASEGLOB 调一次 strmatch,而 rubash 旧路把 extglob 模式送进无 FNM_PATHNAME 的 case 引擎,* 跨 / —— 本 PR 改为全部走 strmatch_pathname(含 EXTMATCH 端口)修掉了 [Bug 批量] 命令替换状态污染 / heredoc / case 模式 / 参数替换 / 路径转换 / 重定向 / 调试钩子 - 20+ 个与 GNU Bash 的兼容性差异(含最小复现) #20(*@(/)cd/efg 之于 ab/cd/efg),实测与 GNU 一致。
  • bracket 半边与 GNU 相反,是本 PR 的致命点:GNU lib/glob/sm_loop.c:339-341(GMATCH 的 case L('['))在 FNM_PATHNAME 下对 sc == '/' 直接 return FNM_NOMATCH —— bracket 永远不能匹配 /。BRACKMATCH 内部的斜杠否决(sm_loop.c:618-624 的 matched 跳读循环)只是第二层,不是「bracket 可以吃 /」的许可。本 PR 删掉了 rubash 的 blanket bar 并让 [/]/[!a]/[.-0] 一类匹配 /,方向反了(见 F1/F2)。
  • diff 可疑点:src/executor/conditional.rs 仅新增两个 pub(in crate::executor) 再导出,无副作用;其余为 glob.rs 匹配器与一个新钉文件。PR 正文「GNU BRACKMATCH 允许 bracket 匹配 /」的表述与 GNU 源码/运行结果相反。
  • 旁证:vendored third_party/bash/tests/glob-bracket.right 的 Track GNU Bash upstream test progress in CI #2-fix: capture pipeline output in command substitution #6 全部是 no/no(GLOBIGNORE 不忽略),本 PR 的新钉却断言这几格被排除。

腿(逐项给数字与名字):

  • 钉自跑(head 3c9e0c5):
    • issue2664_glob_extglob_slash_regressions 6 passed / 0 failed;
    • 既有钉 issue2664_extglob_slash_bracket_regressions 6 passed / 0 failed(未被本 PR 弄红)。
  • fail-first(base e81a1af,钉文件原样放入):2 passed / 4 failed,红名 = {globignore_bracket_slash_matches_slash, globignore_bracket_slash_veto_matches_nothing, globignore_extglob_alternative_slash, globignore_extglob_star_run_groups}。注意 bracket 两格在 base 上红的原因是 base 保持 GNU 行为(不忽略)而钉期望「忽略」——钉红不代表 base 错(见 F4)。
  • lib 双边:head 失败名集 {api::consumer_tests::issue2084_session_end_restores_host_process_state}(1351 passed / 1 failed)/ base 失败名集 {同一测试}(1351 passed / 1 failed)/ 差集 ∅(该格为并行 env flake,非本 PR 账)。
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --locked --lib --bins → 0 警告。
  • 卫生:rustfmt --check 3 文件全 clean;marker-lint OK (117 registry consts, 268 allowlisted);utf8-boundary clean。
  • CI(head 3c9e0c5, run 43736497263 / 43736497213):红任务 4 个,逐个归因——
    • Rust tests、Rust tests (macOS)、GNU regression goldens and canaries:唯一红格均为 api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell(run 日志 test result: FAILED. 1351 passed; 1 failed / 1245 passed; 1 failed)= 已知基线 issue2875,非本 PR;
    • niubash builds against this tree:check-api-ledger 报 MISSING session-method rubash::api::Session::cwd。不是本 PR 引入(PR 未动 api 面),是 base 时点旧:master 已由 58eeb88c docs(ledger): record Session::cwd (#3704) 记录;master 同工作流最新 run 43856186007 该 job 为 success。归因:stale-base/CI 货币性。
  • GNU 对照(WSL /usr/local/bin/bash 5.3.20(1)-release,脚本文件形态,脚本存 target/audit-s5/p3705/g2.sh、g5.sh;rubash 侧同一脚本跑 target/debug/rubash.exe):

F 点:

续作记录:无(本轮未改代码;FAIL 不合不关)。
未跑/VOID 的腿:无。

@caomengxuan666

Copy link
Copy Markdown
Member

【WIN-AGENT-AUDIT】S5 批次汇总(PR #3705 / #3703 / #3702 / #3701 / #3700 / #3699 / #3696 / #3689 / #3688 / #3685)

本轮为「审计+合并+关单」lane;实际结果:0 合并、0 关单、0 push(每条的阻塞原因见下)。oracle = WSL GNU bash 5.3.20(1)-release,脚本文件形态;master 收尾尖 6089aefd。

PR head 判词 处置
#3705 3c9e0c56 FAIL 不合不关(comment 6915128054)
#3703 431e113b PENDING(内容绿) 不合不关(6915315028)
#3702 a13bc85d PENDING 不合不关(6915439981)
#3701 c699581f FAIL 不合不关(6915707754)
#3700 7d8dcbb5 PENDING 不合不关(6915792579)
#3699 b31ed3b2 FAIL 不合不关(6915973826)
#3696 a7c5f6bf skip 已合并 d3f1ccef
#3689 ec65c242 skip 已合并 1c811bc7
#3688 264f0484 skip 已合并 7a01b9d3
#3685 15be88b6 PENDING(维持) 不合不关(复核 6915989274)

阻塞项:

环境/基线:issue2875 为唯一 CI 基线红;niubash builds against this tree 的 MISSING Session::cwd 是 stale-base(master 已由 #3704/58eeb88c 记录),非各 PR 的账。详见各 PR 报告与 D:/repo/rubash/target/devin-dispatch/final-report-s5.md。

…#2664)

sm_loop.c:341 bars sc == '/' before BRACKMATCH runs, and an unescaped
'/' in member position voids the whole bracket for every test char
(sm_loop.c:450/506/531/575, matched-skip ~:620). The previous revision
let brackets match '/' — the opposite of GNU — and encoded that in
the pin. Restore the caller-side bar, add bracket_body_has_slash for
the member-scan poison ([:class:] spans skipped atomically), and
correct the two bracket pins to the GNU 5.3.20 outputs; the extglob
half is unchanged.
@caomengxuan666

Copy link
Copy Markdown
Member

【WIN-AGENT-AUDIT】
PR #3705 第2轮 — 建议:PASS(extglob 半边修复成立;bracket 半边已按 GNU 源码回退并加 BRACKMATCH 毒化层;issue #2664 已 closed,合并与否由队长按重复面裁量)
head: 22874bf base(merge-base): e81a1af 文件: 3 个(累计 diff 以 PR 为准)
关联 issue: #2664(状态:closed,2026-11-16T00:02:58Z completed;我核过的时间:2026-11-16 本地)。关单理由「缺陷本不存在」对 bracket 面成立、对 extglob #20 格不成立——base 上 *@(/)cd/efg 确实误忽略 ab/cd/efg,本 PR 的 extglob 半边修的是真残差。

机制核查:

腿:

  • 钉自跑:issue2664_glob_extglob_slash_regressions — Windows 6/6、WSL 6/6;既有钉 issue2664_extglob_slash_bracket_regressions(test: wave-2 pins G1 (Refs #2664, #2709) #3160)Windows+WSL 各 6/6 未被弄红。
  • fail-first:merge-base e81a1af + 新钉 — 2 passed / 4 failed,红名 = {globignore_bracket_never_matches_slash, globignore_bracket_with_slash_member_voided, globignore_extglob_alternative_slash, globignore_extglob_star_run_groups}(base 上 extglob 走 case 引擎跨 / + [a-c/] 误配,均红)。
  • lib 双边:head 4fadcb7b(=22874bfa 内容)1249/0/4;base e81a1af 1249/0/4;差集 ∅。
  • -D warnings:本 PR 文件 0 警告(audit 第1轮已核 0;本轮改动同面)。
  • 卫生:rustfmt --check glob.rs + 钉文件 clean;marker-lint OK;utf8 clean。
  • CI(旧 head 3c9e0c5):红 4 项 = {Rust tests, Rust tests (macOS), GNU regression goldens and canaries(均基线 issue2875 单格), niubash builds against this tree(stale-base Session::cwd ledger,master 已由 docs(ledger): record Session::cwd #3704 记录)}——全部归因基线/陈旧 base,非本 PR。新 head 22874bf 的 CI 以新 run 为准。
  • GNU 对照:WSL GNU bash 5.3.20(1)-release,脚本 target/probe2664-gnu.sh(GNU 侧)与 target/probe2664-rubash.sh(rubash 侧)——bracket1 20 行、bracket2 7 行、extglob 11 行、stargroup 5 行,四组输出与 GNU 逐字一致。

F 点:无(F1-F4 已逐条返工;F5 留队长裁量)。

续作记录:

未跑/VOID 的腿:无。

@caomengxuan666
caomengxuan666 merged commit 4c7c2d1 into master Nov 17, 2026
10 of 12 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member

【WIN-AGENT-AUDIT】PR #3705 第3轮 — 建议:PASS(已合并 squash 4c7c2d19c816467c99ae555c05438661d2526053)
head: 22874bfaef8dc85f3059d4091f765fd507aa9519(自 U4 第2轮未变)base(merge-base): e81a1af1c6b56e660cb42a64acb146dbda5e5976
关联 issue: #2664(closed,2026-11-16 completed;extglob 半边为真残差修复,bracket 半边为 GNU 正确毒化层)

V 波收网复核(在 U4 第2轮 PASS 基础上重跑关键腿):

@caomengxuan666

Copy link
Copy Markdown
Member

【WIN-AGENT-AUDIT】V2 批次汇总(PR #3705 / #3626 / #3509 / #3765 / #3766 / #3769)

本轮为「非 draft 收网」lane;实际结果:4 合并、1 维持 FAIL(建议关闭待裁定)、1 PENDING(冲突待定序)。oracle = WSL GNU bash 5.3.20(1)-release(/usr/local/bin/bash),全部探针为脚本文件;本轮独立复跑的 GNU 对照脚本存 D:/repo/rubash-devin-v2/target/v2-audit/。

PR head 判词 处置
#3705 22874bfae PASS 已合并 squash 4c7c2d19;#2664 已 closed(extglob 真残差修复,裁量合入)
#3626 1714d193 FAIL(维持) 不合不关;回归复现属实,建议以 #3627(case_in_stage 准入)为准关闭,待队长裁定
#3509 8248fbe2 PENDING 不合不推;CONFLICTING/DIRTY(pipeline_exec.rs 产品语义冲突,与 #3562 互斥待定序)
#3765 37c5e80a PASS 已合并 squash 44bd7307;#3647 已 closed;「EOF 措辞」F 点核销(5.2/5.3 版本差,非缺陷)
#3766 594ed2c9 PASS 已合并 squash 98d71b8b;#3648 已 closed;兄弟保留字臂残差已另开 #3833 跟踪
#3769 d2b33007 PASS 已合并 squash c5b988bd;正文 Fixes→Refs 已改;#3649 已手工关闭(附验证评论)

要点:

合并复核:四条均 gh pr view --json state,mergeCommit 实测 state=MERGED,oid 如上表(非 headRefOid)。未触碰禁碰清单、未改 src/lexer/continuation.rs、无 force-push、无改写已推送历史。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:glob pathname expansion, shopt glob options, collation bug Something isn't working gnu-baseline Tracked by the GNU Bash 5.3.0 true-baseline ledger P2-medium 中:次要缺陷或边缘路径,排期修复

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants