escape code curiosity

Skip to first unread message

Richard Mitchell

May 5, 2022, 9:19:04 AMMay 5
to iterm2-discuss
This isn't iTerm2 specific, also fails in Terminal, but curious if anyone understands how this is failing.

I'm using egrep to colorize text, this is a contrived example to show the failure.


The two commands are:
echo "0123456789012345678921234567893" | egrep --color=always ".|\$"
echo "012345678901234567892123456789312" | egrep --color=always ".|\$"

Piping the output to 'wc -c' shows 559 and 629.  If the string terminates at '1', it still duplicates the output with a count of 610 - thus the output is not really duplicated, otherwise the counts would have jumped to over 1200.

To understand the command, egrep is colorizing each individual character.  The '|\$' causes the entire input text to be output in addition to the match.  This is an admitted abuse of using egrep to highlight words in a stream or document while also showing non-matching lines.

I'm guessing at ~600 characters without a newline and a lot of escape codes, this trips something in the standard vt100 implementation?

The trip point is at 32 characters of input, each getting wrapped in a colorize escape sequence, followed by a reset escape sequence.


Richard Mitchell

May 5, 2022, 6:12:41 PMMay 5
to iterm2-discuss
This appears to only fail in Monterey (macOS 12) and not Big Sur (macOS 11).

That's even more curious.

Richard Mitchell

May 6, 2022, 7:08:47 AMMay 6
to iterm2-discuss
The issue looks to be with egrep, which has an updated version in Monterey.
Reply all
Reply to author
0 new messages