bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BUG: grep --color -i


From: Eric Blake
Subject: Re: BUG: grep --color -i
Date: Fri, 26 May 2006 06:26:46 -0600
User-agent: Thunderbird 1.5.0.2 (Windows/20060308)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Kenneth Nellis on 5/25/2006 8:38 AM:
> 
> (This e-mail contains color-coded text.)

Actually, it didn't.  Most GNU lists are plain text, so if you want to
show ANSI color sequences, it is better to pipe output through od or
hexdump to show where the color sequences were emitted in relation to the
bytes.

> 
> I wish to report that grep does not correctly color matched strings.
> 
> Below, I offer commands and their output to demonstrate that  “grep --color 
> -i” misses some of the strings it should highlight. In the output, below, the 
> bold red highlighting was provided by grep. I added the background 
> highlighting to point out strings that grep failed to highlight.

I recall having seen cases where the color sequences emitted by grep
conflict with the capabilities of a terminal; for example, if a color
start occurs before but the end occurs after text has wrapped around a
line, some terminals refuse to color that sequence of text.  But in trying
to reproduce that, I found that I could make grep go into an infinite loop!

$ grep --version | head -n1
grep (GNU grep) 2.5.1
$ echo $TERM
xterm
$ echo \
looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng\

| grep -i --color=always 'n*' | od -tx1z -Ax
...
0096e0 5b 30 31 3b 33 31 6d 1b 5b 30 30 6d 1b 5b 30 31  >[01;31m.[00m.[01<
0096f0 3b 33 31 6d 1b 5b 30 30 6d 1b 5b 30 31 3b 33 31  >;31m.[00m.[01;31<
009700 6d 1b 5b 30 30 6d 1b 5b 30 31 3b 33 31 6d 1b 5b  >m.[00m.[01;31m.[<
009710 30 30 6d 1b 5b 30 31 3b 33 31 6d 1b 5b 30 30 6d  >00m.[01;31m.[00m<
009720 1b 5b 30 31 3b 33 31 6d 1b 5b 30 30 6d 1b 5b 30  >.[01;31m.[00m.[0<
009730 31 3b 33 31 6d 1b 5b 30 30 6d 1b 5b 30 31 3b 33  >1;31m.[00m.[01;3<
009740 31 6d 1b 5b 30 30 6d 1b 5b 30 31 3b 33 31 6d 1b  >1m.[00m.[01;31m.<
009750 5b 30 30 6d 1b 5b 30 31 3b 33 31 6d 1b 5b 30 30  >[00m.[01;31m.[00<
009760 6d 1b 5b 30 31 3b 33 31 6d 1b 5b 30 30 6d 1b 5b  >m.[01;31m.[00m.[<
009770 30 31 3b 33 31 6d 1b 5b 30 30 6d 1b 5b 30 31 3b  >01;31m.[00m.[01;<
[at this point, I hit ctrl-c to kill the runaway grep]

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEdvQF84KuGfSFAYARAi0mAJwOaW2sfeTSCJC7xdULTp8rbOI8OwCfRRtM
mfjPOpNsqH6cqZ5aRuiGCkc=
=X1Q0
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]