Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 130955 - readline messes up prompt expansion with invisible chars
Summary: readline messes up prompt expansion with invisible chars
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: http://lists.gnu.org/archive/html/bug...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-23 04:12 UTC by Martin Väth
Modified: 2006-05-05 19:56 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Väth 2006-04-23 04:12:50 UTC
>=bash-3.1* gets confused with e.g. the following prompt which was handled correctly with <=bash-3.0*
  PS1='$(echo "Strange \[\e[0;32m\]Prompt\[\e[0m\] ")'
(The example is of course not useful, but minimal: You need in particular an "expandable" PS1 and non-printable characters in the "middle" of the text to produce it).
You can see the problem if you use this prompt and then e.g. type something until the cursor enters the next line and then type backspace. It appears that something is wrong with the calculation of the prompt length and position of non-printable characters.


Gentoo Base System version 1.6.14
Portage 2.1_pre9-r3 (!/gentoo64/usr/portage/profiles/default-linux/amd64/2006.0, gcc-3.4.6, glibc-2.3.5-r3, 2.6.16-hardened-r4 x86_64)
=================================================================
System uname: 2.6.16-hardened-r4 x86_64 AMD Athlon(tm) 64 Processor 3000+
ccache version 2.3 [enabled]
dev-lang/python:     2.4.2
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ABI="amd64"
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE=""
ARCH="amd64"
AUTOCLEAN="yes"
BASH_ENV="/etc/spork/is/not/valid/profile.env"
CBUILD="x86_64-pc-linux-gnu"
CDEFINE_amd64="__x86_64__"
CDEFINE_x86="__i386__"
CFLAGS="-fPIC -march=athlon64 -O2 -fno-ident -pipe"
CFLAGS_x86="-m32 -L/emul/linux/x86/lib -L/emul/linux/x86/usr/lib"
CHOST="x86_64-pc-linux-gnu"
CHOST_amd64="x86_64-pc-linux-gnu"
CHOST_x86="i686-pc-linux-gnu"
CLEAN_DELAY="5"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/eselect/compiler /etc/gconf /etc/env.d"
CXXFLAGS="-fPIC -march=athlon64 -O2 -fno-ident -pipe"
DEFAULT_ABI="amd64"
DISTDIR="/gentoo64/distdir.mv/distfiles"
ELIBC="glibc"
EMERGE_DEFAULT_OPTS="--verbose --nospinner"
EMERGE_WARNING_DELAY="10"
EXTRA_ECONF="--enable-new-ldflags --enable-new_ldflags"
FEATURES="autoconfig ccache collision-protect confcache distlocks sandbox sfperms strict userpriv usersandbox"
FETCHCOMMAND="/home/gentoo/various/scripts/trickyfetch ${URI} ${DISTDIR} ${FILE}"
GENTOO_MIRRORS=[deleted]
INPUT_DEVICES="keyboard mouse"
KERNEL="linux"
LDFLAGS="-Wl,--sort-common -Wl,-O1 -s"
LDFLAGS_x86="-m elf_i386 -L/emul/linux/x86/lib -L/emul/linux/x86/usr/lib"
LIBDIR_amd64="lib64"
LIBDIR_x86="lib32"
LINGUAS="en de ru"
MAKEOPTS="-j2"
MULTILIB_ABIS="x86 amd64"
MULTILIB_STRICT_DENY="64-bit.*shared object"
MULTILIB_STRICT_DIRS="/lib /usr/lib /usr/kde/*/lib /usr/qt/*/lib /usr/X11R6/lib"
MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|eclipse-3|debug|portage)"
MY_RSYNC_EXCLUDEFROM="/home/gentoo/various/etc/portage/rsync_excludes"
NOCOLOR="1"
OPTCFLAGS="-O3 -O4 -fomit-frame-pointer -frename-registers -fweb -funswitch-loops -s -funroll-all-loops -fpeel-loops -ftracer -DNDEBUG -DG_DISABLE_ASSERT -DNO_DEBUG"
OPTCXXFLAGS="-O3 -O4 -fomit-frame-pointer -frename-registers -fweb -funswitch-loops -s -funroll-all-loops -fpeel-loops -ftracer -DNDEBUG -DG_DISABLE_ASSERT -DNO_DEBUG -fvisibility-inlines-hidden"
OPTLDFLAGS="-Wl,-z,combreloc -Wl,--relax -Wl,-z,now"
PKGDIR="/space/gentoo/x86_64"
PORTAGE_ARCHLIST="ppc s390 amd64 ppc64 x86-fbsd m68k arm sparc sh mips ia64 alpha ppc-macos hppa x86"
PORTAGE_BINHOST_CHUNKSIZE="3000"
PORTAGE_CALLER="emerge"
PORTAGE_ELOG_CLASSES="info warn error log"
PORTAGE_ELOG_MAILFROM="portage"
PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for ${PACKAGE} on ${HOST}"
PORTAGE_ELOG_MAILURI="root"
PORTAGE_ELOG_SYSTEM="save"
PORTAGE_GID="250"
PORTAGE_INST_GID="0"
PORTAGE_INST_UID="0"
PORTAGE_MASTER_PID="24441"
PORTAGE_NICENESS="9"
PORTAGE_RSYNC_EXTRA_OPTS="-P --exclude-from=/home/gentoo/various/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'"
PORTAGE_RSYNC_RETRIES="3"
PORTAGE_TMPDIR="/var/tmp"
PORTAGE_WORKDIR_MODE="0700"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/gentoo64/usr/local/overlays/portage.de /home/gentoo/various/portage"
PORT_ENOTICE_DIR="/var/log/notices"
PORT_LOGDIR="/var/log/portage"
PRELINK_PATH=""
PRELINK_PATH_MASK=""
RESUMECOMMAND="/usr/bin/wget -c -t 5 --passive-ftp -P ${DISTDIR} ${URI}"
RPMDIR="/usr/portage/rpm"
SYMLINK_LIB="yes"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="amd64 16bit 64bit 7zip S3TC X a52 aac aalib acpi adsl akode alsa amarok aotuv arts asf async athena atlas auctex audiofile ax25 bash-completion bcmath berkdb bigpatch bindist bittorrent bl blas bmpx browserplugin bzip2 cap caps cblas ccache cdda cdio cdparanoia cdr cdrom cg chasen checkpath chipcard config_wizard crypt crypto_openssl css curl curlwrappers custom-cflags cvs dcraw dga dio discard-path divx dnd dnotify double-precision dpms dri dtaus dts dv dvbplayer dvd dvdr dvdread dynamic ecc edl emacs emul-linux-x86 encode escreen esd eurofile exif exscalibar extras fam fame fat fbcon fbsplash festival ffmpeg filter fix-connected-rt flac fmod force-cgi-redirect fortran ftp gatos gd gdbm geldkarte gencertdaily gif gimp ginac gkrellm glade glgd glibc-compat20 glibc-omitfp glitz glut gmail gmailtimestamps gmp gmtsuppl gmttria gpm grammar gs gsm gtk gtk2 gzip hardenedphp hbci hddtemp ibam id3 idea ieee1394 ilbc image imagemagick imap imlib imlib2 infopipe input_devices_keyboard input_devices_mouse ipfilter ipsec irda jack java java-external jbig jce jpeg jpeg2k kde kdeenablefinal lame latex libsamplerate libtommath libwww lirc live login-watch logitech-mouse logrotate lzo lzw mad math matroska maya-shaderlibrary mbox md5sum memlimit mikmod mime mimencode mixer mjpeg mng mod mode-force mode-paranoid modplug motif mounts-check mozilla moznocompose moznoirc moznoxft mp3 mp4 mp4live mpeg mpeg2 mplayer mschap mupad-noscilab musepack music musicbrainz mythtv nas nat ncurses nforce2 ngui nls no-old-linux no_wxgtk1 noamazon nocardbus nocd noflagstrip nogecko-sdk nolvm1 nolvmstatic nomirrors nosnapshots nowin nvidia nvtv octave offensive ogg ogre on-the-fly-crypt openal openexr opengl opera oss pcntl pcre pdflib perl pic player plib plotutils png pnp pop portaudio posix preview-latex print python qt qt4 quicktime rar rc5 readline realms recode reiser4 reiserfs remix rle roe rogue rotor rtsp scenarios scp screen sdl setup-plugin sid skins slang smime sndfile sou sox speex spell sse-filters ssl stats stlport stream submenu subp subtitles suidcheck symlink sysfs szip tabs tagwriting tcltk tcpmd5 tetex themes theora thesaurus threads thumbnail tiff timidity tomsfastmath transcode udev unicode unzip usb userfiles userlocales utf8 uudeview v4l v4l2 vcd vcdimager video_cards_nv video_cards_nvidia video_cards_v4l videos visual vlm voice vorbis vorbis-psy wma wmf wordperfect wxwindows x264 xanim xatrix xchat xchattext xcomposite xext xgetdefault xine xlockrc xmms xorg xosd xpm xrandr xscreensaver xv xvid xvmc yaepg yv12 zip zlib zvbi elibc_glibc kernel_linux linguas_en linguas_de linguas_ru userland_GNU"
USERLAND="GNU"
USE_EXPAND="DVB_CARDS ELIBC FCDSL_CARDS FRITZCAPI_CARDS INPUT_DEVICES KERNEL LINGUAS USERLAND VIDEO_CARDS"
USE_EXPAND_HIDDEN=""
USE_ORDER="env:pkg:conf:defaults"
VESA="no"
VIDEO_CARDS="nv nvidia v4l"
XARGS="xargs -r"
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2006-04-23 05:04:58 UTC
On a side-note, don't file any compile-related bugs w/ all that broken stuff you have in C[XX]FLAGS/LDFLAGS.
Comment 2 Martin Väth 2006-04-24 04:34:41 UTC
It is only a side-note, but of course I always try several reasonable {C,CXX,LD}FLAGS before submitting a bug - for this particular bug, I had also compiled bash with C{,XX}FLAGS="-O2 -march=athlon64 -pipe" LDFLAGS="" with the same effect; and, as usual, I have also tested on x86 architecture.
Comment 3 Patrick Avery 2006-05-02 12:32:22 UTC
I see the same thing here... it might be more related to readline as you can see the same behavior in net-ftp/yafc which also uses readline.

