[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bash-bug
Subject:    Re: Enabling history timestamps makes old commands show .bash_history modified timestamp
From:       Chet Ramey <chet.ramey () case ! edu>
Date:       2015-12-28 20:08:12
Message-ID: 568196AC.30208 () case ! edu
[Download RAW message or body]

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/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic