Bug 8458 - /etc/profile shouldn't set HISTFILESIZE
Summary: /etc/profile shouldn't set HISTFILESIZE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: setup
Version: 6.1
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2000-01-13 23:00 UTC by James Ralston
Modified: 2014-03-17 02:12 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2000-01-13 23:37:38 UTC

Attachments (Terms of Use)

Description James Ralston 2000-01-13 23:00:42 UTC
In setup-2.0.5-1 (on i386 for certain, and probably on all architectures),
/etc/profile says:


...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

    export HISTSIZE=5000
    export HISTFILESIZE=5000

...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.

Comment 1 Bill Nottingham 2000-01-13 23:37:59 UTC
Fixed in CVS, will be fixed in setup-2.1.0 release.

Note You need to log in before you can comment on or make changes to this bug.