GNU bug report logs - #21414
-F string with tailing newline always matches

Previous Next

Package: grep;

Reported by: Ian Brown - HNAS <ian.brown <at> hds.com>

Date: Fri, 4 Sep 2015 15:34:03 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#21414: closed (-F string with tailing newline always matches )
Date: Fri, 04 Sep 2015 17:35:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 4 Sep 2015 10:34:12 -0700
with message-id <55E9D614.4090202 <at> cs.ucla.edu>
and subject line Re: bug#21414: -F string with tailing newline always matches
has caused the debbugs.gnu.org bug report #21414,
regarding -F string with tailing newline always matches 
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
21414: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21414
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ian Brown - HNAS <ian.brown <at> hds.com>
To: "bug-grep <at> gnu.org" <bug-grep <at> gnu.org>
Subject: -F string with tailing newline always matches 
Date: Fri, 4 Sep 2015 14:45:45 +0000
[Message part 3 (text/plain, inline)]
Grep version 2.20

When using the ouput of another command to pass match strings into grep using -F I was getting unexpected results as it was matching every line. If the terminating newline is removed the grep started to work again.

Easy to work around but this is different behaviour from 2.12 and may cause some scripts to fail.

Ian Brown (HDS)

[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Ian Brown - HNAS <ian.brown <at> hds.com>, 21414-done <at> debbugs.gnu.org
Subject: Re: bug#21414: -F string with tailing newline always matches
Date: Fri, 4 Sep 2015 10:34:12 -0700
On 09/04/2015 07:45 AM, Ian Brown - HNAS wrote:
> Grep version 2.20
>
> When using the ouput of another command to pass match strings into grep using -F I was getting unexpected results as it was matching every line. If the terminating newline is removed the grep started to work again.
>
> Easy to work around but this is different behaviour from 2.12 and may cause some scripts to fail.
>
> Ian Brown (HDS)
>

I assume you're referring to the following sort of behavior:

$ printf 'abc\n\ndef\n' >foo
$ grep -F 'abc
' foo
abc

def

Older versions of GNU grep would ignore the newline after 'abc' in the 
pattern, and would output only 'abc' with the above example. This 
behavior was incompatible with non-GNU grep implementations and with 
POSIX, and the incompatibility seemed to be unintended and not that 
useful and was fixed at some point (sorry, don't know the GNU grep 
version).  Sorry you were relying on it.


This bug report was last modified 9 years and 262 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.