Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 171825 - app-shells/bash-3.2: history problems in vi mode
Summary: app-shells/bash-3.2: history problems in vi mode
Status: RESOLVED FIXED
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
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-22 17:22 UTC by Daniel Gryniewicz (RETIRED)
Modified: 2012-11-20 16:37 UTC (History)
0 users

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 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-03-22 17:22:28 UTC
In all bash 3.2 versions I've tried so far, there's a problem with vi history editing.  If you hit escape and k to go up, the cursor is offset in the line by the width of the prompt.  No amount of line redrawing can fix this, and when you exit back to the prompt, the portion that was offset is still there on the line. bash-3.1_p17 doesn't have this problem.
Comment 1 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-03-23 01:40:48 UTC
Jakub: What does this have to do with vim?  It's a bash issue, and shows up if vim isn't even installed.
Comment 2 Mike Kelly (RETIRED) gentoo-dev 2007-03-23 03:43:57 UTC
Uh, yeah... this is totally not related to vi/vim. It's a set of key bindings for readline. So, this is a bash/readline problem.

Re-assigning to base-system.
Comment 3 Peter Volkov (RETIRED) gentoo-dev 2007-03-23 06:11:47 UTC
Daniel, do you have colour prompt? Then this could be related bug 155369 ...
Comment 4 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-03-23 15:15:43 UTC
I do, indeed, have a color prompt.  My prompt is:

PS1="^[[32;1m[\t \h] ^[[34;1m\W^[[0m> "

However, I have a ~amd64 system, so I have those fixes versions already. I have sys-libs/readline-5.2_p2, and I still had the problem with app-shells/bash-3.2_p15 (although I don't appear to have put 3.2_p10-r1 into my package.mask, so maybe that one worked?  I'll emerge it and try...)
Comment 5 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-03-23 15:16:57 UTC
Nope, 3.2_p10-r1 still exhibits the same problem...
Comment 6 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-05-04 20:32:23 UTC
3.2_p17 still has the problem.
Comment 7 Peter Volkov (RETIRED) gentoo-dev 2007-05-05 15:08:20 UTC
Daniel, could you please describe the problem another time? Just explain steps you do and what goes wrong? Personally, I do not see anything unusual.
Comment 8 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-05-05 19:27:26 UTC
Sure.  Here's what I do:

[15:19:55 athena] ~> ls evolution-2.11.1-more-64-bit.patch evolution-2.9.91-cal-reply.patch

