]> Sergey Matveev's repositories - zsh-autoenv.git/commitdiff
Fix use of local in while loop. (#66)
authorDaniel Hahler <github@thequod.de>
Tue, 16 May 2017 20:58:25 +0000 (22:58 +0200)
committerGitHub <noreply@github.com>
Tue, 16 May 2017 20:58:25 +0000 (22:58 +0200)
For some reason it did not fail on Travis when only pushing the test
first?!

Also adds punctuation to already-stashed msg.

lib/varstash
tests/varstash.t

index 94c063d28d3513b9a286ee456279eb43fc19da4e..056233cb2ebb044175d53f718eef5235c98ae8d4 100644 (file)
@@ -44,7 +44,7 @@
 #
 #       $ stash FOO
 #       $ stash FOO
-#       You have already stashed FOO, please specify "-f" if you want to overwrite another stashed value
+#       You have already stashed FOO, please specify "-f" if you want to overwrite another stashed value.
 #       $ stash -f FOO
 #       $
 #
@@ -94,7 +94,7 @@ function stash() {
 
             if [[ $stash_which == $stash_expression ]]; then
                 if [[ -z $run_from_smartcd ]]; then
-                    echo "You have already stashed $stash_which, please specify \"-f\" if you want to overwrite another stashed value"
+                    echo "You have already stashed $stash_which, please specify \"-f\" if you want to overwrite another stashed value."
                 fi
 
                 # Skip remaining work if we're not doing an assignment
@@ -197,16 +197,18 @@ function get_autostash_array_name() {
 
 function autostash() {
     local run_from_autostash=1
+    local ret varname
+    local already_stashed=
     while [[ -n $1 ]]; do
         if [[ $1 == "alias" && $2 == *=* ]]; then
             shift
             local _stashing_alias_assign=1
         fi
 
-        local already_stashed=
+        already_stashed=
         stash "$1"
         if [[ -z $already_stashed ]]; then
-            local ret varname=${1%%'='*}
+            varname=${1%%'='*}
             get_autostash_array_name
             eval "$ret=(\$$ret \$varname)"
         fi
index 187904fc07d0830e0cae44e8ee83b2abcb7f9da7..3e4b3dc8145c02d3117e4886104a5a5cc9eb3214 100644 (file)
@@ -106,3 +106,23 @@ And once again where a value gets restored.
   orig_2
 
 }}}
+
+autostash does not issue a warning, and no other output. {{{
+
+  $ autostash something=1 something_else=2
+  $ echo $something $something_else
+  1 2
+  $ stash something=1.2 something_else=2.2
+  $ echo $something $something_else
+  1.2 2.2
+  $ stash something something_else
+  You have already stashed something, please specify "-f" if you want to overwrite another stashed value.
+  You have already stashed something_else, please specify "-f" if you want to overwrite another stashed value.
+
+Should not be set anymore.
+
+  $ autounstash
+  $ echo ${+something} ${+something_else}
+  0 0
+
+}}}