[Toybox] [PATCH] grep: Make --color highlight all matches on a line.
Rob Landley
rob at landley.net
Tue Sep 21 18:45:18 PDT 2021
On 9/21/21 1:54 PM, Peter Collingbourne via Toybox wrote:
> This matches the behavior of GNU grep.
Well, _sort_ of. The test you added won't pass TEST_HOST because:
$ echo hello | grep --color=always l | hd
00000000 68 65 1b 5b 30 31 3b 33 31 6d 1b 5b 4b 6c 1b 5b |he.[01;31m.[Kl.[|
00000010 6d 1b 5b 4b 1b 5b 30 31 3b 33 31 6d 1b 5b 4b 6c |m.[K.[01;31m.[Kl|
00000020 1b 5b 6d 1b 5b 4b 6f 0a |.[m.[Ko.|
Different escapes. (The behavior's probably good enough, but the test isn't.)
Hmmm, I don't need to specify the zero to go back to grey, do I? The \e[K is
definitely funky though, that's delete until end of line...? (Why...?)
And to be honest I'm tempted to remember the current color and optimize out
unnecessary color change escapes. Hmmm...
Thanks for the bug fix, good catch. Lemme poke at this a bit...
Rob
More information about the Toybox
mailing list