mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-19 20:29:45 +01:00
lib: optimize default and env_default
This commit is contained in:
parent
4cdffcd485
commit
55575b88f9
1 changed files with 3 additions and 3 deletions
|
@ -79,7 +79,7 @@ function try_alias_value() {
|
||||||
# 0 if the variable exists, 3 if it was set
|
# 0 if the variable exists, 3 if it was set
|
||||||
#
|
#
|
||||||
function default() {
|
function default() {
|
||||||
test `typeset +m "$1"` && return 0
|
(( $+parameters[$1] )) && return 0
|
||||||
typeset -g "$1"="$2" && return 3
|
typeset -g "$1"="$2" && return 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ function default() {
|
||||||
# 0 if the env variable exists, 3 if it was set
|
# 0 if the env variable exists, 3 if it was set
|
||||||
#
|
#
|
||||||
function env_default() {
|
function env_default() {
|
||||||
env | grep -q "^$1=" && return 0
|
(( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0
|
||||||
export "$1=$2" && return 3
|
export "$1=$2" && return 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue