fix: parse repeated -e/--regexp/--file in zstdgrep - #4770
Conversation
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>
|
Hi @vulragrag-star! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
zstdgrepstopped 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 intogrep_argsand may repeat; once any are seen, no positional pattern is stolen.This is a small original evolution of the existing BSD
zstdgrepscript. 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)cltools/zstdgrep.shstill passesNotes
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