Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 156292 - coloured prompt confuses Ctrl+R in app-shells/bash-3.2_p5
Summary: coloured prompt confuses Ctrl+R in app-shells/bash-3.2_p5
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
Depends on:
Reported: 2006-11-26 04:52 UTC by Benno Schulenberg
Modified: 2007-05-05 01:34 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

bash-3.2-display-prompt-invis-delete.patch (bash-3.2-display-prompt-invis-delete.patch,1.64 KB, patch)
2007-04-13 05:51 UTC, Peter Volkov (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Schulenberg 2006-11-26 04:52:40 UTC
When using the standard coloured prompt in bash-3.2_p5, the shell sometimes gets confused about its cursor position: typing Ctrl+R plus some letter and Home brings the cursor to the leftmost column of the screen.  This happens on the console, in Konsole and in xterm.  In bash-3.1_p17 it works fine.  Using an uncoloured prompt also makes the problem disappear.

I can just about always reproduce this by typing Ctrl+R, Shift+D (to recall the habitual 'emerge -Du world -pv' command), and then Home.

# echo $PS1
\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\]

# locale

# emerge --info
Gentoo Base System version 1.12.6
Portage 2.1.1-r2 (hardened/x86/2.6, gcc-hardenednopie, glibc-2.3.6-r5, 2.6.17 i686)
System uname: 2.6.17 i686 AMD Athlon(tm) XP 2800+
Last Sync: Sun, 26 Nov 2006 10:50:01 +0000
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: [Not Present]
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r4
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"
FEATURES="autoconfig distlocks metadata-transfer notitles sandbox sfperms strict test userfetch userpriv usersandbox"
LINGUAS="en en_GB en_US eo es es_ES nl nl_NL"
PORTAGE_RSYNC_EXTRA_OPTS="--progress --human-readable 			  --exclude-from=/etc/portage/rsync_excludes"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
USE="3dnow X aac alsa apm arts asf audiofile avi bash-completion berkdb bzip2 cdparanoia cdr cracklib crypt dio dlloader dri elibc_glibc encode exif fam fbcon ffmpeg flac gif glx gphoto2 gpm gtk gtk2 gtkhtml hardened imagemagick imap imlib input_devices_keyboard input_devices_mouse jabber jpeg jpeg2k kde kdeenablefinal kernel_linux lcms linguas_en linguas_en_GB linguas_en_US linguas_eo linguas_es linguas_es_ES linguas_nl linguas_nl_NL lm_sensors mad mbox mbrola memlimit mikmod mime mmap mmx mng modplug mp3 mpeg musepack ncurses nls nptl nsplugin ogg opengl pdf pic png python qt3 quicktime readline recode sasl scanner sdl shorten sndfile sox speex spell sqlite sse ssl svg test theora threads tidy tiff timidity truetype unicode usb userland_GNU userlocales vcd video_cards_fbdev video_cards_vesa video_cards_via vorbis win32codecs wmf x86 xface xine xml xorg xpm xsl xv xvid zlib"
Comment 1 SpanKY gentoo-dev 2006-12-16 03:49:25 UTC
bash-3.2_p9 should work
Comment 2 Benno Schulenberg 2006-12-17 07:37:49 UTC
Nope, not fixed.  It works fine after doing 'export LC_ALL=C', but not when LC_ALL=en_GB.utf8, for example (both in Konsole and on a VT).
Comment 3 Benno Schulenberg 2007-02-09 15:00:25 UTC
Defining PS1 as follows 'fixes' the problem:

  PS1='\[\033[001;031m\]\h \[\033[001;034m\]\W \$\[\033[000m\] '

That is: make each number consist of three digits.

[[ Observations made before finding the workaround:

Using \e instead of \033 makes no difference.

Occurrence of the problem (Home going too far left) also depends on the length of the name of the current directory: when this name is longer than three characters, the problem does not occur.  So when in root's home dir (~), in /etc or in /usr, hitting Home after a Ctrl+R sequence goes too far left, but when in for example /sbin or /usr/share, it goes to the correct place.

When using \w instead of \W, the name of the current dir has to be somewhat longer for the problem to stop occurring: it goes wrong in /etc, /sbin and /buntu, but not any more in /camera and /cdwriter.  :|

(All this time I'm recalling the command 'emerge -Du world -pv' by typing:
<Ctrl+R> <D> <u> <Home>.) ]]
Comment 4 Peter Volkov (RETIRED) gentoo-dev 2007-04-13 05:51:10 UTC
Created attachment 116120 [details, diff]

Try attached patch, Chet Ramey suggested to use. It should fix the problem...
Comment 5 Benno Schulenberg 2007-04-13 09:19:17 UTC
Ehm, yes, that is the patch I made myself, Peter.  :)  It does solve the problem.
Comment 6 Benno Schulenberg 2007-05-04 10:35:17 UTC
Fixed with p17.

@Peter: But the problem with multibyte characters in directory names isn't fixed yet.

ordesa ~ # mkdir ĉaĉaĉaĉaĉa
ordesa ~ # cd ĉaĉaĉaĉaĉa
ordesa ĉaĉaĉaĉaĉa #
ordesa ĉaĉaĉaĉaĉa # ls somefile
ls: cannot access somefile: No such file or directory
ordesa ĉaĉaĉaĉaĉa #
ordesa ĉaĉaĉaĉaĉa #
(reverse-i-search)`': aĉaĉaĉaĉa # saaile(reverse-i-search)`':                                  s': lomes somefile

(After twice <Enter>, I've typed there <^R><s><o><m><e>.)
Comment 7 Peter Volkov (RETIRED) gentoo-dev 2007-05-04 11:17:21 UTC
Benno, thank you fro reporting back and closing this bug report. But I did not manage to reproduce any bugs with steps you suggested:

peter@camobap ~ $ bash --version
GNU bash, version 3.2.17(1)-release (i686-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
peter@camobap ~ $ bash
peter@camobap ~ $ mkdir ĉaĉaĉaĉaĉa
peter@camobap ~ $ cd ĉaĉaĉaĉaĉa
peter@camobap ~/ĉaĉaĉaĉaĉa $
peter@camobap ~/ĉaĉaĉaĉaĉa $ ls somefile
ls: невозможно получить доступ к somefile: Нет такого файла или каталога
(reverse-i-search)`some': ls somefile

So, please, if you have problems please create new bug report with detailed steps what you did and what went wrong. Assign bug on base-system AT (' AT ' -> @)

BTW. You do not need to CC me. I receive all mail from base-system@g.o.
Comment 8 SpanKY gentoo-dev 2007-05-05 01:34:33 UTC
*** Bug 177095 has been marked as a duplicate of this bug. ***