Skip to content

Comments

fix(bash): BASH_REMATCH not populated when regex starts with parens#242

Merged
chaliy merged 1 commit intomainfrom
claude/bashkit-bash-compatibility-BsDKD
Feb 24, 2026
Merged

fix(bash): BASH_REMATCH not populated when regex starts with parens#242
chaliy merged 1 commit intomainfrom
claude/bashkit-bash-compatibility-BsDKD

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 24, 2026

Summary

  • Fix parser's parse_conditional to check saw_regex_op flag when encountering LeftParen token inside [[ ]]
  • Regex patterns starting with capture groups (e.g. ([0-9]+)) were incorrectly parsed as grouping parens instead of regex content
  • Adds 6 test cases covering basic match, multiple groups, nested groups, no-match clearing, and conditional usage

Test plan

  • All 6 new regex test cases pass
  • cargo test --all-features passes
  • bash_comparison_tests pass (validated against real bash)
  • cargo clippy and cargo fmt clean

Parser's `parse_conditional` didn't check `saw_regex_op` flag when
encountering LeftParen token, so regex patterns starting with capture
groups like `([0-9]+)` were parsed as grouping parens instead of being
collected as part of the regex pattern.

Adds 6 tests covering basic match, multiple groups, nested groups,
no-match clearing, and conditional usage.

https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
@chaliy chaliy merged commit 03941b5 into main Feb 24, 2026
16 checks passed
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