Skip to content

fix: parse repeated -e/--regexp/--file in zstdgrep - #4770

Open
vulragrag-star wants to merge 1 commit into
facebook:devfrom
vulragrag-star:fix/zstdgrep-regexp-options
Open

fix: parse repeated -e/--regexp/--file in zstdgrep#4770
vulragrag-star wants to merge 1 commit into
facebook:devfrom
vulragrag-star:fix/zstdgrep-regexp-options

Conversation

@vulragrag-star

Copy link
Copy Markdown

Summary

zstdgrep stopped after the first -e, and did not consume --regexp / --file (with or without =), so later pattern options were treated as files. Pattern-bearing options now accumulate into grep_args and may repeat; once any are seen, no positional pattern is stolen.

This is a small original evolution of the existing BSD zstdgrep script. It is not a reintroduction of the gzip-zgrep-derived rewrite that was reverted over licensing (#2095 / #2135).

Fixes #2064

Test plan

  • tests/cli-tests/cltools/zstdgrep-regexp.sh (multi -e, --regexp=, separate --regexp, mixed forms, uncompressed path)
  • Existing cltools/zstdgrep.sh still passes

Notes

AI assistance was used to help draft the option-loop change; I reviewed the logic against #2064 and kept the Klausner BSD structure.

Signed-off-by: Jason Wang vulragrag@gmail.com

Stop breaking after the first -e, and consume --regexp/--file
(with and without '=') so later pattern options are not treated
as files. Patterns live in grep_args; no positional pattern is
stolen once any pattern option is seen.

This is a small original evolution of the existing BSD zstdgrep
script, not a reintroduction of the reverted gzip-zgrep-derived
rewrite. See facebook#2064.

Signed-off-by: Jason Wang <vulragrag@gmail.com>
@meta-cla

meta-cla Bot commented Sep 8, 2026

Copy link
Copy Markdown

Hi @vulragrag-star!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Sep 9, 2026
@meta-cla

meta-cla Bot commented Sep 9, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

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.

zstdgrep parsing of grep options naively broken

1 participant