add uci led support
[openwrt.git] / package / base-files / files / etc / functions.sh
index af4eae2..0314692 100755 (executable)
@@ -24,6 +24,30 @@ append() {
        eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
 }
 
        eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
 }
 
+list_contains() {
+       local var="$1"
+       local str="$2"
+       local val
+
+       eval "val=\" \${$var} \""
+       [ "${val%% $str *}" != "$val" ]
+}
+
+list_remove() {
+       local var="$1"
+       local remove="$2"
+       local val
+
+       eval "val=\" \${$var} \""
+       val1="${val%% $remove *}"
+       [ "$val1" = "$val" ] && return
+       val2="${val##* $remove }"
+       [ "$val2" = "$val" ] && return
+       val="${val1## } ${val2%% }"
+       val="${val%% }"
+       eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\""
+}
+
 config_load() {
        [ -n "$IPKG_INSTROOT" ] && return 0
        uci_load "$@"
 config_load() {
        [ -n "$IPKG_INSTROOT" ] && return 0
        uci_load "$@"
@@ -84,8 +108,8 @@ config_unset() {
 config_clear() {
        local SECTION="$1"
        local oldvar
 config_clear() {
        local SECTION="$1"
        local oldvar
-       
-       export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$(echo " $CONFIG_SECTIONS " | sed -e "s, $OLD , ,")"
+
+       list_remove CONFIG_SECTIONS "$SECTION"
        export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
 
        for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
        export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
 
        for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
This page took 0.022003 seconds and 4 git commands to generate.