Repository navigation
fix(grep): strip ripgrep-only flags when falling back to system grep - #2224
mikeangstadt wants to merge 1 commit into
Conversation
When ripgrep is not on $PATH, rtk grep falls back to system grep but was passing ripgrep-specific flags like -g/--glob, --hidden, --pcre2, --json, etc. that grep does not understand, causing silent failures or wrong results. Adds a stateful filter that removes rg-only flags (and their value arguments) from the extra_args before passing them to grep. Closes rtk-ai#2167
|
This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet. |
|
Thanks for the detailed flag table. This was overtaken twice: #2550 (merged 2026-06-23) folded rg-only flag stripping into its own fallback handling, and #2641 (merged 2026-06-26) then removed the fallback altogether by making |
Summary
When ripgrep is not on
$PATH,rtk grepfalls back to systemgrepbut was passing ripgrep-specific flags (e.g.-g/--glob,--hidden,--pcre2,--json,--sort) directly togrep, which does not understand them. This causes silent failures or wrong results (e.g.grep: invalid option -- g).Changes
RG_ONLY_FLAGSconstant table of ripgrep-only flags with their value-taking semanticsfilter_rg_flags()that strips rg-only flags (and their value arguments) fromextra_argsbefore passing to the grep fallback--json) and value-taking flags (-g *.ts,--glob=*.ts).or_else(|_| ...)fallback is changedTesting
extra_args = ["-g", "*.rs", "-i"]->["-i"](skips-gand its value*.rs)extra_args = ["--glob=*.rs", "-i"]->["-i"](embedded value skipped)extra_args = ["--json", "--stats", "-i"]->["-i"]extra_args = ["--hidden", "--no-ignore", "-n"]->["-n"]Closes #2167
Collaborated & orchestrated by ClosedLoop.AI | GitHub