functions.sh: add list_contains function for checking whether a list contains a specific element

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12025 3c298f89-4303-0410-b956-a3cf2f4a3e73
master
Felix Fietkau 2008-07-30 22:39:43 +00:00
parent 943998b6f0
commit 2443a74ce1
1 changed files with 9 additions and 0 deletions

View File

@ -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"