GNU bug report logs - #36148
inconsistent behaviour with anchored regex containing back-references

Previous Next

Package: grep;

Reported by: g1pi <at> libero.it

Date: Sun, 9 Jun 2019 15:30:02 UTC

Severity: normal

Merged with 26864

Full log


View this message in rfc822 format

From: g1pi <at> libero.it
To: 36148 <at> debbugs.gnu.org
Subject: bug#36148: inconsistent behaviour with anchored regex containing back-references
Date: Sun, 9 Jun 2019 10:00:24 +0200
There seems to be a problem with beginning/end-of-line anchors in regex
containing back-references:

$ grep -V | head -1
grep (GNU grep) 3.1

$ cat words
ana
deed
ill
stats

Using -x to match whole line works:

$ egrep -x '(.?)(.?).?\2\1' words 
ana
deed
stats

Using explicit anchors emits false positives:

$ egrep   '^(.?)(.?).?\2\1$' words 
ana
deed
ill	<<<
stats

On the other hand, colouring the output shows that grep somewhat knows its
mistake:

$ egrep --color '^(.?)(.?).?\2\1$' words 
ana	(coloured)
deed	(coloured)
ill
stats	(coloured)





This bug report was last modified 83 days ago.

Previous Next


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