[colug-432] bash history broken
Rick Hornsby
richardjhornsby at gmail.com
Wed Dec 28 17:38:51 EST 2011
Having some trouble with bash history navigation. When using the up
arrow to scroll back through the history, sometimes it doesn't
correctly erase. To display the next entry, and the position of the
cursor gets munged. Instead of erasing the whole command, it erases
most of it, and then starts writing the new command onto the line.
The result is that as you scroll through the history you end up with a
mess that looks like this:
[root at myhost conf]# diff -u /opdiff -u /opt/tomcat/conf/server.xml server.xml
If I keep scrolling, the first "diff -u /op" stays put and won't go away.
If I backspace as far as I can, my cursor stops after the 'p' in the
first "/op". I can type in a command and get a valid result, like so
[root at myhost conf]# diff -u /opls
catalina.policy catalina.properties context.xml logging.properties
server.xml tomcat-users.xml web.xml
It seems to be consistent in the sense that if I ctrl-c the line, I
get back to a normal prompt but as soon as I hit that particular line
in the history, it goes whacky again.
I thought I found something where the prompt coloring was being done
in a really weird way (using expansion of tput commands), but I fixed
that and no luck. I just figured out that if I set PS1="# ", I can
make the problem go away. As soon as I reset PS1 using source
~/.bash_profile, the problem comes back.
Is there something about this PS1 that seems it could cause the
behavior described?
PS1='[\u@\e[0;36m\h\e[0m \W]# '
I found this http://jongartman.tumblr.com/post/5049206374/term-ps1-and-bash-history,
but changing the TERM from xterm to xterm-color, linux, or ansi
doesn't seem to help. I'm pretty sure it is something to do with the
color handling of PS1, but I posted the rest of the output from set
below just in case.
thanks!
-rick
[root at myhost conf]# set
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="25" [3]="1" [4]="release"
[5]="x86_64-redhat-linux-gnu")
BASH_VERSION='3.2.25(1)-release'
COLORS=/etc/DIR_COLORS.xterm
COLUMNS=156
DIRSTACK=()
DISPLAY=localhost:10.0
EUID=0
GROUPS=()
G_BROKEN_FILENAMES=1
HISTFILE=/root/.bash_history
HISTFILESIZE=5000
HISTSIZE=500
HISTTIMEFORMAT='%F %T '
HOME=/root
HOSTNAME=myhost.mydomain.com
HOSTTYPE=x86_64
IFS=$' \t\n'
INPUTRC=/etc/inputrc
LANG=en_US.UTF-8
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=64
LOGNAME=root
LS_COLORS='no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:'
MACHTYPE=x86_64-redhat-linux-gnu
MAIL=/var/spool/mail/root
MAILCHECK=60
OLDPWD=/root/apache-tomcat-7.0.22
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
PIPESTATUS=([0]="0" [1]="0")
PPID=18650
PROMPT_COMMAND='echo -ne
"\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
PS1='[\u@\e[0;36m\h\e[0m \W]# '
PS2='> '
PS4='$0,$LINENO+ '
PWD=/root/apache-tomcat-7.0.22/conf
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:interactive-comments:monitor
SHLVL=1
SSH_CLIENT='x.x.x.x 54559 22'
SSH_CONNECTION='x.x.x.x 54559 x.x.x.x 22'
SSH_TTY=/dev/pts/0
TERM=xterm
TRV=$'\E[7m'
TRVF=$'\E[27m'
UID=0
USER=root
_=
consoletype=pty
tmpid=0
More information about the colug-432
mailing list