sh/jshn.sh: fix allowing numbers in identifiers
authorFelix Fietkau <nbd@openwrt.org>
Thu, 17 May 2012 12:29:59 +0000 (14:29 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 17 May 2012 12:30:00 +0000 (14:30 +0200)
json_add_generic() needs to handle them as well

sh/jshn.sh

index 7228adf..7f922c4 100644 (file)
@@ -24,7 +24,7 @@ json_add_generic() {
                var=$(( ${aseq:-0} + 1 ))
                export -- "SEQ_$cur=$var"
        else
                var=$(( ${aseq:-0} + 1 ))
                export -- "SEQ_$cur=$var"
        else
-               local name="$(echo -n "$var" | tr -C '[a-zA-Z_]' _)"
+               local name="$(echo -n "$var" | tr -C '[a-zA-Z0-9_]' _)"
                [[ "$name" == "$var" ]] || export -- "NAME_${cur}_${name}=$var"
                var="$name"
        fi
                [[ "$name" == "$var" ]] || export -- "NAME_${cur}_${name}=$var"
                var="$name"
        fi