Consider the following shell command:
echo -e "\e[41mTest\nTest2\e[0mTest3"
It prints Test
and in the next line Test2
with a red background (using an ANSI escape code). Test2
is followed directly by Test3
which is uncolored.
The first time this command is executed everything works as expected. However the output is not consistent. After about 10-20 invocations the end of the second line turns red as well. I first stumbled upon this in my C++ App. So I thought it's probably not related to bash.
After the discovery I figured it may be a bug in gnome-terminal
. However the behavior is exactly the same in xterm
.
Thanks to the comment of Geno Chen I figured out that this occurs when the terminal runs out of lines and has to scroll.
Here are the screenshots of aforementioned problem:
Although it makes things a bit unclear in my C++ App it is not a deal breaker. However I'd like to know if there is something wrong with my escape sequences or if this is a bug in some part of the shell. And if there is something I can do to fix it or workaround it.
Filling the line with the currently-selected colors is a detail of bce
(back color erase) which could be implemented differently in different terminals—but Linux console and xterm happen to do it this way. It's an FAQ:
indn
)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With