jshn: only keep UP_* variables around while they are needed
authorFelix Fietkau <nbd@openwrt.org>
Sun, 23 Nov 2014 18:43:56 +0000 (19:43 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 23 Nov 2014 18:43:56 +0000 (19:43 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
sh/jshn.sh

index f5cf1d2ad9b32e22ac60f40a230c5556533fe2b2..78414f07b4898d4d7a793df5ea3e5acd17590aa7 100644 (file)
@@ -92,6 +92,7 @@ _json_close_table() {
 
        _json_get_var _s_cur JSON_CUR
        _json_get_var "${JSON_PREFIX}JSON_CUR" "UP_$_s_cur"
+       unset "${JSON_PREFIX}UP_$_s_cur"
 }
 
 json_set_namespace() {
@@ -258,6 +259,7 @@ json_select() {
        [[ "$1" == ".." ]] && {
                _json_get_var cur JSON_CUR
                _json_get_var cur "UP_$cur"
+               unset "${JSON_PREFIX}UP_$cur"
                _json_set_var JSON_CUR "$cur"
                return 0
        }
@@ -265,6 +267,7 @@ json_select() {
        case "$type" in
                object|array)
                        json_get_var cur "$target"
+                       _json_get_var "${JSON_PREFIX}UP_$cur" JSON_CUR
                        _json_set_var JSON_CUR "$cur"
                ;;
                *)