Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
55575b88
Commit
55575b88
authored
Feb 25, 2019
by
Marc Cornellà
Browse files
lib: optimize default and env_default
parent
4cdffcd4
Changes
1
Show whitespace changes
Inline
Side-by-side
lib/functions.zsh
View file @
55575b88
...
...
@@ -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,7 +93,7 @@ function default() {
# 0 if the env variable exists, 3 if it was set
#
function
env_default
()
{
env
|
grep
-q
"^
$1
="
&&
return
0
((
${${
(@f)
:-
$(
typeset
+xg
)
}
[(I)
$1
]
}
))
&&
return
0
export
"
$1
=
$2
"
&&
return
3
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment