fix(rg): avoid false --generate detection in value arguments#1748
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | e96dd8b | Commit Preview URL | May 25 2026, 04:30 PM |
Pre-scan rg_generate_kind looked for --generate by scanning raw argv, so --generate=... inside values (e.g. after -e/--regexp) was misinterpreted as generation mode instead of search data. Add rg_option_takes_value enumerating value-taking flags. Skip the following token when one is encountered so values cannot trigger generation. Test covers both -e and --regexp. Rebased on top of recent rg merges; original PR #1748 by chaliy.
e20f475 to
e96dd8b
Compare
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.
Motivation
rgbuiltin pre-scanrg_generate_kindlooked for--generateby scanning raw argv, causing--generate=...inside values (e.g. after-e/--regexp) to be misinterpreted as generation mode instead of search data.rgwhere value-taking flags consume the following token.Description
rg_option_takes_value(arg: &str) -> boolto enumerate flags that take a value and must consume the next token.rg_generate_kindto skip tokens consumed by value-taking flags by advancing the index, so--generate=...inside such values is not treated as a generation request.test_rg_generate_not_detected_inside_value_argsthat verifies both-eand--regexptreat--generate=complete-bashas a pattern value and perform a normal search..as_slice()for the binary fixture used by the new test.Testing
cargo test -p bashkit test_rg_generate_not_detected_inside_value_argsand the test passed.cargo test -p bashkit test_rg_generate_errorsand the test passed.Codex Task