bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33162: Pattern partially greps windows line-endings since 3.1


From: Holger Klene
Subject: bug#33162: Pattern partially greps windows line-endings since 3.1
Date: Fri, 26 Oct 2018 14:41:59 +0200

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]