You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Line-ending handling was discussed in the issue grep crash with -i #5046. The comment by the “benevolent dictator” of Git for Windows:
The CR/LF handling was removed. Now grep always opens files in binary mode, which means that if you grep through a file that contains CR/LF line endings, regular expressions like x$ will never match, as the \r at the end of the line is interpreted as a character (one that differs from x in x$).
3. MCVE
3.1. Reproducibility
Reproduced:
The grep binary from Git for Windows launched from Git Bash and cmd.exe.
In all remote CIs that I used, Git for Windows is pre-installed, and a path to its binaries is already added to PATH. I don’t want to take additional steps for remote CIs.
4.2. “Just use diff, comm, or other alternatives”
grep is a better solution for my purpose. Read the section “Advantages” of my answer on Stack Overflow.
4.3. “Just trim line endings”
Yes, I can add something like tr --delete '\r'. This command returns the expected result:
1. Summary
grep from Git for Windows incorrectly handles line endings for me.
2. The possible reasons for the bug
Git for Windows 2.55.0 contains grep 3.0. Cygwin has grep 3.12.
Line-ending handling was discussed in the issue grep crash with -i #5046. The comment by the “benevolent dictator” of Git for Windows:
3. MCVE
3.1. Reproducibility
Reproduced:
Not reproduced:
3.2. Command
Cygwin, Git Bash and Ubuntu shells:
cmd.exe — the same command wrapped in
bash -c "":bash -c "grep --file=<(printf 'Kira Goddess!\r\r\n') <(printf 'Kira Goddess!\r\r\nKira Amazing!\r\r\n')"3.3. Behavior
3.3.1. Expected
Kira Goddess!3.3.2. Actual
No output.
4. The answers to possible replies
4.1. “Just use grep from Cygwin”
In all remote CIs that I used, Git for Windows is pre-installed, and a path to its binaries is already added to PATH. I don’t want to take additional steps for remote CIs.
4.2. “Just use diff, comm, or other alternatives”
grep is a better solution for my purpose. Read the section “Advantages” of my answer on Stack Overflow.
4.3. “Just trim line endings”
Yes, I can add something like
tr --delete '\r'. This command returns the expected result:But I’m sure that additional commands for bypassing bugs aren’t the best idea.
5. Environment
Thanks.