buggrep - Bugs: bug #25063, grep --color clears line when CR...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #25063: grep --color clears line when CR matches (because of \33[K Erase Line string)

Submitter:  None
Submitted:  Wed 10 Dec 2008 03:19:12 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Wed 23 Dec 2009 10:27:19 AM UTC, comment #1: 

You can set GREP_COLORS=ne in the environment to achieve the desired effect.

Paolo Bonzini <bonzini>
Wed 10 Dec 2008 03:19:12 PM UTC, original submission:  

"""
$ echo -en 'foo\r\n' | grep --color=auto 'foo'
foo
$ echo -en 'foo\r\n' | grep --color=auto 'foo.'

$ echo -en 'foo\r\n' | grep 'foo.'
foo
"""

Because grep uses the \33[K Erase Line string to end a colored match, it will clear the entire line when a legitimate carriage return (CR) matches in a file with DOS line-endings.

This is not just a theoretical issue. When searching for things at EOL I can't use 'foo$' for DOS-files, so I need to use 'foo[[:blank:]]*$' and that's the one that breaks.

I'm not sure what the best/quickest fix here is, but I'd scrap the """There are no additional disadvantages specific to doing it after SGR END."""-comment from the grep.c file ;-)

Greetings,
Walter Doekes
OSSO B.V.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bonzini (Posted a comment)
  • -email is unavailable- added by wdoekes
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-12-23 bonzini Open/ClosedOpen Closed
        Summarygrep --color clears line when CR matches (because of \\33[K Erase Line string) grep --color clears line when CR matches (because of \33[K Erase Line string)
    2009-12-23 bonzini StatusNone Fixed
    2008-12-10 wdoekes Carbon-Copy- Added wdoekes

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code