grep --color= outputs blank line if \r in the input
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grep (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: grep
I expect the --color= option in grep to color the match. Instead, grep --color= shows a blank line when \r is in the input.
For example,
$ echo -ne "foo\n" | \grep --color=always '^f.*'
foo
$ echo -ne "foo\r\n" | \grep --color=always '^f.*'
$ echo -ne "foo\r\n" | \grep --color=always '^f.*' | od -bc
0000000 033 133 060 061 073 063 061 155 033 133 113 146 157 157 015 033
033 [ 0 1 ; 3 1 m 033 [ K f o o \r 033
0000020 133 155 033 133 113 012
[ m 033 [ K \n
0000026
grep does find and color the content. It's just not visible.
Removing the \r, even after adding color, displays the line.
$ echo -ne "foo\r\n" | \grep --color=always '^f.*' | tr -d '\r'
foo
$ grep --version
GNU grep 2.5.4
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid
Status changed to 'Confirmed' because the bug affects multiple users.