]> Sergey Matveev's repositories - zsh-autoenv.git/commitdiff
Do not reset the stack variables when (re)sourcing the plugin
authorDaniel Hahler <git@thequod.de>
Sun, 15 Mar 2015 21:10:50 +0000 (22:10 +0100)
committerDaniel Hahler <git@thequod.de>
Sun, 29 Mar 2015 22:58:32 +0000 (00:58 +0200)
This is meant to keep the current state when re-sourcing the shell
config (`. ~/.zshrc`).

Closes https://github.com/Tarrasch/zsh-autoenv/pull/24

autoenv.zsh
tests/ZDOTDIR/.zshenv
tests/autoenv.t
tests/setup.sh

index 3ec01e910407b4d8c3afaf5043409ea23606e6b8..05ac0b7d8d09e1de48ac65117977a6081d55e683 100644 (file)
@@ -41,10 +41,8 @@ autoenv_source_parent() {
 # Internal functions. {{{
 # Internal: stack of entered (and handled) directories. {{{
 typeset -g -a _autoenv_stack_entered
-_autoenv_stack_entered=()
 # -g: make it global, this is required when used with antigen.
 typeset -g -A _autoenv_stack_entered_mtime
-_autoenv_stack_entered_mtime=()
 
 # Add an entry to the stack, and remember its mtime.
 _autoenv_stack_entered_add() {
index 029e73d0af419b9fb479f1f695a77027ca99ad5a..07e8b5bf2048a9b3979183c815ee99a3dbe2fcf2 100644 (file)
@@ -2,7 +2,6 @@ test -f "$TESTDIR/.zcompdump" && rm "$TESTDIR/.zcompdump"
 
 AUTOENV_DEBUG=0
 
-source "$TESTDIR/../autoenv.plugin.zsh"
 export AUTOENV_ENV_FILENAME="$PWD/.env_auth"
 
 echo -n > $AUTOENV_ENV_FILENAME
index 76183850982a5b690b305b8cc353f5172a22a4ae..35cd9631c16680354c6f8078da5d2df291a06cf0 100644 (file)
@@ -74,6 +74,7 @@ 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 }
   $ cd .
   Attempting to load unauthorized env file!
   -* /tmp/cramtests-*/autoenv.t/.env (glob)
@@ -84,4 +85,11 @@ Lets also try one more time to ensure it didn't add it.
   
   **********************************************
   
-  Would you like to authorize it? (type 'yes') no
+  Would you like to authorize it? (type 'yes') yes
+  ENTERED
+
+Reloading the script should keep the current state, e.g. when reloading your
+~/.zshrc.
+
+  $ source $TEST_AUTOENV_PLUGIN_FILE
+  $ cd .
index ecbb0cc4a9bf36cce7d08ef586bdcf14a9e7cf71..afa5c958777e5d95f767b0fb391ebc772bf45080 100644 (file)
@@ -18,6 +18,9 @@ fi
 _save_errexit=${options[errexit]}
 set -e
 
+TEST_AUTOENV_PLUGIN_FILE="$TESTDIR/../autoenv.plugin.zsh"
+source $TEST_AUTOENV_PLUGIN_FILE
+
 # Reset any authentication.
 echo -n >| $AUTOENV_ENV_FILENAME