zshrc: Do not use bogus array index `0' in dirstack code [Closes: issue1055]
[grml-etc-core.git] / etc / zsh / zshrc
index a34b170..f5088f6 100644 (file)
@@ -1077,7 +1077,7 @@ DIRSTACKFILE=${DIRSTACKFILE:-${HOME}/.zdirs}
 if [[ -f ${DIRSTACKFILE} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
     dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
     # "cd -" won't work after login by just setting $OLDPWD, so
-    [[ -d $dirstack[0] ]] && cd $dirstack[0] && cd $OLDPWD
+    [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
 fi
 
 chpwd() {
@@ -2786,12 +2786,12 @@ fir() {
 }
 # smart cd function, allows switching to /etc when running 'cd /etc/fstab'
 cd() {
-    if [[ -f ${1} ]]; then
+    if (( ${#argv} == 1 )) && [[ -f ${1} ]]; then
         [[ ! -e ${1:h} ]] && return 1
         print "Correcting ${1} to ${1:h}"
         builtin cd ${1:h}
     else
-        builtin cd ${1}
+        builtin cd "$@"
     fi
 }