Fixes https://github.com/Tarrasch/zsh-autoenv/issues/77.
if \grep -qE '\b(autostash|autounstash|stash|unstash)\b' $autoenv_env_file; then
source ${${funcsourcetrace[1]%:*}:h}/lib/varstash
fi
if \grep -qE '\b(autostash|autounstash|stash|unstash)\b' $autoenv_env_file; then
source ${${funcsourcetrace[1]%:*}:h}/lib/varstash
fi
- # NOTE: Varstash uses $PWD as default for varstash_dir, we might set it to
- # ${autoenv_env_file:h}.
fi
# Source the env file.
fi
# Source the env file.
restore_xtrace=1
setopt localoptions xtrace
fi
restore_xtrace=1
setopt localoptions xtrace
fi
- source $autoenv_env_file
+
+ varstash_dir=${autoenv_env_file:h} source $autoenv_env_file
if (( restore_xtrace )); then
setopt noxtrace
fi
if (( restore_xtrace )); then
setopt noxtrace
fi
$ echo 'echo ENTER; stash FOO=changed' >| sub/$AUTOENV_FILE_ENTER
$ echo 'echo LEAVE; unstash FOO' >| sub/$AUTOENV_FILE_LEAVE
$ test_autoenv_auth_env_files sub
$ echo 'echo ENTER; stash FOO=changed' >| sub/$AUTOENV_FILE_ENTER
$ echo 'echo LEAVE; unstash FOO' >| sub/$AUTOENV_FILE_LEAVE
$ test_autoenv_auth_env_files sub
Activating the env stashes it and applies a new value.
Activating the env stashes it and applies a new value.
ENTER
$ echo $FOO
changed
Leaving the directory unstashes it (varstash_dir is set to prev dir).
ENTER
$ echo $FOO
changed
Leaving the directory unstashes it (varstash_dir is set to prev dir).