joakim666 / colortail

Like the tail command line utility but with colors
GNU General Public License v2.0
126 stars 23 forks source link

colortail emits excessive color sequences #4

Closed phord closed 9 years ago

phord commented 13 years ago

colortail seems to color each matched character individually instead of switching colors only when needed. This is pretty wasteful and can cause secondary parsers to fail to match keywords.

echo 'COLOR brightmagenta
{
^(.*)$
}' > ct.conf
echo bar > foo
colortail -k ct.conf foo |hexdump -C
00000000  3d 3d 3e 20 66 6f 6f 20  3c 3d 3d 0a 1b 5b 31 3b  |==> foo <==..[1;|
00000010  33 35 6d 66 1b 5b 31 3b  33 35 6d 6f 1b 5b 31 3b  |35mb.[1;35ma.[1;|
00000020  33 35 6d 6f 1b 5b 31 3b  33 35 6d 0a 1b 5b 30 3b  |35mr.[1;35m..[0;|
00000030  30 6d 00                                          |0m.|
00000033

colortail -k ct.conf foo |grep foo
Binary file (standard input) matches
echo $?
0
colortail -k ct.conf foo |grep bar
echo $?
1
joakim666 commented 9 years ago

Closing after merged fix.