functions.sh: add a function for removing an item from a list in a shell variable

SVN-Revision: 12024
owl
Felix Fietkau 2008-07-30 20:35:22 +00:00
parent 3380590790
commit 4d883da9bf
1 changed files with 14 additions and 0 deletions

View File

@ -24,6 +24,20 @@ append() {
eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
}
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%% }"
eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\""
}
config_load() {
[ -n "$IPKG_INSTROOT" ] && return 0
uci_load "$@"