bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enabling history timestamps makes old commands show .bash_history mo


From: Chet Ramey
Subject: Re: Enabling history timestamps makes old commands show .bash_history modified timestamp
Date: Mon, 28 Dec 2015 15:08:12 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

On 12/26/15 6:15 PM, james harvey wrote:
> When I turn on timestamps for history, .bash_history records without a
> timestamp (and possibly in-memory records without a timestamp - not
> sure, haven't tested) inherit the modified timestamp of .bash_history
> next time it is read.

No.  History entries always have a timestamp.  By default, the timestamp
is the current time when the entry is added to the history list.  If the
history file doesn't have timestamps, that means entries from the file
get the current time when the file is read.

Now, since you have histappend set, this will never change: your history
will always be appended to the history file and previous entries will
never change (nor acquire a timestamp, obviously).

> This obviously causes old commands to have a much newer date.
> 
> I look at HISTTIMEFORMAT as display formatting only, since it writes
> to .bash_history with since-epoch time.
> 
> My fix would be to log since-epoch timestamps for each command in
> .bash_history, and if someone has default HISTTIMEFORMAT, just not to
> show the timestamps.

This is what setting HISTTIMEFORMAT to the empty string does.  That's how
you indicate you want timestamps in the history file, since not everyone
wants them.

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]