X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/097b27145d8b0e148636abd74ff80b8b92e25c05..d5dc9a90873047ab07107833a950320ae3b2b41f:/package/base-files/files/etc/functions.sh diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh index f4af4a857..0314692c5 100755 --- a/package/base-files/files/etc/functions.sh +++ b/package/base-files/files/etc/functions.sh @@ -24,6 +24,15 @@ append() { 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" @@ -35,6 +44,7 @@ list_remove() { val2="${val##* $remove }" [ "$val2" = "$val" ] && return val="${val1## } ${val2%% }" + val="${val%% }" eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\"" } @@ -98,8 +108,8 @@ config_unset() { 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}_} | \