GNU/Linux ◆ xterm-256color ◆ bash 2677 views

I cannot reproduce on Bash 4.4.23, but I can reproduce on all of Bash 5.0.3 (Debian’s) Bash 5.0.7 and ea578790a910fcd394930de7a1933a9ee24f9119 from the “devel” branch (“commit bash-20190705 snapshot”).

I’m on Linux and can reproduce both in my host’s install of Bash (Debian Buster), and inside containers (which is how I’ve tested various Bash versions to reproduce). I can also reproduce in all of xfce4-terminal, gnome-terminal, and terminology (in trying to make sure it really was Bash and not a quirk of the terminal). Bash in Debian is likely compiled via GCC 8.3.0, my Bash 5.0.7 was compiled via GCC 8.3.0 in Alpine 3.9, and my Bash from devel was compiled via GCC 8.3.0 in Alpine 3.10.

What I’ve found is that if PS1 contains ‘\n’ and the last line gets long enough for the cursor to be on the next line (for example, if \w gets too long), then typing will result in a single character being printed in the correct place followed by the cursor being moved to the next line.

I’ve found the simplest way to test is to have a small terminal (I use 80x24) and set PS1 to something long (and it reproduces with or without special characters, colors, or even \w, \h, \u, etc). My current testing value is PS1=’\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa$ ‘.