Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: reading/saving history file dependent on isset(RCS)

>>>>> On October 20, 2011 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:

> There isn't a default setting for HISTFILE, so if no startup files are
> read there's no way for the shell to know what history file to read.
> That's not "conditioned on" the option, it's just a side-effect.

But it's not just a side-effect; the call to readhistfile() is
actually conditioned on 'isset(RCS)', so if my .zshenv sets HISTFILE
and also 'setopt norcs', it does not read my HISTFILE.

Based on there being no default setting for HISTFILE, can the
isset(RCS) check can be safely removed for the readhistfile() call?

> I'm pretty sure that the reasoning is that if the shell didn't read the
> history file in the first place (which it could not possibly have, see
> above) then it's likely to destroy information if it writes the file
> on exit.  So the user has to deliberately clear the option if he wants
> the shell to behave like one that started up with the option off.

Likewise, if there is no default setting of HISTFILE, can we safely
remove the isset(RCS) checks for the savehistfile() calls?

It seems useful to consider two cases:

1. NORCS gets set from the command line (zsh -f): in this case
   HISTFILE is not set, and the isset(RCS) checks are superfluous.

2. NORCS gets set from some startup file, to inhibit later startup
   files from loading: in this case, if you've set HISTFILE, it seems
   reasonable to honor it for both reading and writing the history.

The argument about not clobbering a file that was not read in the
first place only holds if the shell brokenly decided not to read the
file that was requested via the user having set HISTFILE.


Messages sorted by: Reverse Date, Date, Thread, Author