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

Quentin Rameau quinq at fifth.space
Thu Apr 5 08:24:19 UTC 2018


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.
But this is my mistake for keeping implied that yes, specifying an
option means it mustn't be empty. ^^

Now to the actual issue, I think this comes from line 746 of
findutils/grep.c, wanting to mimic GNU extensions is not always a good
idea.
I really don't have time to debug it myself atm until Monday, thought
it was worth putting out a direction.

Thanks!


More information about the busybox mailing list