diff options
author | Marc Cornellà <marc.cornella@live.com> | 2019-02-25 23:20:47 +0100 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2019-02-25 23:20:47 +0100 |
commit | 55575b88f9e47d88fab02c26fc69e4af48af1cd9 (patch) | |
tree | 38819c32b3e3d021de2853ba07b3debb5642dada /lib/functions.zsh | |
parent | 4cdffcd4858c7818e5325c03909d75e41995eeae (diff) | |
download | zsh-55575b88f9e47d88fab02c26fc69e4af48af1cd9.tar.gz zsh-55575b88f9e47d88fab02c26fc69e4af48af1cd9.tar.bz2 zsh-55575b88f9e47d88fab02c26fc69e4af48af1cd9.zip |
lib: optimize default and env_default
Diffstat (limited to 'lib/functions.zsh')
-rw-r--r-- | lib/functions.zsh | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/functions.zsh b/lib/functions.zsh index 4ef8920f6..9f8736bd7 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -79,7 +79,7 @@ function try_alias_value() { # 0 if the variable exists, 3 if it was set # function default() { - test `typeset +m "$1"` && return 0 + (( $+parameters[$1] )) && return 0 typeset -g "$1"="$2" && return 3 } @@ -93,8 +93,8 @@ function default() { # 0 if the env variable exists, 3 if it was set # function env_default() { - env | grep -q "^$1=" && return 0 - export "$1=$2" && return 3 + (( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0 + export "$1=$2" && return 3 } |