bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep bug


From: Andy Goth
Subject: grep bug
Date: Sat, 2 Jun 2001 20:00:04 -0500

First, the version.

$ grep --version
grep (GNU grep) 2.4.2
$

Initially, I have two files, strings and list.

$ cat strings
$ cat list
a
b
c
d
$

Now, I want to do some simple whole-line string matching.

$ grep -xf strings list
a
b
c
d
$

The results of the above command are _very_ wrong.  An empty strings file 
should match nothing.  Without x?

$ grep -f strings list
$

Nothing matches, as expected.

Next, apply -v to reverse the results.  The expected result is that list will 
just be cat'ed, since nothing matches an empty strings file.

$ grep -xvf strings list
$

But, there's no output!

Things work properly with a nonempty strings file:

$ echo a > strings
$ grep -xf strings list
a
$ grep -xvf strings list
b
c
d

So, the bug is that when -f refers to an empty file, the -x option acts like 
a -v.  Of course, things work correctly with a pattern of "" passed on the 
commandline, but GNU grep gets confused when the same is passed via -f.

This is an irritating bug, and it has cost me a lot of time piecing some data 
files back together again from scrollback logs after testing scripts that ran 
into this bug.

-- 
Andy Goth  |  address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]