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

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

grep 2.4.2 misunderstanding/feature/bug/inconsistency ???


From: John Refling
Subject: grep 2.4.2 misunderstanding/feature/bug/inconsistency ???
Date: Thu, 12 Oct 2000 16:48:46 -0700

I have noticed an inconsistency in gnu fgrep (also egrep, and grep).
According to the man page,

   the -f option, when used with an empty file "contains zero patterns
   therefore matches nothing"

When I use the -f option, I get what I expect, nothing.   But when I
use the -x and the -f together, I get ALL the lines in the file, not
what I would expect.  One would expect that the results with the -x
option could NOT be greater than without it, since it is more restrictive.
At least that is my logic.  I have asked other people and they agree
the gnu fgrep behaviour is strange.

Note that this is opposite of what Irix and Solaris do (not that those
O/Ss are particularly great, just a reference point).

I don't think the behaviour with the -x switch is consistent, especially
in the limit, since as the number of patterns in the -f file shrinks, the
output shrinks, but when the pattern file shrinks from one pattern to zero
(empty) then the output suddenly INCREASES to the maximum (all the input
lines).

Is this a bug, or am I misinterpreting the man page?






on Linux:
~~~~~~~~~

> ./fgrep --version
fgrep (GNU grep) 2.4.2

Copyright 1988, 1992-1999, 2000 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

>
> rm -f empty_file
> touch empty_file
> cat empty_file
> cat two_line_file
this is a file
with two lines.
>
> ./fgrep    -f empty_file two_line_file
>
> ./fgrep -x -f empty_file two_line_file
this is a file                                   <----+
with two lines.                                  <----|
>                                                     |
>                                                     |
> logout                                              +--- seems inconsistent
                                                      |
                                                      |
                                                      |
On Irix:                                              |
~~~~~~~~                                              |
                                                      |
>                                                     |
> which fgrep                                         |
/bin/fgrep                                            |
>                                                     |
> rm -f empty_file                                    |
> touch empty_file                                    |
> cat empty_file                                      |
> cat two_line_file                                   |
this is a file                                        |
with two lines.                                       |
>                                                     |
>                                                     |
> fgrep    -f empty_file two_line_file                |
>                                                     |
>                                                     |
> fgrep -x -f empty_file two_line_file                |
>                                                <----|
> 



reply via email to

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