1
0
mirror of https://github.com/Tarrasch/zsh-autoenv.git synced 2025-12-14 02:15:11 +02:00

varstash integration

Fixes: https://github.com/Tarrasch/zsh-autoenv/issues/5
This commit is contained in:
Daniel Hahler
2014-11-15 20:59:39 +01:00
parent 0bcbeb5ae5
commit 5b553ba1ed
2 changed files with 53 additions and 5 deletions

36
tests/varstash.t Normal file
View File

@@ -0,0 +1,36 @@
Test varstash integration.
$ source $TESTDIR/setup.sh
Setup test environment.
# Defaults:
# $ DOTENV_FILE_ENTER=.env
# $ DOTENV_FILE_LEAVE=.env.leave
# $ DOTENV_HANDLE_LEAVE=1
$ mkdir sub
$ cd sub
$ echo "autostash FOO=baz" > $DOTENV_FILE_ENTER
$ echo "autounstash" > $DOTENV_FILE_LEAVE
Manually create auth file
$ echo "$PWD/$DOTENV_FILE_ENTER:$(echo $(<$DOTENV_FILE_ENTER) | shasum)" > $ENV_AUTHORIZATION_FILE
$ echo "$PWD/$DOTENV_FILE_LEAVE:$(echo $(<$DOTENV_FILE_LEAVE) | shasum)" >> $ENV_AUTHORIZATION_FILE
Set environment variable.
$ FOO=bar
Activating the env stashes it and applies a new value.
$ cd .
$ echo $FOO
baz
Leaving the directory unstashes it.
$ cd ..
$ echo $FOO
bar