grep --color= outputs blank line if \r in the input

Bug #696688 reported by Robert Citek
16
This bug affects 3 people
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

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in grep (Ubuntu):
status: New → Confirmed
Revision history for this message
schamane (schamane) wrote :

Related to

grep - Bugs: bug #25539, empty display with DOS newlines... [Savannah]
http://savannah.gnu.org/bugs/?25539

#456943 - grep: incorrect display with color and wrapping in some terminals - Debian Bug report logs
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=456943

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.