bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multi-line Prompt/PS1 wrapping oddly


From: Tianon Gravi
Subject: Multi-line Prompt/PS1 wrapping oddly
Date: Fri, 12 Jul 2019 13:40:15 -0700

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$
'.

I've also recorded a short asciinema to help illustrate more clearly:
https://asciinema.org/a/zaOBmlbs01VlPfuBPpcswQ3vm

♥,
- Tianon
  4096R / B42F 6819 007F 00F8 8E36  4FD4 036A 9C25 BF35 7DD4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]