Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

found bug

0 views
Skip to first unread message

Karl Riauba

unread,
Aug 22, 2018, 9:26:27 PM8/22/18
to bug-gn...@gnu.org
Hi,

I think I found egrep bug.
No tabs in example file or in variable.
10.193.132.65:9102 should suppose to be filtered out, but it doesn't.

Thanks

$ echo ===$egrep===
=== 10.193.132.65:9102 | 10.193.132.65:111 | 10.193.132.65:4560 |
10.193.132.65:2800 | 10.193.132.65:4369 | 10.193.132.65:22 |
10.193.132.65:8888 | 10.193.132.65:8088 | 10.193.132.65:8089 |
10.193.132.65:38012 | 10.193.132.65:8126 | 10.193.132.65:5280 |
10.193.132.65:39073 | 10.193.132.65:8834 | 10.193.132.65:2850 |
10.193.132.65:41187 | 10.193.132.65:5285 | 10.193.132.65:9125 |
10.193.132.65:5222 | 10.193.132.65:5287 | 10.193.132.65:5223 |
10.193.132.65:35848 ===
RO...@gamesvc-2-001.dev.qa.las1:~
$ cat egrep_bug
tcp 0 0 0.0.0.0:9102 0.0.0.0:* LISTEN
12160/statsd_export
tcp 0 0 0.0.0.0:9125 0.0.0.0:* LISTEN
12160/statsd_export
tcp 0 0 10.193.132.65:9102 10.196.128.42:46852
ESTABLISHED 12160/statsd_export
udp 0 0 0.0.0.0:9125 0.0.0.0:*
12160/statsd_export
unix 3 [ ] STREAM CONNECTED 47777
12160/statsd_export
RO...@gamesvc-2-001.dev.qa.las1:~
$ cat egrep_bug | egrep -v "$egrep"
tcp 0 0 0.0.0.0:9102 0.0.0.0:* LISTEN
12160/statsd_export
tcp 0 0 0.0.0.0:9125 0.0.0.0:* LISTEN
12160/statsd_export
tcp 0 0 10.193.132.65:9102 10.196.128.42:46852
ESTABLISHED 12160/statsd_export
udp 0 0 0.0.0.0:9125 0.0.0.0:*
12160/statsd_export
unix 3 [ ] STREAM CONNECTED 47777
12160/statsd_export
RO...@gamesvc-2-001.dev.qa.las1:~
$

Eric Blake

unread,
Aug 22, 2018, 9:59:46 PM8/22/18
to Karl Riauba, bug-gn...@gnu.org
On 08/22/2018 06:32 PM, Karl Riauba wrote:
> Hi,
>
> I think I found egrep bug.

Thanks for your report. However, you've reported to an old address;
'grep --help' currently recommends that bug reports be sent to
bug-...@gnu.org, which makes me wonder if the behavior you are seeing
may have changed in the meantime with a newer version of grep.

> No tabs in example file or in variable.

Maybe not, but your mailer line wrapped things, which means I can't
readily reproduce your output by just copying and pasting from your
email. However, I think I've managed to reconstruct the egrep_bug file
that you describe, containing just 5 lines, and your $egrep variable
with no newlines but a bunch of values with one space on either side.

> 10.193.132.65:9102 should suppose to be filtered out, but it doesn't.
>

> $ echo ===$egrep===

It's hard to say if I exactly matched the contents of your $egrep
variable, since you forgot to use shell quoting, so if your variable
contained multiple spaces, word splitting and then echo's argument
pasting collapsed those multiple spaces down to one.

> $ cat egrep_bug | egrep -v "$egrep"

Side comment: Useless use of cat; you could have written:

egrep -v "$egrep" < egrep_bug

for fewer processes.

> tcp 0 0 0.0.0.0:9102 0.0.0.0:* LISTEN
> 12160/statsd_export
> tcp 0 0 0.0.0.0:9125 0.0.0.0:* LISTEN
> 12160/statsd_export
> tcp 0 0 10.193.132.65:9102 10.196.128.42:46852
> ESTABLISHED 12160/statsd_export

When I tried to reproduce your setup, this line was filtered for me,
using grep 3.1. But it was very easy to make this line not be filtered,
by calling:

egrep -v " $egrep" < egrep_bug

since that creates a pattern which requires two leading spaces, when
only one is present in the input. Since you didn't use proper shell
quoting, I can't tell if the bug is in your usage, or if it really was
something broken in whatever version of grep you are using.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org

Bob Proulx

unread,
Sep 10, 2018, 3:55:52 PM9/10/18
to Karl Riauba, bug-gn...@gnu.org
Hello Karl,

Karl Riauba wrote:
> I think I found egrep bug.
> No tabs in example file or in variable.
> 10.193.132.65:9102 should suppose to be filtered out, but it doesn't.

I as well tried to reproduce this bug. I was unable to do so. It
works for me okay using grep 3.1.

What version of grep are you using? You can post this using the
--version option.

grep --version

Eric suspects you must be using a very old version due to the use of
this mailing list for bug submission. If your version is very old
then it may have been a bug in that older version that was fixed in
the intervening years. It would still be interesting to know here
what version of grep you are using.

> $ echo ===$egrep===

At this point the $egrep variable was not quoted. Oops. Therefore
any amount of whitespace error may have been introduced there that
will be invisible to us.
>...

And then the email was word wrapped which is a very annoying feature
of your mailer. Again it makes it difficult to reproduce bugs
exactly. If you can't convince your mailer not to word wrap then
sometimes these files may be attached verbatim and therefore show the
problem without the mailer causing us problems.

> $ cat egrep_bug
> tcp 0 0 0.0.0.0:9102 0.0.0.0:* LISTEN
> 12160/statsd_export

Argh! Again the mailer word wrapping this text drives people trying
to reproduce your report crazy! :-(

> tcp 0 0 0.0.0.0:9125 0.0.0.0:* LISTEN
> 12160/statsd_export
> tcp 0 0 10.193.132.65:9102 10.196.128.42:46852

But here appears to be the main point of your report. The string
10.193.132.65:9102 is in the file and has at least one space both
before and after it. The grep pattern included that same string with
a very likely but unprovable one space both before and after it.
Therefore it should match that line but appears to you to not have
matched it.

However to me reading this report the most likely cause of the problem
is multiple spaces in the pattern before that address and therefore
not matching due to whitespace problems.

My hopefully helpful advice to you is to quote your variables so that
whitespace is not split by the shell. And then double check very
closely the amount of whitespace in the pattern. If your case is
really a bug in grep then please say the version of grep. And if it
is an older version please try it with a newer version to see if the
problem has been fixed since that older version.

Bob

0 new messages