Weed out non-existing directories when loading DIRSTACKFILE
[grml-etc-core.git] / etc / zsh / zshrc
index e88ba04..d4978e4 100644 (file)
@@ -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