The problem is only present (in bash) when "set horizontal-scroll mode on" is in (/etc|$HOME)/inputrc.

The problem is always in net-ftp/yafc as long as you have a colorful prompt setting.

=app-shells/bash-3.1_p17
=sys-libs/readline-5.1_p4
=net-ftp/yafc-1.1.1

---[ emerge --info
Portage 2.1_pre10-r2 (default-linux/x86/2006.0, gcc-4.1.0, glibc-2.4-r1, 2.6.16-gentoo-r2 i686)
=================================================================
System uname: 2.6.16-gentoo-r2 i686 Pentium II (Deschutes)
Gentoo Base System version 1.12.0_pre18
ccache version 2.4 [enabled]
dev-lang/python:     2.4.3
dev-util/ccache:     2.4-r1
dev-util/confcache:  0.4.2
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
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-r2
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r5
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=pentium2 -mtune=pentium2 -O3 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/vim/vimfiles /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/X11/xkb /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/eselect/compiler /etc/gconf /etc/revdep-rebuild /etc/splash /etc/terminfo /etc/env.d"
CXXFLAGS="-march=pentium2 -mtune=pentium2 -O3 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig buildpkg ccache confcache digest distlocks fixpackages metadata-transfer noinfo parallel-fetch prelink sandbox sfperms strict userlocales userpriv usersandbox"
GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://mirror.datapipe.net/gentoo http://gentoo.mirrored.ca/"
LANG="en_US.utf8"
LC_ALL="en_US.utf8"
LINGUAS="en"
PKGDIR="/usr/portage/packages/latest-i686"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/other-overlays /usr/local/portage/gentoo-php-overlay/portage /usr/local/portage/gentoo-php-overlay/testing"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
USE="x86 X alsa apache2 apm arts automount avi bash-completion berkdb bzip2 cli crypt cups curl dlloader dri eds emboss encode esd fbcon firefox font-server foomaticdb fortran gdbm gif gnome gnutls gpgme gpm gstreamer gtk gtk2 hal hardened howl imap imlib isdnlog jpeg ldap libg++ libwww mad mailwrapper mbox md5sum mikmod mmx motif mp3 mpeg mysql nautilus ncurses nls nntp nptl nptlonly offensive ogg opengl oss pam pcre pdflib perl php pic png pop pppd python qdbm quicktime readline reflection samba session slang smime smtp spell spl ssl tcltk tcpd threads truetype truetype-fonts type1-fonts udev unicode userlocales utf8 vim vim-pager vim-with-x vorbis winbind xml xmms xorg xv zlib elibc_glibc input_devices_keyboard input_devices_mouse kernel_linux linguas_en userland_GNU video_cards_s3 video_cards_vesa video_cards_fbdev"
Unset:  ASFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LDFLAGS, MAKEOPTS
Comment 4 Martin Väth 2006-05-03 14:44:41 UTC
I guess you meant the opposite:
The problem occurs only in the default setting, i.e. if
   set horizontal-scroll-mode On
is *not* present in inputrc.
However, it seems that in horizontal-scroll-mode, the readline library simply needs no information about the "structure" of the prompt except for the total length, therefore it seems the error simply cannot show up in this case.
So it still is possible that it is the bug that bash-3.1 passes the wrong information about the prompt (like position of non-printable characters) to the readline library.
Of course you are right that it also might be a bug in readline itself: This would not contradict the fact that the error occurs with bash-3.1 but not with bash-3.0, because bash has a compiled-in version of the readline library (and therefore the version of readline changes automatically between bash-3.0 and bash-3.1: The CHANGES file in bash-3.1 says that there were some changes in readline).
Comment 5 SpanKY gentoo-dev 2006-05-03 18:37:50 UTC
hack from upstream seems to fix this test case ... i'll pursue this further
Comment 6 SpanKY gentoo-dev 2006-05-05 19:56:17 UTC
ok, upstream will have this fixed in the next version, thanks for the testcase :)