[pbuilder] 07/08: modules: add a helper function _contains() to check whether a value is in a given list
Mattia Rizzolo
mattia at debian.org
Wed Jun 22 12:17:45 UTC 2016
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch master
in repository pbuilder.
commit 389599957579326aaed9a6aad5221cc5cc3f0a7c
Author: Mattia Rizzolo <mattia at debian.org>
Date: Wed Jun 22 11:58:49 2016 +0000
modules: add a helper function _contains() to check whether a value is in a given list
I copied this fuction years ago from who knows where, and since then I keep
copying it around. I know it would become really useful one day! :)
Gbp-Dch: Ignore
---
pbuilder-modules | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/pbuilder-modules b/pbuilder-modules
index e2bc2f4..5a941fa 100644
--- a/pbuilder-modules
+++ b/pbuilder-modules
@@ -137,6 +137,18 @@ log.d() {
esac
}
+# call like `_contains $list $value`, returns 0 if $value is in $list, 1 otherwise
+_contains() {
+ local n=$#
+ local value=${!n}
+ for ((i=1; i < $#; i++)) {
+ if [ "${!i}" == "${value}" ]; then
+ return 0
+ fi
+ }
+ return 1
+}
+
# test whether a directory is empty
# fails if "$*" exists but isn't a directory
# fails and outputs garbage if "$*" doesn't actually exist
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/pbuilder.git
More information about the Pbuilder-maint
mailing list