Skip to content

fix(rg): avoid false --generate detection in value arguments#1748

Merged
chaliy merged 1 commit into
mainfrom
2026-05-25-fix-rg-generate-command-handling
May 25, 2026
Merged

fix(rg): avoid false --generate detection in value arguments#1748
chaliy merged 1 commit into
mainfrom
2026-05-25-fix-rg-generate-command-handling

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 25, 2026

Motivation

  • The rg builtin pre-scan rg_generate_kind looked for --generate by scanning raw argv, causing --generate=... inside values (e.g. after -e/--regexp) to be misinterpreted as generation mode instead of search data.
  • This produced incompatible behavior vs upstream rg where value-taking flags consume the following token.

Description

  • Add rg_option_takes_value(arg: &str) -> bool to enumerate flags that take a value and must consume the next token.
  • Update rg_generate_kind to skip tokens consumed by value-taking flags by advancing the index, so --generate=... inside such values is not treated as a generation request.
  • Add a regression test test_rg_generate_not_detected_inside_value_args that verifies both -e and --regexp treat --generate=complete-bash as a pattern value and perform a normal search.
  • Small test-data fix to use .as_slice() for the binary fixture used by the new test.

Testing

  • Ran cargo test -p bashkit test_rg_generate_not_detected_inside_value_args and the test passed.
  • Ran cargo test -p bashkit test_rg_generate_errors and the test passed.
  • Ran focused crate tests while iterating; the two targeted tests above were validated green.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 25, 2026

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 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.
@chaliy chaliy force-pushed the 2026-05-25-fix-rg-generate-command-handling branch from e20f475 to e96dd8b Compare May 25, 2026 15:06
@chaliy chaliy merged commit e63706a into main May 25, 2026
33 checks passed
@chaliy chaliy deleted the 2026-05-25-fix-rg-generate-command-handling branch May 25, 2026 15:29
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.

1 participant