Package: bash
Version: 5.2~rc2-2

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


-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.18.0-4-amd64 (SMP w/32 CPU threads; PREEMPT)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_CA:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages bash depends on:
ii  base-files   12.2
ii  debianutils  5.7-0.3
ii  libc6        2.34-7
ii  libtinfo6    6.3+20220423-2

Versions of packages bash recommends:
pn  bash-completion  <none>

Versions of packages bash suggests:
pn  bash-doc  <none>

-- no debconf information

Attachment: signature.asc
Description: PGP signature

Reply via email to