From 8c453b693ce2790ab8cd489cb19a90388242e799 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 30 Jul 2008 22:39:43 +0000 Subject: [PATCH] functions.sh: add list_contains function for checking whether a list contains a specific element SVN-Revision: 12025 --- package/base-files/files/etc/functions.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh index f4af4a85739..01db77ce395 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"