summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functions13
-rwxr-xr-xmkinitcpio11
2 files changed, 13 insertions, 11 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() {
diff --git a/mkinitcpio b/mkinitcpio
index 0404ecc..f698198 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -135,7 +135,7 @@ hook_help() {
}
hook_list() {
- local n p hook resolved
+ local p hook resolved
local -a paths hooklist depr
local ss_ordinals=(¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹)
@@ -156,16 +156,13 @@ hook_list() {
resolved=${resolved##*/}
- index_of "$resolved" "${depr[@]}"
-
- n=$?
- if (( n == 255 )); then
+ if ! index_of "$resolved" "${depr[@]}"; then
# deprecated hook
depr+=("$resolved")
- n=$(( ${#depr[*]} - 1 ))
+ _idx=$(( ${#depr[*]} - 1 ))
fi
- hook=$hook${ss_ordinals[n]}
+ hook+=${ss_ordinals[_idx]}
fi
hooklist+=("${hook##*/}")