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

An easy, light and scriptable solution that solves 99% of all cases has
already been hinted at:

export HISTDIR=foo
mkdir -p $HISTDIR || echo 'Woe is me!'

I'm sorry, but how does it solve 99% of all cases?  There are two cases:

1.  $HISTFILE:h exists when writing $HISTFILE
2.  $HISTFILE:h does not exist when writing $HISTFILE

The above solution makes case 1 more likely, sure, but it doesn't solve case 2.

I think that the proposed code to create directories violates the principle of least surprise, and should not be included in the standard zsh distribution. 

The reality is that in 99.99% of cases $HISTFILE:h is going to be someone's home directory.  If that doesn't exist you're pretty much screwed anyway.

Then in the 0.01% of cases where people put their $HISTFILE elsewhere, the code above, placed in their .zshenv file will work 99.99% of the time.

So I'd say that 99.9999% of cases are covered.

In other words, it's a one in a million thing.

Duncan Sinclair  |  {+44|0}141 548 3095  |  cis.strath.ac.uk
System Administrator
Computer and Information Sciences
University of Strathclyde

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