summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-12-23 22:25:19 +0100
committerDave Reisner <dreisner@archlinux.org>2013-05-07 19:17:46 +0200
commit601aab2477f5cb6fc3298216625b9804d6a18dad (patch)
tree365091c9faaff0d4bb6d8ca0180b80c20472d096 /functions
parentd662258b8769af81a036b7d4cd0af0a66e33dbb2 (diff)
downloadmkinitcpio-601aab2477f5cb6fc3298216625b9804d6a18dad.tar.gz
mkinitcpio-601aab2477f5cb6fc3298216625b9804d6a18dad.tar.xz
remove "arbitrary" limit from index_of()
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r--functions13
1 files changed, 9 insertions, 4 deletions
diff --git a/functions b/functions
index bb28f34..43e3b7d 100644
--- a/functions
+++ b/functions
@@ -212,15 +212,20 @@ in_array() {
}
index_of() {
- # get the array index of an item. size limit of 254 items!
+ # get the array index of an item. sets the global var _idx with
+ # index and returns 0 if found, otherwise returns 1.
local item=$1; shift
- for (( i=1; i <= $#; i++ )); do
- [[ $item = ${!i} ]] && return $(( --i ))
+ for (( _idx=1; _idx <= $#; _idx++ )); do
+ if [[ $item = ${!_idx} ]]; then
+ (( --_idx ))
+ return 0
+ fi
done
# not found
- return 255
+ unset _idx
+ return 1
}
funcgrep() {