Skip to content

syntax: keep literal parens in extglob arms - #802

Merged
ewhauser merged 1 commit into
mainfrom
ewhauser/extglob-literal-parens
Mar 30, 2026
Merged

ewhauser merged 1 commit into
mainfrom
ewhauser/extglob-literal-parens

Conversation

@ewhauser

Copy link
Copy Markdown
Owner

Summary

  • keep literal parenthesized text inside extglob arms instead of materializing it as a bare PatternGroup
  • skip balanced literal parens while splitting extglob arms so @(x|(a|b)) stays a two-arm extglob
  • ignore bare ( inside extglobs when tracking invalid pattern-group syntax, and add regressions for word, [[ ... ]], and case forms

Root cause

The grouped-alternation parser and raw-pattern scanners started treating any bare ( as pattern-group syntax. That is correct for top-level grouped alternation, but incorrect inside extglob arms, where plain parentheses are literal unless introduced by an extglob operator.

Impact

Bash-style patterns such as @(x|(a|b)) parse again in normal words, [[ ... ]] conditional patterns, and case items, without weakening the existing rejection of real bare pattern groups outside extglobs.

Validation

  • go test ./shell/syntax/... -count=1
  • make lint

@ewhauser
ewhauser merged commit 09b0e63 into main Mar 30, 2026
16 checks passed
@ewhauser
ewhauser deleted the ewhauser/extglob-literal-parens branch March 30, 2026 15:48
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