@@ -99,6 +99,8 @@ function arrFilter() {
9999 local -r predicate=$3
100100 shift 3 || traceAndDie " could not shift by 3"
101101
102+ exitIfArgIsNotArray arrFilter_arrIn 1
103+ exitIfArgIsNotArrayOrIsNonEmpty arrFilter_arrOut 2
102104 exitIfArgIsNotFunction " $predicate " 3
103105
104106 local -ri arrFilter_arrInLength=" ${# arrFilter_arrIn[@]} "
@@ -123,20 +125,22 @@ function arrTakeEveryX() {
123125 exit 9
124126 fi
125127 # shellcheck disable=SC2034 # is passed by name to arrFilter
126- local -rn arrFilterMod_arrIn =$1
128+ local -rn arrTakeEveryX_arrIn =$1
127129 # shellcheck disable=SC2034 # is passed by name to arrFilter
128- local -rn arrFilterMod_arrOut =$2
130+ local -rn arrTakeEveryX_arrOut =$2
129131 local -ri modulo=$3
130132 local -ri offset=$4
131133 shift 4 || traceAndDie " could not shift by 4"
132134
133- # shellcheck disable=SC2329 # is passed by name to arrFilter
134- function arrFilterMod_fn() {
135+ # arrFilter will check that arrTakeEveryX_arrIn and arrTakeEveryX_arrOut are arrays and arrOut non empty
136+
137+ # shellcheck disable=SC2329 # is passed by name to arrFilter
138+ function arrTakeEveryX_fn() {
135139 local -r index=$2
136140 (( (index - offset) % modulo == 0 ))
137141 }
138- arrFilter arrFilterMod_arrIn arrFilterMod_arrOut arrFilterMod_fn
139- unset arrFilterMod_fn
142+ arrFilter arrTakeEveryX_arrIn arrTakeEveryX_arrOut arrTakeEveryX_fn
143+ unset arrTakeEveryX_fn
140144}
141145
142146function arrStringEntryMaxLength() {
@@ -148,6 +152,7 @@ function arrStringEntryMaxLength() {
148152 fi
149153 local -rn arrStringEntryMaxLength_arr=$1
150154 shift 1 || traceAndDie " could not shift by 1"
155+ exitIfArgIsNotArray arrStringEntryMaxLength_arr 1
151156
152157 local -i i maxLength=0 arrLength=" ${# arrStringEntryMaxLength_arr[@]} "
153158 for (( i = 0 ; i < arrLength; ++ i)) ; do
0 commit comments