autoenv.zsh | 5 ++--- tests/varstash-unstash-on-leave.t | 6 +++--- diff --git a/autoenv.zsh b/autoenv.zsh index 2deac546596dda7728b1934d1602bcf39ffbbd5d..5395e1f9405fc1f43e794d41c45cd27723bebd81 100644 --- a/autoenv.zsh +++ b/autoenv.zsh @@ -293,8 +293,6 @@ if ! (( $+functions[autostash] )); then 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. @@ -306,7 +304,8 @@ if [[ $AUTOENV_DEBUG -gt 2 && ! -o xtrace ]]; then 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 diff --git a/tests/varstash-unstash-on-leave.t b/tests/varstash-unstash-on-leave.t index bfea2bf272beaa56bca184abd3ac4ffc1521e23d..c5cc125e1cbdb843a59f727f00d4151fd214248d 100644 --- a/tests/varstash-unstash-on-leave.t +++ b/tests/varstash-unstash-on-leave.t @@ -4,7 +4,7 @@ $ source $TESTDIR/setup.zsh || return 1 Setup test environment. - $ mkdir sub + $ mkdir -p sub/sub2 $ 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 @@ -12,14 +12,14 @@ $ FOO=orig Activating the env stashes it and applies a new value. - $ cd sub + $ cd sub/sub2 ENTER $ echo $FOO changed Leaving the directory unstashes it (varstash_dir is set to prev dir). - $ cd .. + $ cd - LEAVE $ echo $FOO orig