AW: BUG: grep -v -x -f does not work when pattern file is empty

dietmar.schindler at manroland-web.com dietmar.schindler at manroland-web.com
Thu Apr 5 09:57:17 UTC 2018


> Von: Quentin Rameau
> Gesendet: Donnerstag, 5. April 2018 10:24
>
> Hello Dietmar,
>
> > > The standard specifies, for the -f flag:
> > >
> > > “Patterns in pattern_file shall be terminated by a <newline>. A null
> > > pattern can be specified by an empty line in pattern_file.”
> >
> > The above does not rule an empty pattern_file (i. e. no patterns) out.
> > The actually relevant part from
> > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html
> > is:
> >
> > -f  pattern_file
> > Read one or more patterns from the file named by the pathname
> > pattern_file. …
> >
> > > So calling grep -f with an empty file is non-standard thus not a BUG
> > > per se.
> >
> > True, but because of the wording "one or more patterns".
>
> Well, it's a combination of both. You don't get an empty set of
> patterns without specifying[:] a pattern must be an empty line.

Hello, Quentin,

I beg to differ. Your subclause "a pattern must be an empty line" doesn't make sense, so I take you meant "a null pattern must be an empty line". But "a null pattern" is distinct from "an empty set of patterns"; a set of patterns that consists of one null pattern is not an empty set, but rather a set with cardinality one.

> But this is my mistake for keeping implied that yes, specifying an
> option means it mustn't be empty. ^^

It doesn't mean that as a matter of course. If the "one or more patterns" were omitted from the above, it would read "Read patterns from the file named by the pathname pattern_file." Then, zero patterns (i. e. an empty pattern_file) would be legal, and the sentences you cited would not apply at all, because they refer to patterns, of which there aren't any in an empty file.
--
Regards,
Dietmar
________________________________
manroland web systems GmbH | Managing Director: Alexander Wassermann
Registered Office: Augsburg | Trade Register: AG Augsburg | HRB-No.: 26816 | VAT: DE281389840

Confidentiality note:
This eMail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, you are hereby notified that any use or dissemination of this communication is strictly prohibited. If you have received this eMail in error, then please delete this eMail.
________________________________


More information about the busybox mailing list