GNU bug report logs - #31071
Previous color lost when using --color=always option

Previous Next

Package: grep;

Reported by: Adrian H <adrianh.bsc <at> gmail.com>

Date: Thu, 5 Apr 2018 21:32:01 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Adrian H <adrianh.bsc <at> gmail.com>
To: 31071 <at> debbugs.gnu.org
Subject: bug#31071: Previous color lost when using --color=always option
Date: Thu, 5 Apr 2018 12:44:29 -0400
If I use grep --color=always and it matches on a line that is already
coloured, it results in the text after the match is reset to the
terminal's default colour/attributes.  E.g.

This just shows a line with some colour/attributes set:

  $ echo The quick brown fox jumps over the lazy dog |
  > GREP_COLOR='03;36' grep --color=always '.*'
  ESC[03;36mESC[KThe quick brown fox jumps over the lazy dogESC[mESC[K

This shows the same line with fox highlighted in other attributes:

  $ echo The quick brown fox jumps over the lazy dog |
  >  GREP_COLOR='03;36' grep --color=always '.*' |
  >  GREP_COLOR='01;36' grep --color=always 'fox'
  ESC[03;36mESC[KThe quick brown ESC[01;36mESC[KfoxESC[mESC[K jumps
over the lazy dogESC[mESC[K

The issue is that the current colour isn't tracked, it is just reset
with ESC[m.  It would be nice if it were able to be tracked.  Yes, it
is more difficult to code, but I think it would be useful when
highlighting a coloured textual document.




This bug report was last modified 5 years and 170 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.