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

Re: Failing to write to history file if containing directory doesn't exist



On 10/8/07, Matthew Wozniski <godlygeek@xxxxxxxxx> wrote:

> On Mon, Oct 08, 2007 at 05:30:08PM +0200, Nikolai Weibull wrote:

> > And what if the directory gets deleted between the time HISTFILE is
> > set and the shell exits?

> The only way that should ever happen is if the user removed (or moved)
> the directory himself.  If that's the case, the shell should certainly
> not recreate a directory that the user intentionally deleted, each and
> every time the history is updated.  That would make it impossible for
> a user with HISTFILE=~/.zsh/history to do something as simple as:
>
> % mv .zsh .zsh-4.3.4
> % ln -s .zsh-4.3.4 .zsh
>
> without first unsetting and later setting HISTFILE, since the
> directory would be recreated between the two commands.

Only under the condition that HISTFILE is written to between the two commands.

> > I'd rather err on the side of a more intelligent, "work hard for the
> > user"-type shell that doesn't let my data disappear out into oblivion
> > without doing its best to keep said data around.

> But really, you're talking about recreating a directory that was just
> deleted.  In this case we really ought to err on the principle of
> least surprise.  After all, that directory didn't just get up and walk
> away, someone had to delete it.  ;)

What if someone figured that it'd be easier to

% rm -r ~/.local/var/zsh

than to

% rm ~/.local/var/zsh/history

(if, for example, ~/.local/var/zsh contains other transient data to be removed).

I still want to play a "don't lose data without trying to save it"
card, but it seems I'm the only one playing cards of that suite.



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