Test varstash integration.
- $ source $TESTDIR/setup.sh
+ $ source $TESTDIR/setup.zsh || return 1
Setup test environment.
$ mkdir sub
$ cd sub
- $ echo 'echo ENTER; autostash FOO=changed' > $AUTOENV_FILE_ENTER
- $ echo 'echo LEAVE; autounstash' > $AUTOENV_FILE_LEAVE
-Manually create auth file
+The varstash library should not get loaded always.
+
+ $ echo 'echo ENTER' > $AUTOENV_FILE_ENTER
+ $ echo 'echo LEAVE' > $AUTOENV_FILE_LEAVE
+ $ test_autoenv_auth_env_files
+ $ cd .
+ ENTER
+ $ type -w autostash
+ autostash: none
+ [1]
+
+Now on to some stashing.
+ $ echo 'echo ENTER; autostash FOO=changed' > $AUTOENV_FILE_ENTER
+ $ echo 'echo LEAVE; autounstash' > $AUTOENV_FILE_LEAVE
$ test_autoenv_auth_env_files
Set environment variable.
Activating the env stashes it and applies a new value.
- $ cd .
+ $ cd ..
+ LEAVE
+ $ cd sub
ENTER
+ $ type -w autostash
+ autostash: function
$ echo $FOO
changed
Setup:
+ $ unset VAR
$ cd sub
ENTER
- $ echo 'echo ENTER; autostash VAR=changed' > $AUTOENV_FILE_ENTER
- $ echo 'echo LEAVE; echo "no explicit call to autounstash"' > $AUTOENV_FILE_LEAVE
+ $ echo 'echo ENTER; autostash VAR=changed' >| $AUTOENV_FILE_ENTER
+ $ echo 'echo LEAVE; echo "no explicit call to autounstash"' >| $AUTOENV_FILE_LEAVE
$ test_autoenv_auth_env_files
-$VAR is empty:
+$VAR is unset:
- $ echo VAR:$VAR
- VAR:
+ $ echo VAR_set:$+VAR
+ VAR_set:0
-Set it:
+Trigger the autostashing in the enter file.
- $ VAR=orig
$ cd ..
LEAVE
no explicit call to autounstash
-
-Leaving the directory keeps it intact - nothing had been stashed yet.
-
- $ echo $VAR
- orig
-
-Enter the dir, trigger the autostashing.
-
$ cd sub
ENTER
$ echo $VAR
$ cd ..
LEAVE
no explicit call to autounstash
- $ echo $VAR
- orig
-
+ $ echo VAR_set:$+VAR
+ VAR_set:0
Remove the leave file, auto-unstashing should still happen.
$ echo $VAR
changed
$ cd ..
+ $ echo VAR_set:$+VAR
+ VAR_set:0
+
+And once again where a value gets restored.
+
+ $ VAR=orig_2
$ echo $VAR
- orig
+ orig_2
+ $ cd sub
+ ENTER
+ $ echo $VAR
+ changed
+ $ cd ..
+ $ echo $VAR
+ orig_2
}}}