projects
/
project
/
libubox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
318d682
)
jshn: add ability to pass default values to json_get_var and json_get_vars
author
Jo-Philipp Wich
<jow@openwrt.org>
Tue, 10 Dec 2013 17:30:15 +0000
(17:30 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Tue, 10 Dec 2013 17:30:15 +0000
(17:30 +0000)
sh/jshn.sh
patch
|
blob
|
history
diff --git
a/sh/jshn.sh
b/sh/jshn.sh
index 70b7976e55468c2aabf85c8592cdf28caaf89e29..85c4151b2a0c3ad53174c085260ffec81e8d391f 100644
(file)
--- a/
sh/jshn.sh
+++ b/
sh/jshn.sh
@@
-231,13
+231,17
@@
json_get_var() {
_json_get_var __cur JSON_CUR
local __var="${JSON_PREFIX}${__cur}_${2//[^a-zA-Z0-9_]/_}"
_json_get_var __cur JSON_CUR
local __var="${JSON_PREFIX}${__cur}_${2//[^a-zA-Z0-9_]/_}"
- eval "export -- \"$__dest=\${$__var
}\"; [ -n \"\${$__var
+x}\" ]"
+ eval "export -- \"$__dest=\${$__var
:-$3}\"; [ -n \"\${$__var+x}\${3
+x}\" ]"
}
json_get_vars() {
while [ "$#" -gt 0 ]; do
local _var="$1"; shift
}
json_get_vars() {
while [ "$#" -gt 0 ]; do
local _var="$1"; shift
- json_get_var "$_var" "$_var"
+ if [ "$_var" != "${_var#*:}" ]; then
+ json_get_var "${_var%%:*}" "${_var%%:*}" "${_var#*:}"
+ else
+ json_get_var "$_var" "$_var"
+ fi
done
}
done
}