angle-grinder icon indicating copy to clipboard operation
angle-grinder copied to clipboard

Splitting within an ANSI color code causes all output to be printed in that color

Open wfchandler opened this issue 2 years ago • 2 comments

Currently ANSI color codes present in source input are retained and printed in the output, even when redirecting to a file.

If a split is made within a color group, this may lead to an unescaped color code that causes all output to use that color.

image

In the log file being parsed the color code starts at the start of the second column and is terminated at the end of third:

image

By parsing the second column as a field we capture the start of the color code, but lose its termination. The stuck terminal color can be fixed by executing echo -e '\033[0m'.

I think it would probably be better to strip out color and other terminal escape codes from output.

wfchandler avatar Jul 27 '21 05:07 wfchandler

this is an interesting bug...stripping color from the output is probably the best option

rcoh avatar Aug 04 '21 15:08 rcoh

The vte crate (https://crates.io/crates/vte) might be useful here. Stripping the escape sequences before putting the string through parsers would probably be something to try.

tstack avatar Aug 18 '21 06:08 tstack