The attached patch allows to pass several options -e as one would do with standard grep(1) command.
This review comes from the following PR :
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238380
Differential D23549
zgrep: Allow multiple options '-e' martymac on Feb 6 2020, 10:17 PM. Authored by Tags None Referenced Files
Subscribers
Details The attached patch allows to pass several options -e as one would do with standard grep(1) command. This review comes from the following PR :
Diff Detail
Event TimelineComment Actions Could you upload a diff with full context?
Comment Actions Hi Mark, Thanks a lot for your feedback. Good catch! Damn, you are right, my patch does not work when grepping patterns that include whitespaces :/ Using eval would work but is a no go for me as it would handle grep arguments in an insecure way : one would, for example, be able to fork a subshell by passing it as a grep pattern. We could replace spaces in grep patterns with character classes such as :blank: to make the final grep pattern space-free (such as 'foo[[:blank:]]bar') but this is really ugly (and it includes the tab character). After several tries, I could not find a simple, elegant way to work around that problem. Maybe you're right, it would be better to leave the tool as-is and replace it "some day" (TM) by a re-written version, maybe in a language more fit for arguments manipulation ? Comment Actions Close for now as the suggested patch does not handle spaces in file names (see discussion). |