mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-11-22 07:20:59 +02:00
Fix (auto)unstashing when being sourced from a subdir (#79)
Fixes https://github.com/Tarrasch/zsh-autoenv/issues/77.
This commit is contained in:
parent
9074633a29
commit
d6bfdff968
@ -293,8 +293,6 @@ _autoenv_source() {
|
|||||||
if \grep -qE '\b(autostash|autounstash|stash|unstash)\b' $autoenv_env_file; then
|
if \grep -qE '\b(autostash|autounstash|stash|unstash)\b' $autoenv_env_file; then
|
||||||
source ${${funcsourcetrace[1]%:*}:h}/lib/varstash
|
source ${${funcsourcetrace[1]%:*}:h}/lib/varstash
|
||||||
fi
|
fi
|
||||||
# NOTE: Varstash uses $PWD as default for varstash_dir, we might set it to
|
|
||||||
# ${autoenv_env_file:h}.
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source the env file.
|
# Source the env file.
|
||||||
@ -306,7 +304,8 @@ _autoenv_source() {
|
|||||||
restore_xtrace=1
|
restore_xtrace=1
|
||||||
setopt localoptions xtrace
|
setopt localoptions xtrace
|
||||||
fi
|
fi
|
||||||
source $autoenv_env_file
|
|
||||||
|
varstash_dir=${autoenv_env_file:h} source $autoenv_env_file
|
||||||
if (( restore_xtrace )); then
|
if (( restore_xtrace )); then
|
||||||
setopt noxtrace
|
setopt noxtrace
|
||||||
fi
|
fi
|
||||||
|
@ -4,7 +4,7 @@ Test unstash behavior on leaving.
|
|||||||
|
|
||||||
Setup test environment.
|
Setup test environment.
|
||||||
|
|
||||||
$ mkdir sub
|
$ mkdir -p sub/sub2
|
||||||
$ echo 'echo ENTER; stash FOO=changed' >| sub/$AUTOENV_FILE_ENTER
|
$ echo 'echo ENTER; stash FOO=changed' >| sub/$AUTOENV_FILE_ENTER
|
||||||
$ echo 'echo LEAVE; unstash FOO' >| sub/$AUTOENV_FILE_LEAVE
|
$ echo 'echo LEAVE; unstash FOO' >| sub/$AUTOENV_FILE_LEAVE
|
||||||
$ test_autoenv_auth_env_files sub
|
$ test_autoenv_auth_env_files sub
|
||||||
@ -12,14 +12,14 @@ Setup test environment.
|
|||||||
|
|
||||||
Activating the env stashes it and applies a new value.
|
Activating the env stashes it and applies a new value.
|
||||||
|
|
||||||
$ cd sub
|
$ cd sub/sub2
|
||||||
ENTER
|
ENTER
|
||||||
$ echo $FOO
|
$ echo $FOO
|
||||||
changed
|
changed
|
||||||
|
|
||||||
Leaving the directory unstashes it (varstash_dir is set to prev dir).
|
Leaving the directory unstashes it (varstash_dir is set to prev dir).
|
||||||
|
|
||||||
$ cd ..
|
$ cd -
|
||||||
LEAVE
|
LEAVE
|
||||||
$ echo $FOO
|
$ echo $FOO
|
||||||
orig
|
orig
|
||||||
|
Loading…
Reference in New Issue
Block a user