Discussion:
bash history buffer output mangled after repeated up-arrow
(too old to reply)
t***@zyxst.net
2018-04-25 14:26:06 UTC
Permalink
hi,

I've noticed now, for a while (like maybe over a year) that if you're in
bash shell, hitting up-arrow (which usually loads history -1) multiple
times will result in part of history becoming the prompt.

I use csh as login shell now because csh doesn't have this problem.

I can re-create the issue by logging in then doing the following:
% bash
$ . .profile
hit uparrow a few times (in this case, 15 times), it gets to this in its
history:
bzcat /var/log/messages.1.bz2 |less

prompt is now:
[***@desktop ~]$ bzcat /var<--cursor is here waiting for input

[keep hitting up arrow]
now it's [***@desktop ~]$ ls -lah .g[history] where [history] is
find /usr/src/sys/sys/param.h -mtime; echo

backspacing to (in this case) [***@desktop ~]$ ls -lah .g (which is as
far as one can backspace on that line) and hitting return, restored the
normal prompt position. Repeatedly hitting up-arrow mangles bash
history.

it doesn't happen in csh. Not tried other shells. It only happens on
freebsd boxes (11-stable and later). I've not seen it happen on linuxen
(raspabian, mint, ubuntu, centos). It doesn't matter if bash is built from
source or installed via pkg. Doesn't matter if fdescfs is mounted or not.
It still happens if I create a fresh freebsd-11-stable VM, log into it,
install bash.

Any ideas?
thanks,
--
J.
Lowell Gilbert
2018-04-25 18:10:57 UTC
Permalink
Post by t***@zyxst.net
hi,
I've noticed now, for a while (like maybe over a year) that if you're in
bash shell, hitting up-arrow (which usually loads history -1) multiple
times will result in part of history becoming the prompt.
I use csh as login shell now because csh doesn't have this problem.
% bash
$ . .profile
hit uparrow a few times (in this case, 15 times), it gets to this in its
bzcat /var/log/messages.1.bz2 |less
[keep hitting up arrow]
/usr/src/sys/sys/param.h -mtime; echo
far as one can backspace on that line) and hitting return, restored
the normal prompt position. Repeatedly hitting up-arrow mangles bash
history.
it doesn't happen in csh. Not tried other shells. It only happens on
freebsd boxes (11-stable and later). I've not seen it happen on
linuxen (raspabian, mint, ubuntu, centos). It doesn't matter if bash
is built from source or installed via pkg. Doesn't matter if fdescfs
is mounted or not.
It still happens if I create a fresh freebsd-11-stable VM, log into it,
install bash.
Any ideas?
It doesn't happen to me.

Maybe you've got something weird in your .profile?
Tim Daneliuk
2018-04-25 19:38:28 UTC
Permalink
Post by Lowell Gilbert
Post by t***@zyxst.net
Any ideas?
It doesn't happen to me.
Maybe you've got something weird in your .profile?
Agreed. Remove your .bash_history, .profile and .bashrc files temporarily and see if the
problem changes or goes away.
--
----------------------------------------------------------------------------
Tim Daneliuk ***@tundraware.com
PGP Key: http://www.tundraware.com/PGP/
tech-lists
2018-04-26 16:55:15 UTC
Permalink
Post by Tim Daneliuk
Post by Lowell Gilbert
Post by t***@zyxst.net
Any ideas?
It doesn't happen to me.
Maybe you've got something weird in your .profile?
Agreed. Remove your .bash_history, .profile and .bashrc files temporarily and see if the
problem changes or goes away.
hm, why didn't I think of that?! lol ok, thanks, am trying this.

I thought I might have something broken in ttys or xterm. Haven't
noticed it yet (but that doesn't mean it wasn't happening, just that I
didn't notice) in a non-X console. It does happen in screen.

thanks,
--
J.
Garance A Drosehn
2018-04-26 01:05:26 UTC
Permalink
Post by t***@zyxst.net
hi,
I've noticed now, for a while (like maybe over a year) that if you're in
bash shell, hitting up-arrow (which usually loads history -1) multiple
times will result in part of history becoming the prompt.
When I've seen this, it has been because:

1) bash thought the width of the current window had a different
number of columns than it actually has.
or
2) the variable $PS1 is set to some custom value, and that value
includes some characters use up either more or less than one
column-width.

In my case, case #2 happens when I'm playing games to set specific
colors in my prompt. So, for instance, my PS1 includes the string
'\e[1;34;47m' which sets the color of both the background and the
text. However, all those characters will use up zero columns when
displayed. Bash needs to know that all those characters use up
zero columns, so those characters need to be surrounded by '\['
and '\]'. Thus the string really needs to be: '\[\e[1;34;47m\]'

I think there are some other 'tty' settings which can also cause
the behavior that you're seeing, but I don't remember which ones.
--
Garance Alistair Drosehn = ***@rpi.edu
Senior Systems Programmer or ***@FreeBSD.org
Rensselaer Polytechnic Institute; Troy, NY; USA
@lbutlr
2018-04-26 11:59:51 UTC
Permalink
far as one can backspace on that line) and hitting return, restored the normal prompt position. Repeatedly hitting up-arrow mangles bash
history.
Are you using social characters, color codes, or other stuff in your prompt? What's the definition of your PS1 look like?
--
"If this is the best God can do, I'm not impressed."
@lbutlr
2018-04-26 12:01:21 UTC
Permalink
Post by @lbutlr
Are you using social characters
Sigh. SPECIAL characters.
--
And the three men I admire most, the father son and the holly ghost they
caught the last train for the coast...
Loading...