EDIT: the bug disappears by version 4.3.8.I am using GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu). I believe I have found a bug. Would like to know if perhaps I'm missing something or if my bug is version/platform specific.Bash's history functions will utilize the HISTTIMEFORMAT variable, if defined. So ifHISTTIMEFORMAT=%sThen, history produces:60  1460542926 historyAdditionally, history -w results in the history file containing:#1460543065cat $HISTFILE#1460543082HISTTIMEFORMAT=%s#1460543084history -wHowever, if the variable is defined in this way:: ${HISTTIMEFORMAT:=%s }then the output from history is correct, but history -w fails to write the timestamp headers to $HISTFILE.unset HISTTIMEFORMAT: ${HISTTIMEFORMAT:=%s }history -wIf I then simply do export HISTTIMEFORMAT or declare HISTTIMEFORMAT, the problem goes away. However, if the variable is instead auto-exported via set -a, it doesn't work. I could not reproduce this kind of result with a different variable, PS2. From version 4.3.8 running on an Mint 17 / Ubuntu systemMethod 1$ bash --versionGNU bash, version 4.3.8(1)-release (x86_64-pc-linux-gnu)$ bash --norcbash-4.3$ HISTFILE=/tmp/histfile.$$bash-4.3$ history -cbash-4.3$ HISTTIMEFORMAT=%s bash-4.3$ history    1  1460642608 HISTTIMEFORMAT=%s     2  1460642610 historybash-4.3$ history -wbash-4.3$ cat $HISTFILE#1460642608HISTTIMEFORMAT=%s #1460642610history#1460642612history -wbash-4.3$ Method 2$ bash --norcbash-4.3$ HISTFILE=/tmp/histfile.$$bash-4.3$ history -cbash-4.3$ : ${HISTTIMEFORMAT:=%s }bash-4.3$ history    1  1460642758 : ${HISTTIMEFORMAT:=%s }    2  1460642763 historybash-4.3$ history -wbash-4.3$ cat $HISTFILE#1460642758: ${HISTTIMEFORMAT:=%s }#1460642763history#1460642769history -wbash-4.3$ From RHEL6 and RHEL7 systemsincluding GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu) and version 4.1.2(1)-release (x86_64-redhat-linux-gnu)Method 1~$ bash --versionGNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)Copyright (C) 2009 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software; you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.~$ bash --norcbash-4.1$ HISTFILE=/tmp/histfile.$$bash-4.1$ history -cbash-4.1$ HISTTIMEFORMAT=%s bash-4.1$ history -wbash-4.1$ cat $HISTFILE#1460643571HISTTIMEFORMAT=%s #1460643573history -wbash-4.1$ exitMethod 2~$ bash --norcbash-4.1$ HISTFILE=/tmp/histfile.$$bash-4.1$ history -cbash-4.1$ : ${HISTTIMEFORMAT:=%s }bash-4.1$ history -w bash-4.1$ cat $HISTFILE: ${HISTTIMEFORMAT:=%s }history -w bash-4.1$ history3  1460643602 : ${HISTTIMEFORMAT:=%s }4  1460643606 history -w 5  1460643608 cat $HISTFILE6  1460643719 history
have I found a bug in BASH?
bash;bugs
Further research indicates it was a bug and fixed sometime between the 4.2.x and 4.3.6 releases.