Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Eric Blake Newsgroups: gnu.utils.bug Subject: Re: found bug Date: Wed, 22 Aug 2018 20:55:20 -0500 Organization: Red Hat, Inc. Lines: 59 Approved: bug-gnu-utils@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1534989585 20133 208.118.235.17 (23 Aug 2018 01:59:45 GMT) X-Complaints-To: action@cs.stanford.edu To: Karl Riauba , bug-gnu-utils@gnu.org Envelope-to: bug-gnu-utils@gnu.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 23 Aug 2018 01:55:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 23 Aug 2018 01:55:21 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 X-BeenThere: bug-gnu-utils@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU utilities List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.utils.bug:2249 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-grep@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