Subject: bug#32838: Regression in grep 3.1: Grep '$' matcher no longer works on CRLF files on Windows

From: Konstantin Kolinko <[email-masked]>
Date: Tue, 25 Sep 2018 11:15:51 +0300

Hi!

This issue has been reported downstream at Git for Windows project, here:
https://github.com/git-for-windows/git/issues/1841

Git for Windows includes a set of GNU utilities. IIRC those come from
MinGW project.

Summarizing from the downstream report:
Actual output, with grep 3.1 (in Git for Windows 2.19.0):
[[[
$ grep --version
grep (GNU grep) 3.1
...

$ cat > foo.txt
foo:
bar
baz:

$ unix2dos foo.txt
unix2dos: converting file foo.txt to DOS format...

$ grep ':$' < foo.txt

$ grep --line-regexp '.*:' foo.txt

$ grep --line-regexp '.*:' < foo.txt

]]]

Expected output, observable with grep 3.0 (in Git for Windows 2.18.0),
or if I run dos2unix on the file:

[[[
$ cp foo.txt foo2.txt

$ dos2unix foo2.txt
dos2unix: converting file foo2.txt to Unix format...

$ grep ':$' < foo2.txt
foo:
baz:

$ grep --line-regexp '.*:' foo2.txt
foo:
baz:

$ grep --line-regexp '.*:' < foo2.txt
foo:
baz:

]]]

I guess that this regression is related to the following changes
listed in the NEWS file, apparently implemented via #25707:

[[[
  The following changes affect only MS-Windows platforms.  First, the
  --binary (-U) option now governs whether binary I/O is used, instead
  of a heuristic that was sometimes incorrect.  Second, the
  --unix-byte-offsets (-u) option now has no effect on MS-Windows too.
]]]

Best regards,
Konstantin Kolinko