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.
|
|
|
|
|
2017-12-16 00:24:12 +02:00
|
|
|
$ $TESTSHELL -c 'echo ${MYVAR:-empty}; echo $MYEXPORT'
|
2015-04-23 16:11:40 +03:00
|
|
|
empty
|
|
|
|
changed_export
|
|
|
|
|
|
|
|
Activate autoenv in the subshell.
|
|
|
|
|
2017-12-16 00:24:12 +02:00
|
|
|
$ $TESTSHELL -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.
|
|
|
|
|
2017-12-16 00:24:12 +02:00
|
|
|
$ $TESTSHELL -c "$TEST_SOURCE_AUTOENV; cd ..; echo \${MYVAR:-empty}; echo \$MYEXPORT"
|
2015-04-23 16:11:40 +03:00
|
|
|
ENTER
|
|
|
|
LEAVE
|
|
|
|
empty
|
|
|
|
orig_export
|