Bug 238380

Summary: zgrep: Allow multiple options '-e'
Product: Base System Reporter: Ganael LAPLANCHE <martymac>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Not Accepted    
Severity: Affects Many People CC: markj
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch none

Description Ganael LAPLANCHE freebsd_committer 2019-06-07 10:15:07 UTC
Created attachment 204872 [details]
Patch

Currently, zgrep only allows a single option -e to be processed :

$ echo -e 'foo\nbar\nbaz' > test.txt
$ gzip test.txt

$ zgrep -e foo -e bar test.txt.gz
zcat: can't stat: -e: No such file or directory
zcat: can't stat: bar: No such file or directory
test.txt.gz:foo

The attached patch allows to pass several options -e as one would do with standard grep(1) command.
Comment 1 Ganael LAPLANCHE freebsd_committer 2020-02-06 16:53:41 UTC
Hello,

Any volunteer to review that PR ?

Thanks :)
Comment 2 Mark Johnston freebsd_committer 2020-02-06 16:57:25 UTC
(In reply to Ganael LAPLANCHE from comment #1)
Could you please create a phabricator review and tag me?
Comment 3 Ganael LAPLANCHE freebsd_committer 2020-02-06 22:18:29 UTC
Hello Mark,

Here is the link to the review :

https://reviews.freebsd.org/D23549

Thanks a lot!

Ganael.
Comment 4 Ganael LAPLANCHE freebsd_committer 2020-03-12 12:16:04 UTC
Well, as discussed in the review, the suggested patch does not handle spaces in file names. It will probably be tricky to work around that problem in shell without using the eval statement, which would introduce security problems.

So I'll close that PR for now, as it would probably be better to re-implement the zgrep wrapper in a language more suited for arguments' manipulation.