Bug 238380 - zgrep: Allow multiple options '-e'
Summary: zgrep: Allow multiple options '-e'
Status: Closed Not Accepted
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
Keywords: patch
Depends on:
Reported: 2019-06-07 10:15 UTC by Ganael LAPLANCHE
Modified: 2020-03-12 12:16 UTC (History)
1 user (show)

See Also:

Patch (1.26 KB, text/plain)
2019-06-07 10:15 UTC, Ganael LAPLANCHE
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ganael LAPLANCHE freebsd_committer 2019-06-07 10:15:07 UTC
Created attachment 204872 [details]

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

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

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 :


Thanks a lot!

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.