Subject: grep carriage return conflicts with output color highlighting

From: Judson Wilson <[email-masked]>
Date: Wed, 25 Jul 2012 16:34:45 -0700

I had trouble grepping carriage returns (grep $'\r' ) until I realized the
lines were printing blank.

If I grep something else on the line, the line prints fine. Putting 1 and 1
together I figured it was
the result highlighting conflicting with the carriage return color, and I
was able to get it to
work using --color=never.

test case:

[judson@localhost ~]$ echo $'a\nb\r\n\c\n' > carriage.txt
[judson@localhost ~]$ grep 'b' carriage.txt
b
[judson@localhost ~]$ grep $'\r' carriage.txt

[judson@localhost ~]$ grep --color=never $'\r' carriage.txt
b

As for my versions:

[judson@localhost ~]$ grep -V
grep (GNU grep) 2.9
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <
http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

[judson@localhost ~]$ uname -r
2.6.43.8-1.fc15.i686