summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
Diffstat (limited to 'functions')
-rw-r--r--functions12
1 files changed, 12 insertions, 0 deletions
diff --git a/functions b/functions
index f46a9ae..10a072c 100644
--- a/functions
+++ b/functions
@@ -193,6 +193,18 @@ in_array() {
return 1 # Not Found
}
+index_of() {
+ # get the array index of an item. size limit of 254 items!
+ local item=$1; shift
+
+ for (( i=1; i <= $#; i++ )); do
+ [[ $item = ${!i} ]] && return $(( --i ))
+ done
+
+ # not found
+ return 255
+}
+
funcgrep() {
awk -v funcmatch="$1" '
/^[[:space:]]*[[:alnum:]_]+[[:space:]]*\([[:space:]]*\)/ {