Hi,
I also encountered this issue that my '~/.bash_history' was always
truncated to 2000 lines despite myself having set 'HISTSIZE' and
'HISTFILESIZE' to larger values in my '~/.bash_aliases' and it took me a
while to find out what was going on.
In fact, 'HISTFILESIZE=2000' is set in '/etc/skel/.bashrc', which is
shipped by the Debian package, so the '~/.bashrc' file created from that
skeleton file contains that line for every user by default.
The corresponding changelog entry for version 4.2-1 (November 2011)
where those lines were added is the following
find the current sitation unfortunate, since it not only sets the value
for the environment variable, but immediately truncates the bash history
file, '~/.bash_history'.
Setting a value for HISTFILESIZE in the skel file therefore effectively
makes it impossible for users to simply override that value by setting
it to another value in '~/.bash_aliases' (which is sourced in
'~/.bashrc' as provided by the skeleton file), which in my understanding
is usually regarded as the recommended way to set user-specific values.
Thus, users would have to edit '~/.bashrc' in addition (and know that
this is needed, which is probably rather unexpected for most users).
The issue of truncation by setting HISTFILESIZE is easily demonstrated
by the following commands:
$ rm ~/.bash_history
$ for i in {1..2000}; do echo "echo $i" >> ~/.bash_history ; done
$ wc -l ~/.bash_history
2000 /home/michi/.bash_history
$ HISTFILESIZE=1000
$ wc -l ~/.bash_history
1000 /home/michi/.bash_history
$ HISTFILESIZE=500
$ wc -l ~/.bash_history
500 /home/michi/.bash_history
Apparently, setting HISTFILESIZE to a larger value later (which a user
might do in ~/.bash_aliases) does not bring back the deleted entries:
$ HISTFILESIZE=5000
$ wc -l ~/.bash_history
500 /home/michi/.bash_history
To avoid this and allow the user to simply set the desired history
length via environment variable in '~/.bash_aliases', I would recommend
to only set the 'HISTSIZE' variable, which is what 'HISTFILESIZE'
defaults to when not set explicitly.
From bash's man page:
By setting 'HISTSIZE' to 2000 and not setting HISTFILESIZE in the
skeleton file, the default size of the history file remains 2000 lines,
but it can easily be overriden by users.
I have attached a patch that does this and would be thankful if such a
change were considered.
Regards,
Michael