Package: bash
Version: 3.1-4
Severity: minor

 --- I apologize if you receive duplicates of this message ---
 --- because of mail server error ---

Hi!

I think there's a bug with bash v3.1 when output a line without trailing
newline in case PS1 has non-printing characters embedded. The cursor
gets a wrong position and overwrites the output string.

Example:

$PS1='$'
$echo -n abc  # output abc without trailing newline
abc$
   ^         # cursor (shown by ^) is right after $ as we expected

$PS1='\[\e[0m\]$'      # try colored prompt
$echo -n abc
$bc$
 ^            # cursor points to the wrong place

$PS1='\[\e[0m\]123$'   # another try, with more normal characters
123$echo -n abc
abc123$
      ^      # this time we get the right result

Empirically, once the number of characters embedded in \[ \] overtakes
the rest normal characters in PS1 (with \e counted as one char), this
problem occurs. As the second case shown above, it looks like that after
printing string abc followed by $PS1, cursor jumps back to the beginning
of line with $PS1 printed again, leads to overwrite previous output.

I have tried bash v3.0 too, which works fine against the above test.

Regards!

wyf

-- System Information:
Debian Release: testing/unstable
 APT prefers unstable
 APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14-1-686
Locale: LANG=zh_CN.GBK, LC_CTYPE=zh_CN.GBK (charmap=GBK)

Versions of packages bash depends on:
ii  base-files                    3.1.11     Debian base system miscellaneous f
ii  debianutils                   2.15.3     Miscellaneous utilities specific t
ii  libc6                         2.3.6-5    GNU C Library: Shared libraries an
ii  libncurses5                   5.5-1      Shared libraries for terminal hand

bash recommends no packages.

-- no debconf information

Reply via email to