Skip to content

[bug] extglob patterns not compiled in ${var/pat/repl}: ${v/@(abc)/X} leaves value unchanged (GNU substitutes) #349

Closed

Description

@caomengxuan666

Found by gnusweep3 lane (cat7 g019/g038; WSL GNU Bash 5.3.0 oracle, worktree 0fe8d0f).

Repro:

shopt -s extglob
v=abcabc
echo "${v/@(abc)/X}"    # GNU: Xabc    rubash: abcabc
echo "${v//@(abc)/X}"   # GNU: XX      rubash: abcabc
echo "${v/!(a)/Z}"      # GNU: Z       rubash: abc

rubash treats the extglob operator sequence as literal text in the pattern position of the parameter-expansion substitution operators (#/#/%%///%), so no substitution happens. Extglob in ${v#pat} stripping DOES work (g016-g018 PASS).

GNU C owner: subst.c match_pattern() (subst.c:298) — the compiled-pattern path used by parameter_brace_expand's patsub branch; extglob operators are honored because the pattern is compiled with the extended_glob state (subst.c:5495 if (extended_glob) in the matching helpers).
Artifacts: target/issue-suites/results/gnusweep3/cat7/case/g019.* / g038.; minimal target/issue-suites/results/gnusweep3/probes/min/m15-extglob-param.

Activity

  1. added
    bug
    gnu-baseline
    on Sep 30, 2026
  2. added a commit that references this issue on Sep 30, 2026
  3. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt20/deepsweep (86294c0c): patsub literal-path admission missed @( !( + ( shapes (pat_subst routes ALL patterns through match_upattern, subst.c:9238).

  4. added a commit that references this issue on Oct 31, 2026
  5. caomengxuan666 commented on Oct 31, 2026

    @caomengxuan666
    MemberAuthor

    Progress landed: PR #2372 (merged 8ec98aa) — executor trap-liveness hot paths migrated to the allocation-free probes. Verified on the ported-to-master tree: lib 991/0 (baseline-equal), regression no new reds; interleaved A/B (Linux, this VM, twin tree): function/loop shapes CPU -2..-11%, DEBUG-trap pipe_probe wall -61.5%, outputs sha-identical across 10 shapes. The wider #349 baseline gap stays open.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions