Bug 697528

Summary: HISTTIMEFORMAT variable does not work the way it is described in the bash man page
Product: Red Hat Enterprise Linux 5 Reporter: Jason Corley <jason.corley>
Component: bashAssignee: Roman Rakus <rrakus>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.6CC: prc, tsmetana
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-21 12:37:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jason Corley 2011-04-18 14:21:59 UTC
Description of problem:
The bash man page says the following about the variable HISTTIMEFORMAT:

HISTTIMEFORMAT
      If  this  variable  is  set and not null, its value is used as a
      format string for strftime(3) to print the time stamp associated
      with  each  history  entry displayed by the history builtin.  If
      this variable is set, time stamps are  written  to  the  history
      file so they may be preserved across shell sessions.

However no matter what strftime(3) string you use, or even if you use the number 1, you will always get unix epoch time.

Steps to Reproduce:
1. create /etc/profile.d/bash_history.sh with the following contents:
HISTTIMEFORMAT="%Y%m%d_%H:%M:%S"
export HISTTIMEFORMAT
2. log out, log back in
3. run some commands
4. log out, log back in, and check the format of the commented # lines in ~/.bash_history
5. change the variable to whatever format you want (including any non-zero number) and verify no change in logging
 
Actual results:
Time string is always in unix epoch time.

Expected results:
Time string logged should be in the strftime(3) format specified by the HISTTIMEFORMAT variable.

Comment 1 Roman Rakus 2011-04-18 14:57:27 UTC
HISTTIMEFORMAT works with `history' builtin. What does `history' shows you when you set up HISTTIMEFORMAT variable?

Comment 2 Jason Corley 2011-04-20 19:04:54 UTC
ah ok, so the format in the history file is always in epoch time, it's just the env var modifies the display. totally read that wrong. I guess this can be closed, history works as expected.