Repository navigation
fix(rg): honor -- delimiter when checking help/version flags - #1960
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes rg (and the shared builtin help/version shortcut) to correctly honor the -- option delimiter, ensuring that tokens after -- are treated as positional arguments rather than triggering early help/version behavior—matching real ripgrep semantics (e.g., rg -- --help searches for the literal --help).
Changes:
- Update the shared
check_help_versionhelper to stop scanning once--is encountered. - Add an
rg_arg_before_delimiterhelper and use it sorg’s early-h,-V, and--pcre2-versionshortcuts only apply before--. - Add/extend tests to assert that dash-prefixed tokens after
--are treated as patterns/paths rather than flags.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/bashkit/src/builtins/rg/mod.rs | Restricts early help/version/pcre2-version shortcuts to arguments before -- and expands differential tests for delimiter behavior. |
| crates/bashkit/src/builtins/mod.rs | Stops shared help/version scanning at the -- delimiter and adds a unit test for the new behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 0b0525b | Commit Preview URL | Jun 05 2026, 08:31 PM |
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
--option delimiter must be treated as positional values and not consumed as help/version flags by early shortcut checks inrg.rgwhererg -- --helpsearches for the literal string--helprather than printing help.Description
check_help_versionscanning when--is seen by adding a"--" => breakcase incheck_help_versionincrates/bashkit/src/builtins/mod.rs.rg_arg_before_delimiter(args, needle)incrates/bashkit/src/builtins/rg/mod.rsthat searches only up to the--delimiter and use it to replacectx.args.iter().any(...)checks for-h,-V, and--pcre2-versionso those shortcuts are only honored if they appear before--.check_help_version_stops_at_option_delimiterand extend thergdifferential test matrix with cases that assert dash-prefixed tokens (-h,-V,--help,--version,--pcre2-version) after--are treated as positional patterns/paths.Testing
cargo fmt --check(succeeded).cargo test -p bashkit check_help_version_stops_at_option_delimiter(unit test passed).cargo test -p bashkit builtins::rg::tests::diff_rg_matches_real_rg_cases(rg differential tests executed and passed).Codex Task