Red Hat Bugzilla – Bug 8458
/etc/profile shouldn't set HISTFILESIZE
Last modified: 2014-03-16 22:12:06 EDT
In setup-2.0.5-1 (on i386 for certain, and probably on all architectures),
...and then exports both variables.
The very act of setting HISTFILESIZE causes bash to run out and truncate
the history file. The truncation occurs at the instant HISTFILESIZE is
set. Therefore, attempting to set a higher value for HISTFILESIZE in one's
...is useless, because the history file has already been truncated by
/etc/profile before ~/.bash_profile is even sourced.
Fortunately, every version of bash I've ever seen has a feature that is
useful here: for interactive shells, after the sourcing of initialization
files has been completed, if HISTFILESIZE is not set, bash will
automatically initialize HISTFILESIZE to the value of HISTSIZE and perform
any required history file truncation. (See the beginning of the
load_history() function in bashhist.c.)
Unfortunately, this behavior isn't documented, but its presence leads to an
elegant solution: in /etc/profile, set and export a default HISTSIZE, but
don't set HISTFILESIZE. This allows users full freedom to set either
HISTSIZE or HISTFILESIZE in their ~/.bash_profile files. If they don't
explicitly set HISTFILESIZE, it will be automatically set to whatever they
set HISTSIZE to; if they don't set HISTSIZE, then HISTFILESIZE will
automatically inherit the same value that /etc/profile sets for HISTSIZE.
Fixed in CVS, will be fixed in setup-2.1.0 release.