Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-05-16 02:18:16 +0400
committerFelix Fietkau <nbd@openwrt.org>2012-05-16 12:42:37 +0400
commit592f2dbd82c6cb9f85332c8056eed58374ac6dd0 (patch)
tree22e34043d8bf5cc21f2f95d69a994416e5b6d0af /sh
parent97ed91fa77e3e2926bab3e70955a0e2b511db86e (diff)
sh/jshn.sh: allow numbers in identifiers for json_get_var()
When traversing arrays of tables or arrays of array it is required to call json_select # where # is the index of the array item to select. Internally json_select() calls json_get_var() to obtain the correct prefix to populate $JSON_CUR with. However, the "tr" call in json_get_var() incorrectly replaces all digits with underscores, making any lookup for numeric array items fail. The attached patch changes the "tr" expression to allow digits and thus implements the expected behaviour for nested arrays.
Diffstat (limited to 'sh')
-rw-r--r--sh/jshn.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/sh/jshn.sh b/sh/jshn.sh
index 117da67..7228adf 100644
--- a/sh/jshn.sh
+++ b/sh/jshn.sh
@@ -100,7 +100,7 @@ json_get_type() {
json_get_var() {
local dest="$1"
- local var="$(echo -n "$2" | tr -C '[a-zA-Z_]' _)"
+ local var="$(echo -n "$2" | tr -C '[a-zA-Z0-9_]' _)"
eval "export -- \"$dest=\${${JSON_CUR}_$var}\""
}