On 3/25/15 3:02 PM, Christoph Anton Mitterer wrote:
> On Wed, 2015-03-25 at 14:48 -0400, Chet Ramey wrote: 
>> The history file truncation code already skips lines that look like history
>> timestamps.  Look at history.c:history_truncate_file().
> Ah? Hmm was that only recently introduced?
> I'm having bash4.3 with patches up to including 33. And this time I
> looked whether Debian added any of it's goodness ;-)
> 
> 
> When I set e.g. in .bashrc:
> HISTSIZE=50
> HISTFILESIZE=50
> HISTTIMEFORMAT=$'%c\t'

Here's what happens.  The history timestamp code depends on the setting of
the history `comment character' -- that's the `#' that it uses to denote
the start of a timestamp entry.  The history comment character disables
history expansion for every subsequent character on a line.

When you start bash, and source your .bashrc, the history comment character
is not set.  You haven't set it in .bashrc, I assume, and it doesn't
acquire its default value until later on in the interactive shell
initialization process.  Since that's not set, the lines beginning with
`#[digit]' are not recognized as timestamps and treated as ordinary history
entries.

You can fix this by assigning to histchars before setting HISTFILESIZE:

histchars='!^#'

Those are the defaults.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to