mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2025-12-21 13:06:48 +02:00
Remember non-yes answer for the current shell session
This basically caches $_autoenv_check_authorized_env_file in $_autoenv_asked_already. This should also improve the case for authorized files. Ref: https://github.com/Tarrasch/zsh-autoenv/issues/29
This commit is contained in:
@@ -14,6 +14,7 @@ Now try to make it accept it
|
||||
|
||||
$ _autoenv_stack_entered=()
|
||||
$ rm $AUTOENV_ENV_FILENAME
|
||||
$ _autoenv_asked_already=()
|
||||
$ _autoenv_ask_for_yes() { echo "yes" }
|
||||
$ cd .
|
||||
Attempting to load unauthorized env file!
|
||||
@@ -37,8 +38,9 @@ Now lets see that it actually checks the shasum value.
|
||||
$ cd .
|
||||
ENTERED
|
||||
|
||||
$ _autoenv_stack_entered=()
|
||||
$ rm $AUTOENV_ENV_FILENAME
|
||||
$ _autoenv_stack_entered=()
|
||||
$ _autoenv_asked_already=()
|
||||
$ test_autoenv_add_to_env $PWD/.env mischief
|
||||
$ cd .
|
||||
Attempting to load unauthorized env file!
|
||||
@@ -56,8 +58,9 @@ Now lets see that it actually checks the shasum value.
|
||||
|
||||
Now, will it take no for an answer?
|
||||
|
||||
$ _autoenv_stack_entered=()
|
||||
$ rm $AUTOENV_ENV_FILENAME
|
||||
$ _autoenv_stack_entered=()
|
||||
$ _autoenv_asked_already=()
|
||||
$ _autoenv_ask_for_yes() { echo "no"; return 1 }
|
||||
$ cd .
|
||||
Attempting to load unauthorized env file!
|
||||
@@ -74,7 +77,8 @@ Now, will it take no for an answer?
|
||||
|
||||
Lets also try one more time to ensure it didn't add it.
|
||||
|
||||
$ _autoenv_ask_for_yes() { echo "yes"; return 0 }
|
||||
$ _autoenv_asked_already=()
|
||||
$ _autoenv_ask_for_yes() { echo "no"; return 1 }
|
||||
$ cd .
|
||||
Attempting to load unauthorized env file!
|
||||
-* /tmp/cramtests-*/autoenv.t/.env (glob)
|
||||
@@ -85,11 +89,35 @@ Lets also try one more time to ensure it didn't add it.
|
||||
|
||||
**********************************************
|
||||
|
||||
Would you like to authorize it? (type 'yes') no
|
||||
|
||||
And now see if we're not being asked again after not allowing it.
|
||||
|
||||
$ _autoenv_ask_for_yes() { echo "should_not_be_used"; return 1 }
|
||||
$ cd .
|
||||
|
||||
|
||||
Reloading the script should keep the current state, e.g. when reloading your
|
||||
~/.zshrc.
|
||||
But it should re-ask for unauthorized files.
|
||||
|
||||
$ cd ..
|
||||
$ $TEST_SOURCE_AUTOENV
|
||||
$ _autoenv_ask_for_yes() { echo "yes"; return 0 }
|
||||
$ cd -
|
||||
Attempting to load unauthorized env file!
|
||||
-* /tmp/cramtests-*/autoenv.t/.env (glob)
|
||||
|
||||
**********************************************
|
||||
|
||||
echo ENTERED
|
||||
|
||||
**********************************************
|
||||
|
||||
Would you like to authorize it? (type 'yes') yes
|
||||
ENTERED
|
||||
|
||||
Reloading the script should keep the current state, e.g. when reloading your
|
||||
~/.zshrc.
|
||||
With an authorized file, it should not re-ask you.
|
||||
|
||||
$ $TEST_SOURCE_AUTOENV
|
||||
$ cd .
|
||||
|
||||
@@ -42,6 +42,7 @@ Leave the directory and answer "no".
|
||||
|
||||
$ cd sub
|
||||
ENTERED
|
||||
$ _autoenv_asked_already=()
|
||||
$ _autoenv_ask_for_yes() { echo "yes"; return 0 }
|
||||
$ cd ..
|
||||
Attempting to load unauthorized env file!
|
||||
|
||||
@@ -110,6 +110,7 @@ Changing the root .env should trigger re-authentication via autoenv_source_paren
|
||||
First, let's answer "no".
|
||||
|
||||
$ echo "echo NEW" >| .env
|
||||
$ _autoenv_asked_already=()
|
||||
$ _autoenv_ask_for_yes() { echo "no"; return 1 }
|
||||
$ cd sub
|
||||
autoenv_source_parent_from_sub:
|
||||
@@ -135,6 +136,7 @@ This currently does not trigger re-execution of the .env file.
|
||||
|
||||
Touching the .env file will now source the parent env file.
|
||||
|
||||
$ _autoenv_asked_already=()
|
||||
$ touch -t 201401010104 .env
|
||||
$ cd .
|
||||
autoenv_source_parent_from_sub:
|
||||
|
||||
Reference in New Issue
Block a user