2015-04-23 17:03:21 +03:00
|
|
|
$ source $TESTDIR/setup.zsh || return 1
|
2014-11-15 16:08:52 +02:00
|
|
|
|
2015-05-22 00:58:26 +03:00
|
|
|
Lets set a simple .autoenv.zsh action
|
2014-11-15 16:08:52 +02:00
|
|
|
|
|
|
|
$ mkdir sub
|
|
|
|
$ cd sub
|
2015-05-22 00:58:26 +03:00
|
|
|
$ echo 'echo ENTERED' > .autoenv.zsh
|
|
|
|
$ echo 'echo LEFT' > .autoenv_leave.zsh
|
2014-11-15 16:08:52 +02:00
|
|
|
|
|
|
|
Change to the directory.
|
|
|
|
|
2014-11-27 14:33:04 +02:00
|
|
|
$ _autoenv_ask_for_yes() { echo "yes"; return 0 }
|
2014-11-15 16:08:52 +02:00
|
|
|
$ cd .
|
2014-11-27 14:33:04 +02:00
|
|
|
Attempting to load unauthorized env file!
|
2017-12-14 01:53:53 +02:00
|
|
|
-* /*/cramtests-*/leave.t/sub/.autoenv.zsh (glob)
|
2014-11-15 16:08:52 +02:00
|
|
|
|
|
|
|
**********************************************
|
|
|
|
|
|
|
|
echo ENTERED
|
|
|
|
|
|
|
|
**********************************************
|
|
|
|
|
2014-11-27 14:33:04 +02:00
|
|
|
Would you like to authorize it? (type 'yes') yes
|
2014-11-15 16:08:52 +02:00
|
|
|
ENTERED
|
|
|
|
|
|
|
|
|
|
|
|
Leave the directory and answer "no".
|
|
|
|
|
2014-11-27 14:33:04 +02:00
|
|
|
$ _autoenv_ask_for_yes() { echo "no"; return 1 }
|
2014-11-15 16:08:52 +02:00
|
|
|
$ cd ..
|
2014-11-27 14:33:04 +02:00
|
|
|
Attempting to load unauthorized env file!
|
2017-12-14 01:53:53 +02:00
|
|
|
-* /*/cramtests-*/leave.t/sub/.autoenv_leave.zsh (glob)
|
2014-11-15 16:08:52 +02:00
|
|
|
|
|
|
|
**********************************************
|
|
|
|
|
|
|
|
echo LEFT
|
|
|
|
|
|
|
|
**********************************************
|
|
|
|
|
2014-11-27 14:33:04 +02:00
|
|
|
Would you like to authorize it? (type 'yes') no
|
2014-11-15 16:08:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
$ cd sub
|
|
|
|
ENTERED
|
2014-11-27 14:33:04 +02:00
|
|
|
$ _autoenv_ask_for_yes() { echo "yes"; return 0 }
|
2014-11-15 16:08:52 +02:00
|
|
|
$ cd ..
|
2014-11-27 14:33:04 +02:00
|
|
|
Attempting to load unauthorized env file!
|
2017-12-14 01:53:53 +02:00
|
|
|
-* /*/cramtests-*/leave.t/sub/.autoenv_leave.zsh (glob)
|
2014-11-15 16:08:52 +02:00
|
|
|
|
|
|
|
**********************************************
|
|
|
|
|
|
|
|
echo LEFT
|
|
|
|
|
|
|
|
**********************************************
|
|
|
|
|
2014-11-27 14:33:04 +02:00
|
|
|
Would you like to authorize it? (type 'yes') yes
|
2014-11-15 16:08:52 +02:00
|
|
|
LEFT
|
|
|
|
|
|
|
|
|
|
|
|
Now check with subdirs, looking upwards.
|
|
|
|
|
2014-11-21 23:51:28 +02:00
|
|
|
$ AUTOENV_LOOK_UPWARDS=1
|
2014-11-15 16:08:52 +02:00
|
|
|
$ mkdir sub/child
|
|
|
|
$ cd sub/child
|
|
|
|
ENTERED
|
|
|
|
$ cd .
|
|
|
|
$ cd ..
|
|
|
|
$ cd ..
|
|
|
|
LEFT
|
|
|
|
|
|
|
|
|
|
|
|
Now check with subdirs, not looking at parent dirs.
|
|
|
|
|
2014-11-21 23:51:28 +02:00
|
|
|
$ AUTOENV_LOOK_UPWARDS=0
|
2014-11-15 16:08:52 +02:00
|
|
|
$ cd sub/child
|
|
|
|
$ cd ..
|
|
|
|
ENTERED
|
|
|
|
$ cd child
|
|
|
|
$ cd ../..
|
|
|
|
LEFT
|
2014-11-15 16:25:20 +02:00
|
|
|
|
|
|
|
|
2015-05-22 00:58:26 +03:00
|
|
|
Test that .autoenv.zsh is sourced only once with AUTOENV_HANDLE_LEAVE=0.
|
2014-11-15 16:25:20 +02:00
|
|
|
|
2014-11-21 23:51:28 +02:00
|
|
|
$ unset _autoenv_stack_entered
|
|
|
|
$ AUTOENV_HANDLE_LEAVE=0
|
2014-11-15 16:25:20 +02:00
|
|
|
$ cd sub
|
|
|
|
ENTERED
|
|
|
|
$ cd ..
|
|
|
|
$ cd sub
|
2015-01-19 19:57:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
Test that "leave" is not triggered when entering an outside dir via symlink.
|
|
|
|
|
|
|
|
$ AUTOENV_HANDLE_LEAVE=1
|
|
|
|
$ cd ..
|
|
|
|
LEFT
|
|
|
|
$ mkdir outside
|
|
|
|
$ cd outside
|
2015-05-22 00:58:26 +03:00
|
|
|
$ echo 'echo ENTERED outside: PWD:${PWD:t} pwd:${${"$(pwd)"}:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t} event:${autoenv_event}' > .autoenv.zsh
|
|
|
|
$ echo 'echo LEFT outside: PWD:${PWD:t} pwd:${${"$(pwd)"}:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t} event:${autoenv_event}' > .autoenv_leave.zsh
|
2015-10-09 23:04:55 +03:00
|
|
|
$ echo 'echo LEFT: autoenv_env_file:${autoenv_env_file}' >> .autoenv_leave.zsh
|
2015-01-19 19:57:47 +02:00
|
|
|
$ test_autoenv_auth_env_files
|
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
$ ln -s ../outside sub/symlink
|
|
|
|
$ cd sub
|
|
|
|
ENTERED
|
|
|
|
$ cd symlink
|
|
|
|
ENTERED outside: PWD:symlink pwd:symlink from:sub to:symlink event:enter
|
|
|
|
|
|
|
|
$ cd ../..
|
|
|
|
LEFT
|
|
|
|
LEFT outside: PWD:leave.t pwd:leave.t from:symlink to:leave.t event:leave
|
2015-10-09 23:04:55 +03:00
|
|
|
LEFT: autoenv_env_file:*/leave.t/sub/symlink/.autoenv_leave.zsh (glob)
|
2015-01-19 19:57:47 +02:00
|
|
|
$ cd sub/symlink
|
|
|
|
ENTERED outside: PWD:symlink pwd:symlink from:leave.t to:symlink event:enter
|
2015-04-24 18:36:37 +03:00
|
|
|
|
2015-10-09 23:04:55 +03:00
|
|
|
$autoenv_env_file should not be exported.
|
|
|
|
|
|
|
|
$ echo -n $autoenv_env_file
|
|
|
|
|
2015-04-24 18:36:37 +03:00
|
|
|
$autoenv_env_file should be reset when leaving.
|
|
|
|
|
2015-10-09 23:04:55 +03:00
|
|
|
$ echo -n $autoenv_env_file
|
2015-04-24 18:36:37 +03:00
|
|
|
$ cd ../..
|
|
|
|
LEFT outside: PWD:leave.t pwd:leave.t from:symlink to:leave.t event:leave
|
2015-10-09 23:04:55 +03:00
|
|
|
LEFT: autoenv_env_file:*/leave.t/sub/symlink/.autoenv_leave.zsh (glob)
|
2015-04-24 18:36:37 +03:00
|
|
|
$ echo ${autoenv_env_file:-empty}
|
|
|
|
empty
|