GNU bug report logs -
#33162
Pattern partially greps windows line-endings since 3.1
Previous Next
Full log
View this message in rfc822 format
Hello!
I think, I may have stumbled upon a bug in gnu-grep version 3.1 which was not present in 3.0 and 2.6.3
Steps to reproduce:
A) generate test-file: printf "a --\r\nb --\nc --\rd --\n\r" > test.txt
B) check test-file: md5sum.exe test.txt
e3ef5d742eee3a7f326bc7b4b391cc42 *test.txt
C) run old grep 3.0 or 2.6.3:
$ grep -ce '--[^ -]' test.txt
1
$ grep -ne '--[^ -]' test.txt
3:c --d --
D) run new grep 3.1:
$ grep -ce '--[^ -]' test.txt
2
$ grep -ne '--[^ -]' test.txt
d --
It looks as if the 3.1 has an issue with alternative line-ending styles sometimes matched as part of the pattern:
a --\r\n (windows) is messed around
b --\n (unix) seems to work OK
c --\r just for completenes
d --\n\r just for completenes
You can modify the printf statement to generate each test-case into it's own file. b and d are equally not found, c is always found. The behavior changed for a: [^ -] now matches the \r in 3.1 which was ignored in older versions.
Thanks
Holger
PS: This version of grep was distributed along with git-bash for Windows 64bit
https://github.com/git-for-windows/git/releases/download/v2.19.1.windows.1/Git-2.19.1-64-bit.exe
grep (GNU grep) 3.1
GNU bash, version 4.4.19(2)-release (x86_64-pc-msys)
git version 2.19.1.windows.1
This bug report was last modified 4 years and 267 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.