]> Sergey Matveev's repositories - zsh-autoenv.git/commitdiff
lib/varstash: simplify stash for Zsh
authorDaniel Hahler <git@thequod.de>
Sun, 23 Apr 2017 19:55:34 +0000 (21:55 +0200)
committerDaniel Hahler <git@thequod.de>
Wed, 26 Apr 2017 19:51:11 +0000 (21:51 +0200)
lib/varstash

index dd5096915e2bbb02939afb3d5628cb9f20ee0305..7da077ef149129c370f6f31ab47fd4ad0a5ae4b1 100644 (file)
@@ -135,19 +135,13 @@ function stash() {
         # Handle any variable that may exist under this name
         local vartype="$(declare -p $stash_which 2>/dev/null)"
         if [[ -n $vartype ]]; then
-            if [[ -n $ZSH_VERSION ]]; then
-                local pattern="typeset"
-            else
-                local pattern="declare"
-            fi
-            if [[ $vartype == $pattern" -a"* ]]; then
+            if [[ $vartype == 'typeset -a'* ]]; then
                 # varible is an array
                 if [[ -z $already_stashed ]]; then
                     eval "__varstash_array__$stash_name=(\"\${$stash_which""[@]}\")"
                 fi
 
-            elif ([[ -n $ZSH_VERSION ]] && [[ $vartype == "export "* ]]) \
-                || [[ $vartype == $pattern" -x"* ]]; then
+            elif [[ $vartype == "export "* || $vartype == 'typeset -x'* ]]; then
                 # variable is exported
                 if [[ -z $already_stashed ]]; then
                     eval "export __varstash_export__$stash_name=\"\$$stash_which\""