On 7/27/23 10:16 PM, Grisha Levit wrote:
If the `history' builtin is used with no filename argument and the HISTFILE
variable is unset, the Readline default history file ~/.history is used.

It makes sense to use some default filename if the user explicitly asks
for the history to be read or written. Better than silently doing nothing
or (slightly better) warning if HISTFILE is unset.


$ rm -f ~/.history
$ bash -c 'history -s foo; history -w'
$ cat ~/.history
foo

The help text states:

     If FILENAME is given, it is used as the history file.  Otherwise,
     if HISTFILE has a value, that is used, else ~/.bash_history.

So we should change the default filename.

The man and info pages both just state that if no filename supplied then
"the value of HISTFILE is used."

Since Bash normally doesn't perform any history file operations if HISTFILE
is empty or unset, I think it would make sense for `history' to do the same.

What does `normally' mean here? I can see not reading from the history at
startup or not writing to it at shell termination, but in your example the
`history' builtin is being used to explicitly save the history somewhere.

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


Reply via email to