Dear Maintainer,
I was seeing incorrect cursor behaviour when my PS1 prompt got long, and
was surprised to learn that merely moving a space character from after a
control sequence to before it fixed the problem. Based on the man page,
I think I've used the "non-printing" escapes correctly.
Try this in an 80-character-wide terminal:
x159=''
while [ "${#x159}" -lt 159 ]; do x159=x$x159; done
PS1=$'\\[\x1b[0;33;40m\\]'$x159$'$\\[\x1b[0m\\] '
Then enter an ordinary character such as 't'. I see my cursor move up a
line to the final 'x' before '$', instead of the expected position after
the 't' I just entered. But I see no problem with this prompt:
PS1=$'\\[\x1b[0;33;40m\\]'$x159$'$ \\[\x1b[0m\\]'
I only moved the trailing space. It's outside the non-printing sequence
delimited by \[ and \] in both cases, so I'd expect no difference except
the colour of that cell.
- Michael
Version: 5.2.21-2.1 Hi, this issue does not seem to be reproducible in version 5.2.21-2 of bash. Please reopen this bug if you can still reproduce this issue. Regards,
reopen 1018851 stop Thanks for looking at this. I'm using bash package version "5.2.21-2.1". Upon further investigation under variously "clean" environments, I can still re-produce this inside urxvt (rxvt-unicode 9.31-3+b1), but only if LANG is set. I used the bwrap (bubblewrap) utility to hide all user directories, and Xepher to ensure a clean X11 environment (xrdb -query shows nothing). I ran "urxvt -cr red -e /bin/bash", setting the cursor colour to red to make it more visible when the problem occurs. I'm attaching screen-shots. term1.png is immediately after setting the prompt, before typing "t"; term2.png is after typing "t"; term3.png is after further typing "est" (that is, typing "test" without pressing Enter). By using the left and right arrow keys, I can then cause the cursor to "walk" up the terminal, as shown in term4.png. If I leave LANG unset, the problem does not occur. Its normal value is en_CA.UTF-8 on my system, and C.UTF-8 shows the same behaviour.
Control: tags -1 confirmed
Control: found -1 5.2.21-2.1
Oh, I see. In my tests I had LC_* set, but LANG was not set.
I can confirm that this issue happens also with gnome-terminal and
xterm, as long as LANG is set to an available locale ending with ".UTF-8".
To reproduce:
$ set LANG=C.UTF-8
$ x=$(eval "printf x%.0s {1..$((COLUMNS*2-1))}")
$ PS1=$'\[\e[0;34;42m\]'$x$'\[\e[0m\]\$ '
(press up arrow)
(type anything)
Regards,