Skip to content

fix(rg): honor -- delimiter when checking help/version flags - #1960

Merged
chaliy merged 1 commit into
mainfrom
2026-06-05-fix-rg-delimiter-help/version-flag-issue
Jun 5, 2026
Merged

chaliy merged 1 commit into
mainfrom
2026-06-05-fix-rg-delimiter-help/version-flag-issue

Conversation

@chaliy

@chaliy chaliy commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Fix correctness: arguments after the -- option delimiter must be treated as positional values and not consumed as help/version flags by early shortcut checks in rg.
  • Ensure parity with real rg where rg -- --help searches for the literal string --help rather than printing help.

Description

  • Stop shared check_help_version scanning when -- is seen by adding a "--" => break case in check_help_version in crates/bashkit/src/builtins/mod.rs.
  • Add a helper rg_arg_before_delimiter(args, needle) in crates/bashkit/src/builtins/rg/mod.rs that searches only up to the -- delimiter and use it to replace ctx.args.iter().any(...) checks for -h, -V, and --pcre2-version so those shortcuts are only honored if they appear before --.
  • Add unit test check_help_version_stops_at_option_delimiter and extend the rg differential test matrix with cases that assert dash-prefixed tokens (-h, -V, --help, --version, --pcre2-version) after -- are treated as positional patterns/paths.

Testing

  • Ran cargo fmt --check (succeeded).
  • Ran cargo test -p bashkit check_help_version_stops_at_option_delimiter (unit test passed).
  • Ran cargo test -p bashkit builtins::rg::tests::diff_rg_matches_real_rg_cases (rg differential tests executed and passed).

Codex Task

Copilot AI review requested due to automatic review settings June 5, 2026 19:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_version helper to stop scanning once -- is encountered.
  • Add an rg_arg_before_delimiter helper and use it so rg’s early -h, -V, and --pcre2-version shortcuts 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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 5, 2026 •

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 0b0525b Commit Preview URL Jun 05 2026, 08:31 PM

@chaliy
chaliy merged commit a01aa70 into main Jun 5, 2026
36 checks passed
@chaliy
chaliy deleted the 2026-06-05-fix-rg-delimiter-help/version-flag-issue branch June 5, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants