Why does grep add ANSI code
\e[K to its colored output? I can't see the point of it, but obviously the developers can. It is an ANSI/VT100 Terminal code which is used to "Clear line from current cursor position to end of line".
In a fringe case, grep can cause text to "vanish" from the terminal display. For example:
echo -e "ab\rc" echo -e "ab\rc" |grep --color=always "c"
The simple echo displays:
cb, but the colorized display shows:
The underlying encoded text is:
echo -e 'ab\r\033[01;31m\033[Kc\033[m\033[K'
However, without the
echo -e 'ab\r\033[01;31mc\033[m' works as expected!
What is the reason for grep's inclusion of these
\e[K codes. I'm writing a script to allow for overlaying of a second colorizing pass, as in:
c=--color=always; ls $c /bin/gzip | grep $c 'z'. so I need to understand why grep uses