2015-04-23 16:11:40 +03:00
|
|
|
Test varstash with exported variables in subshell.
|
|
|
|
|
2015-04-23 17:03:21 +03:00
|
|
|
$ source $TESTDIR/setup.zsh || return 1
|
2015-04-23 16:11:40 +03:00
|
|
|
|
|
|
|
Setup test environment.
|
|
|
|
|
|
|
|
$ mkdir sub
|
|
|
|
$ cd sub
|
|
|
|
$ echo 'echo ENTER; autostash MYVAR=changed; autostash MYEXPORT=changed_export' > $AUTOENV_FILE_ENTER
|
|
|
|
$ echo 'echo LEAVE; autounstash' > $AUTOENV_FILE_LEAVE
|
|
|
|
|
|
|
|
Manually create auth file
|
|
|
|
|
|
|
|
$ test_autoenv_auth_env_files
|
|
|
|
|
|
|
|
Set environment variable.
|
|
|
|
|
|
|
|
$ MYVAR=orig
|
|
|
|
$ export MYEXPORT=orig_export
|
|
|
|
|
|
|
|
Activating the env stashes it and applies a new value.
|
|
|
|
|
|
|
|
$ cd .
|
|
|
|
ENTER
|
|
|
|
$ echo $MYVAR
|
|
|
|
changed
|
|
|
|
$ echo $MYEXPORT
|
|
|
|
changed_export
|
|
|
|
|
|
|
|
The variable is not available in a subshell, only the exported one.
|
|
|
|
|
|
|
|
$ $SHELL -c 'echo ${MYVAR:-empty}; echo $MYEXPORT'
|
|
|
|
empty
|
|
|
|
changed_export
|
|
|
|
|
|
|
|
Activate autoenv in the subshell.
|
|
|
|
|
2015-04-23 17:00:12 +03:00
|
|
|
$ $SHELL -c "$TEST_SOURCE_AUTOENV; echo \${MYVAR}; echo \$MYEXPORT"
|
2015-04-23 16:11:40 +03:00
|
|
|
ENTER
|
|
|
|
changed
|
|
|
|
changed_export
|
|
|
|
|
|
|
|
"autounstash" should handle the exported variables.
|
|
|
|
|
2015-04-23 17:00:12 +03:00
|
|
|
$ $SHELL -c "$TEST_SOURCE_AUTOENV; cd ..; echo \${MYVAR:-empty}; echo \$MYEXPORT"
|
2015-04-23 16:11:40 +03:00
|
|
|
ENTER
|
|
|
|
LEAVE
|
|
|
|
empty
|
|
|
|
orig_export
|
|
|
|
#
|
|
|
|
# Exiting the subshell should restore.
|
|
|
|
#
|
|
|
|
# $ pwd
|
|
|
|
# */varstash_export.t (glob)
|
|
|
|
# $ echo $MYVAR
|
|
|
|
# changed
|
|
|
|
# $ echo $MYEXPORT
|
|
|
|
# changed_export
|