Closed mattmc3 closed 1 year ago
Also, I verified that if ZSHZ_DATA is set to a file name with no directory path, the :h
suffix will helpfully return '.'. This will ensure that mkdir -p
succeeds on that edge case.
ZSHZ_DATA=my_z_database
# the h param expansion returns '.' in this case
echo ${ZSHZ_DATA:h}
# mkdir -p won't fail on this edge case
mkdir -p ${ZSHZ_DATA:h}
Thank you for the very clever solution.
I wonder if we should do anything further about the edge case. If I accidentally put in my .zshrc
ZSHZ_DATA=quux
instead of
ZSHZ_DATA=~/quux
Zsh-z will happily create a quux
file in every directory I navigate to. That is literally what I told it to do, but it's presumably never what I want.
I should be able to address this issue early next week.
Zsh-z will happily create a quux file in every directory I navigate to. That is literally what I told it to do, but it's presumably never what I want.
That's a great callout. I pushed another one-liner commit that addresses this:
[[ "${datafile:h}" != '.' ]] || datafile="${ZDOTDIR:-$HOME}/$datafile"
Let me know if how I handled it works for you. It might seem a bit clever, but I think it reads pretty clear that either the basedir isn't '.' (everywhere), or set the dir to where zsh considers home.
Your addition was great. I just merged it to master
. Thanks again!
See #72