(That's all one one line).  It doesn't matter what the command is; any command that results in more than 80 char on the screen, ie that causes the line to scroll with "<" on the left side, is sufficient.

Then, after the command is run, I hit <esc>k to go up one line into history.  The cursor is somewhere in the middle of the line, but it think's it's at the beginning.  The line does not redraw correctly, even with <ctrl>-l.  As I move the cursor right and left, it updates the character under the cursor, but it reverts to the wrong one after any kind of redraw.  This makes command line history completely useless to use.  If this isn't clear enough, I can try to make a screencast of the problem...

My .profile sets these related settings:
shopt -s histappend
export HISTCONTROL="erasedups"
PS1="^[[32;1m[\t \h] ^[[34;1m\W^[[0m> "
set -o vi

I have bash-completion enabled.  My .inputrc contains this:
set horizontal-scroll-mode On
set editing-mode vi
set completion-ignore-case On

bash 2 is fine; bash 3.0.x is fine.  bash 3.1 had the problem briefly (p8 and p10 failed) but 3.1_p17 is fine, and what I'm using now.  bash 3.2.x all have the problem.  I've tried p9 p9-r1 p10 p10-r1 p15 p15-r1 p17, all of which fail.  I have readline-5.2_p4.

Portage 2.1.2.5 (default-linux/amd64/2006.1/desktop, gcc-4.1.2, glibc-2.5-r2, 2.6.21-ck1-rc2 x86_64)
=================================================================
System uname: 2.6.21-ck1-rc2 x86_64 Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz
Gentoo Base System release 1.12.10
Timestamp of tree: Unknown
ccache version 2.4 [enabled]
dev-lang/python:     2.4.4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r7
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.61
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.16
sys-devel/libtool:   1.5.23b
virtual/os-headers:  2.6.21
ACCEPT_KEYWORDS="amd64 ~amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=nocona -pipe -ggdb -Wstrict-aliasing -Wreturn-type -Wimplicit -Wformat"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/rc.d /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/wget"
CXXFLAGS="-O2 -march=nocona -pipe -ggdb -Wstrict-aliasing -Wreturn-type -Wimplicit -Wformat"
DISTDIR="/home/portage/distfiles"
FEATURES="ccache collision-protect cvs distlocks installsources metadata-transfer multilib-strict sandbox sfperms sign splitdebug strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LANG="en_US.utf8"
LDFLAGS="-Wl,--as-needed"
LINGUAS="en en_US pq"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
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 --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/home/portage"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/home/portage/overlays/gnome /home/portage/overlays/uml-overlay /home/portage/overlays/dang.overlays/user /home/portage/overlays/dang.overlays/maintainer /home/portage/overlays/sunrise /home/portage/overlays/gentopia /home/portage/overlays/local"
SYNC="rsync://dang.nexthop.com/gentoo-portage"
USE="X aac aalib accessibility acpi alsa amd64 apache2 artworkextra avahi avi bash-completion berkdb bitmap-fonts branding bzip2 cairo cdr cli cracklib crypt cscope cups db2 dbus dga divx4linux dri dvd dvdr eds emboss encode ethereal evo exif fam firefox flac font-server foomaticdb gd gdbm gif gimpprint gnome gnutls gphoto2 gstreamer gtk gtk2 guile hal howl iconv imagemagick imap imlib ipv6 isdnlog jabber jpeg keyring ldap libg++ libnotify libwww logrotate lzo lzw mad matroska midi mikmod mime mmap mng mono mozilla mp3 mpeg mpi ncurses nls nptl nptlonly offensive ogg opengl oscar oss pam pcre pda pdflib perl png ppds pppd python qemu-fast quicktime readline reflection rtc samba sdl session sharedmem slang slp smime soap softmmu speex spell spl sqlite sse3 ssl svg tcpd theora tiff tracker truetype truetype-fonts type1-fonts unicode usb vorbis wifi wmf xface xml xml2 xorg xsl xulrunner xv xvid zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="evdev keyboard mouse synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_US pq" USERLAND="GNU" VIDEO_CARDS="i810 vesa"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS


Comment 9 Peter Volkov (RETIRED) gentoo-dev 2007-05-06 07:50:42 UTC
Daniel, can you reproduce your problem with horizontal-scroll-mode off?

Also do you have \[  \] around color specifiers in your PS1? Try this (I've substituted ^[ with \033 (so you can just cut and paste) and putted \[ \] around colors) :
PS1="\[\033[32;1m\][\t \h] \[\033[34;1m\]\W\[\033[0m\]> "
Comment 10 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-05-06 16:36:26 UTC
horizontal-scroll-mode seems to make no difference; with it on or off, all of my investigation below was the same.

In addition, I tried both with and without vi history mode, and I had similar (although not identical, because emacs mode positions the cursor at the end of the line, while vi mode positions it at the beginning of the line) problems with both.

No, actual information.

That prompt is actually worse.  I get the same problem (both with horizontal-scroll-mode on and off), but the cursor is over the first : in the time, not on the end of the line like with my normal prompt:

[12:04:54 athena] ~>
   ^
Cursor is here.

It does, however, seem to be prompt related, because the default prompt doesn't cause this problem, just my prompt.

Okay, a litte more investigation.  My original prompt, with \t changed to \A still causes the problem.  The stock gentoo prompt, with \u changed to \t causes the problem; however, with \u changed to \A, there is no problem.  My original prompt with \t changed to \A *does* cause the problem.

Here's a prompt that works:
PS1='\[\033[01;32m\]\A \h\[\033[01;34m\] \w \[\033[00m\]> '

Here's one that fails:
PS1='\[\033[01;32m\]\t \h\[\033[01;34m\] \w \[\033[00m\]> '

Just for fun, I tried \D.  Using seconds fails:
PS1='\[\033[01;32m\]\D{%H:%M%S} \h\[\033[01;34m\] \w \[\033[00m\]> '
But using no seconds succeeds:
PS1='\[\033[01;32m\]\D{%H:%M} \h\[\033[01;34m\] \w \[\033[00m\]> '

Interestingly, by accident, I typoed the prompt, and this works fine:
PS1='\[\033[01;32m\]\D{%H:%M%S} \h\[\033[01;34m\] \W \[\033[00m\]> '
(note the lack of : between %M and %S)  Adding that : back in causes failure.

For now, I'm using the prompt that works above, but I'd like to have my seconds back on the display.

One final thing:  I'm using gnome-terminal as my terminal, with vte-0.16.3 as it's renderer.  I tried several combinations with xterm, as well, and xterm fails for any prompt I tried with time in it, even the ones that worked with gnome-terminal, so there is some terminal component involved.
Comment 11 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-05-06 23:01:34 UTC
Update:  I was wrong; the prompts marked "working" don't actually work all the time.  They work fine in my homedir, where the path is "~", but as soon as I change directories, they start failing again.  So, it's back to 3.1_p17 for me.
Comment 12 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-10-19 13:39:29 UTC
I suddenly need a solution to this; sys-apps/portage-2.1.3.15 needs >=app-shells/bash-3.2_p17, and both p17 and p17-r1 are broken.  I'd highly prefer not to lose my timestamps in my prompts.
Comment 13 Daniel Gryniewicz (RETIRED) gentoo-dev 2007-11-10 20:18:14 UTC
I've found a version of the prompt that works.  Basically, you have to set the color before and after the time, or the display is messed up.  Here's my working prompt:

COLOR1=34
COLOR2=31
PCOLOR1="\[\033[1;${COLOR1}m\]"
PCOLOR2="\[\033[1;${COLOR2}m\]"
PCOLORN="\[\033[0m\]"
PS1="${PCOLOR1}[${PCOLOR1}\A${PCOLOR1}\
${PCOLOR1} ${PCOLOR1}\h${PCOLOR1}]\
 ${PCOLOR2}\W\
${PCOLORN}>${PCOLORN} "
Comment 14 SpanKY gentoo-dev 2012-11-05 16:17:58 UTC
still a problem with 4.2 ?
Comment 15 Daniel Gryniewicz (RETIRED) gentoo-dev 2012-11-20 16:28:48 UTC
No longer a problem with 4.2.  This can be closed, as far as I'm concerned.