Skip to content

feat(interpreter): implement extglob patterns (@, ?, *, +, !)#273

Merged
chaliy merged 3 commits intomainfrom
claude/bashkit-bash-compatibility-BsDKD
Feb 25, 2026
Merged

feat(interpreter): implement extglob patterns (@, ?, *, +, !)#273
chaliy merged 3 commits intomainfrom
claude/bashkit-bash-compatibility-BsDKD

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Feb 25, 2026

Summary

  • Implements all five extended glob operators gated on shopt -s extglob
  • @(pat|pat) — exactly one alternative
  • ?(pat|pat) — zero or one
  • *(pat|pat) — zero or more (recursive backtracking)
  • +(pat|pat) — one or more (recursive backtracking)
  • !(pat|pat) — anything except the alternatives
  • Lexer updated to consume OP(...) as single word tokens
  • Works in case statements and [[ == ]] conditionals
  • Nested extglob patterns supported via recursive parsing

Test plan

  • 15 new spec tests covering all five operators
  • All 1452 spec tests pass (1447 pass, 5 skip)
  • cargo clippy clean
  • cargo fmt clean
  • Existing glob/case tests still pass

Add extended glob pattern matching gated on shopt -s extglob:
- @(pat|pat) — matches exactly one of the alternatives
- ?(pat|pat) — matches zero or one
- *(pat|pat) — matches zero or more
- +(pat|pat) — matches one or more
- !(pat|pat) — matches anything except the alternatives

Changes:
- Lexer: consume extglob OP(...) as single word tokens
- Interpreter: add extglob matching in glob_match_impl with
  recursive backtracking for *, +, ! operators
- Works in case statements and [[ == ]] conditionals

Adds 15 spec tests.

https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
@chaliy chaliy merged commit 2cb9ba1 into main Feb 25, 2026
16 checks passed
@chaliy chaliy deleted the claude/bashkit-bash-compatibility-BsDKD branch March 12, 2026 03:42
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.

2 participants