Package: grep
Version: 2.27-2
Severity: normal

There seems to be a problem with beginning/end-of-line anchors in regex
containing back-references:

$ 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)

-- System Information:
Debian Release: 9.9
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-9-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968), LANGUAGE=C 
(charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages grep depends on:
ii  dpkg          1.18.25
ii  install-info  6.3.0.dfsg.1-1+b2
ii  libc6         2.24-11+deb9u4
ii  libpcre3      2:8.39-3

grep recommends no packages.

Versions of packages grep suggests:
ii  libpcre3  2:8.39-3

-- no debconf information

Reply via email to