diff options
author | Felix Fietkau <nbd@openwrt.org> | 2008-07-30 22:39:43 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2008-07-30 22:39:43 +0000 |
commit | 2443a74ce18ff941101f2b6b51e7c60ac77f6f06 (patch) | |
tree | f46fcf63107036926a359901f08ea221e1d1f0ec | |
parent | 943998b6f0caea0990db243be0bdf5d02076f5b0 (diff) | |
download | upstream-2443a74ce18ff941101f2b6b51e7c60ac77f6f06.tar.gz upstream-2443a74ce18ff941101f2b6b51e7c60ac77f6f06.tar.bz2 upstream-2443a74ce18ff941101f2b6b51e7c60ac77f6f06.zip |
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
-rwxr-xr-x | package/base-files/files/etc/functions.sh | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh index f4af4a8573..01db77ce39 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" |