From ef0f2491f306bf6ca59090f9ef68e7f7a8420461 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Fri, 26 Jun 2015 11:38:33 +0200 Subject: [PATCH] Weed out non-existing directories when loading DIRSTACKFILE Between saving our persistent dirstack file and loading it in the next session, directories of which the names we saved might have ceased to exist. This can cause problems, when the first entry from the saved dirstack points to a non-existing directory. Ordinarily, that would not be catastrophic and only lead to an error message while loading the setup. But if you throw auto-mounters into the mix, this can cause the setup to hang until the auto-mounter runs into a timeout. The proposed fix is to filter out names of non-existing directories while loading the saved dirstack file. This leaves the window between loading the file and trying to change to the first then-existing directory of the file open for the directory to vanish. That would be tough luck, I guess. Reported-by: Till Hofmann Signed-off-by: Frank Terbeck --- etc/zsh/zshrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index e88ba04..d4978e4 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -1620,7 +1620,9 @@ DIRSTACKSIZE=${DIRSTACKSIZE:-20} DIRSTACKFILE=${DIRSTACKFILE:-${ZDOTDIR:-${HOME}}/.zdirs} if [[ -f ${DIRSTACKFILE} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then - dirstack=( ${(f)"$(< $DIRSTACKFILE)"} ) + # Enabling NULL_GLOB via (N) weeds out any non-existing + # directories from the saved dir-stack file. + dirstack=( ${(f)"$(< $DIRSTACKFILE)"}(N) ) # "cd -" won't work after login by just setting $OLDPWD, so [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD fi -- 2.1.4