mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-11-22 15:30:59 +02:00
varstash: remove all usages of =~
This commit is contained in:
parent
936b5eaf77
commit
07abe9cea8
@ -101,7 +101,7 @@ function stash() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
while [[ -n $1 ]]; do
|
while [[ -n $1 ]]; do
|
||||||
if [[ $1 == "alias" && $2 =~ "=" ]]; then
|
if [[ $1 == "alias" && $2 == *=* ]]; then
|
||||||
shift
|
shift
|
||||||
local _stashing_alias_assign=1
|
local _stashing_alias_assign=1
|
||||||
continue
|
continue
|
||||||
@ -179,13 +179,13 @@ function stash() {
|
|||||||
else
|
else
|
||||||
local pattern="^declare"
|
local pattern="^declare"
|
||||||
fi
|
fi
|
||||||
if [[ $vartype =~ $pattern" -a" ]]; then
|
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 [[ $vartype =~ $pattern" -x" ]]; then
|
elif [[ $vartype == $pattern" -x"* ]]; then
|
||||||
# variable is exported
|
# variable is exported
|
||||||
if [[ -z $already_stashed ]]; then
|
if [[ -z $already_stashed ]]; then
|
||||||
eval "__varstash_export__$stash_name=\"\$$stash_which\""
|
eval "__varstash_export__$stash_name=\"\$$stash_which\""
|
||||||
@ -310,7 +310,8 @@ function unstash() {
|
|||||||
fi
|
fi
|
||||||
if [[ ( -n "$nostash" && -z "$unstashed" ) || ( -n "$unstashed" && -z "$unstashed_variable" ) ]]; then
|
if [[ ( -n "$nostash" && -z "$unstashed" ) || ( -n "$unstashed" && -z "$unstashed_variable" ) ]]; then
|
||||||
# Don't try to unset illegal variable names
|
# Don't try to unset illegal variable names
|
||||||
if ! [[ $unstash_which =~ [^a-zA-Z0-9_] || $unstash_which =~ ^[0-9] ]]; then
|
# Using substitution to avoid using regex, which might fail to load on Zsh (minimal system).
|
||||||
|
if [[ ${unstash_which//[^a-zA-Z0-9_]/} == $unstash_which && $unstash_which != [0-9]* ]]; then
|
||||||
unset -v $unstash_which
|
unset -v $unstash_which
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user