Skip to content

feat(rg): support escaped glob metacharacters - #1705

Merged
chaliy merged 1 commit into
mainfrom
2026-05-22-rg-batch-26
May 23, 2026
Merged

chaliy merged 1 commit into
mainfrom
2026-05-22-rg-batch-26

Conversation

@chaliy

@chaliy chaliy commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

What

Add rg glob parsing support for backslash-escaped glob metacharacters, including escaped star, question mark, bracket classes, and brace alternation syntax.

Why

Real ripgrep treats backslash in glob patterns as quoting the next glob character. Bashkit rg previously interpreted escaped metacharacters as active glob syntax, so patterns like -g '\*.txt' did not match literal filenames the way real rg does.

How

Teach the shared rg glob-to-regex translator to emit the next character literally after \\, and preserve escapes while parsing brace alternatives so escaped commas/braces do not affect alternation parsing. Add real-rg differential cases for escaped glob metacharacters.

Risk

  • Low
  • Affects rg glob matching, type globs, and ignore glob translation through the shared converter. This should improve parity, but backslash-heavy patterns are the behavioral surface.

Checklist

  • Tests added or updated
  • Backward compatibility considered

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 674a03b Commit Preview URL May 23 2026, 03:33 AM

@chaliy
chaliy merged commit 09d2991 into main May 23, 2026
34 checks passed
@chaliy
chaliy deleted the 2026-05-22-rg-batch-26 branch May 23, 2026 03:46
chaliy added a commit that referenced this pull request May 30, 2026
## What
Add rg glob parsing support for backslash-escaped glob metacharacters,
including escaped star, question mark, bracket classes, and brace
alternation syntax.

## Why
Real ripgrep treats backslash in glob patterns as quoting the next glob
character. Bashkit rg previously interpreted escaped metacharacters as
active glob syntax, so patterns like `-g '\*.txt'` did not match literal
filenames the way real rg does.

## How
Teach the shared rg glob-to-regex translator to emit the next character
literally after `\\`, and preserve escapes while parsing brace
alternatives so escaped commas/braces do not affect alternation parsing.
Add real-rg differential cases for escaped glob metacharacters.

## Risk
- Low
- Affects rg glob matching, type globs, and ignore glob translation
through the shared converter. This should improve parity, but
backslash-heavy patterns are the behavioral surface.

## Checklist
- [x] Tests added or updated
- [x] Backward compatibility considered
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