diff options
author | Dan McGee <dan@archlinux.org> | 2011-01-31 18:59:44 +0100 |
---|---|---|
committer | Thomas Bächler <thomas@archlinux.org> | 2011-01-31 21:46:37 +0100 |
commit | 65cf7985377d9c63658a7a24bb853ec2d84c2e42 (patch) | |
tree | 4109f395691bea5c283f5741be4d139fb05ddf86 /functions | |
parent | 49c9c9fc1b37610a87fe3cf9f5e7b5785672264d (diff) | |
download | mkinitcpio-65cf7985377d9c63658a7a24bb853ec2d84c2e42.tar.gz mkinitcpio-65cf7985377d9c63658a7a24bb853ec2d84c2e42.tar.xz |
Add bash in_array function
This is what we currently use in makepkg for the same purpose.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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 {} +)" |