From 65cf7985377d9c63658a7a24bb853ec2d84c2e42 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 31 Jan 2011 11:59:44 -0600 Subject: Add bash in_array function This is what we currently use in makepkg for the same purpose. Signed-off-by: Dan McGee --- functions | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/functions b/functions index 334938b..bd0a2c6 100644 --- a/functions +++ b/functions @@ -24,6 +24,21 @@ get_module_name () echo "$modname" } +## +# usage : in_array( $needle, $haystack ) +# return : 0 - found +# 1 - not found +## +in_array() { + local needle=$1; shift + [[ -z $1 ]] && return 1 # Not Found + local item + for item in "$@"; do + [[ $item = $needle ]] && return 0 # Found + done + return 1 # Not Found +} + auto_modules () { aliases="$(find /sys/devices/ -name modalias -exec cat {} +)" -- cgit v1.2.3-24-g4f1b