Repository navigation
Conversation
shiloong
force-pushed
the
fix/grep-fallback-pattern
branch
from
June 9, 2026 08:19
514ea7d to
09157e9
Compare
When rtk grep falls back from rg to grep (when rg is unavailable), the fallback uses the original BRE pattern and lacks -E (extended regex) support. This causes patterns with alternation (e.g. 'fn foo\|pub.*bar') to fail silently: - User passes BRE pattern 'fn foo\|pub.*bar' to rtk grep - rtk converts to PCRE 'fn foo|pub.*bar' for rg - When rg is unavailable, grep receives original BRE pattern without -E - grep interprets | as literal pipe, returning zero matches - Result: misleading AI agents into thinking the pattern was not found Fix: - Use PCRE-converted pattern (rg_pattern) instead of original BRE pattern - Add -E (extended regex) flag to grep invocation Signed-off-by: Shile Zhang <[email protected]>
shiloong
force-pushed
the
fix/grep-fallback-pattern
branch
from
June 11, 2026 02:11
09157e9 to
e1db7cc
Compare
Collaborator
|
Thanks for digging into this. The BRE to PCRE conversion this fixes no longer exists on develop: PR #2641 (merged 2026-06-26) stopped substituting one engine for the other, so |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When rtk grep falls back from rg to grep (when rg is unavailable), the fallback uses the original BRE pattern and lacks the
-E(extended regex) flag. This causes patterns with BRE-to-PCRE conversion to fail silently:fn foo\|pub.*bartortk grepfn foo|pub.*barfor rgfn foo|pub.*bar(PCRE) but without-E, grep treats|as a literal pipe characterFix
rg_pattern) instead of the original BRE pattern in the grep fallback-E(extended regex) flag to the grep invocation so|alternation is interpreted correctlyBefore
After