Incorrect commandline history with bash

Jeremy Chadwick koitsu at
Sat Sep 20 21:42:15 UTC 2008

On Sat, Sep 20, 2008 at 11:18:34PM +0530, manish jain wrote:
> I just migrated from Linux and I am now using FreeBSD 6.3. My keyboard
> layout is US-ISO and my TERM is con25. I am using bash#3 as my login shell.
> (I installed the bash package from the distribution media, not from
> /usr/ports).
> The problem is that bash does not remember my commands correctly. Almost all
> commands I enter in a login session are forgotten in the next session. Using
> the Up and Down arrow keys navigates a mangled and incomlete command
> history. Even using Ctrl-r for a reverse find almost never fetches a command
> I had actually typed in previously.
> The following are the contents of my .bash_profile and .bashrc:
> #.bash_profile :
> [ -f ~/.bashrc ] && source ~/.bashrc
> #end-of-file

You have this backwards.  ~/.bashrc should contain something like this:

if [ -f "${HOME}/.bash_profile" ]
  source "${HOME}/.bash_profile"

And all of your applicable environment settings should go in
.bash_profile.  This probably won't solve your problem, but I thought
I'd point it out.

> #.bashrc :
> export HISTFILESIZE=200
> shopt -s cmdhist
> shopt -s histappend
> #end-of-file

I set none of these things (though I do use export HISTTIMEFORMAT="%T  "
but that should not affect your problem) and my .bash_history always
contains commands from past sessions, including timestamps too.

My options are defaults:

$ shopt | egrep 'cmdhist|histappend'
cmdhist         on
histappend      off

Can you please try pkg_delete'ing the bash you installed from the
installation media, and instead update your ports tree via csup (not
cvsup) and then build/install bash from /usr/ports/shells/bash?

Finally, please do not cross-post to multiple lists.  It's shunned upon,
and generally pointless as not everyone is subscribed to both lists.
I've removed freebsd-questions at, as this could be a ports
issue rather than a generic question.

| Jeremy Chadwick                                jdc at |
| Parodius Networking              |
| UNIX Systems Administrator                  Mountain View, CA, USA |
| Making life hard for others since 1977.              PGP: 4BD6C0CB |

More information about the freebsd-ports mailing list