mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-11-25 16:31:00 +02:00
lib/varstash: simplify stash for Zsh
This commit is contained in:
parent
c018ad8e66
commit
d09b85cc0a
10
lib/varstash
10
lib/varstash
@ -135,19 +135,13 @@ function stash() {
|
|||||||
# Handle any variable that may exist under this name
|
# Handle any variable that may exist under this name
|
||||||
local vartype="$(declare -p $stash_which 2>/dev/null)"
|
local vartype="$(declare -p $stash_which 2>/dev/null)"
|
||||||
if [[ -n $vartype ]]; then
|
if [[ -n $vartype ]]; then
|
||||||
if [[ -n $ZSH_VERSION ]]; then
|
if [[ $vartype == 'typeset -a'* ]]; then
|
||||||
local pattern="typeset"
|
|
||||||
else
|
|
||||||
local pattern="declare"
|
|
||||||
fi
|
|
||||||
if [[ $vartype == $pattern" -a"* ]]; then
|
|
||||||
# varible is an array
|
# varible is an array
|
||||||
if [[ -z $already_stashed ]]; then
|
if [[ -z $already_stashed ]]; then
|
||||||
eval "__varstash_array__$stash_name=(\"\${$stash_which""[@]}\")"
|
eval "__varstash_array__$stash_name=(\"\${$stash_which""[@]}\")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif ([[ -n $ZSH_VERSION ]] && [[ $vartype == "export "* ]]) \
|
elif [[ $vartype == "export "* || $vartype == 'typeset -x'* ]]; then
|
||||||
|| [[ $vartype == $pattern" -x"* ]]; then
|
|
||||||
# variable is exported
|
# variable is exported
|
||||||
if [[ -z $already_stashed ]]; then
|
if [[ -z $already_stashed ]]; then
|
||||||
eval "export __varstash_export__$stash_name=\"\$$stash_which\""
|
eval "export __varstash_export__$stash_name=\"\$$stash_which\""
|
||||||
|
Loading…
Reference in New Issue
Block a user