Skip to content

Commit f8f6162

Browse files
committed
bc: exit if out arr given for arrFilter is non-empty
1 parent d91cf15 commit f8f6162

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utility/array-utils.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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[@]}"
@@ -130,6 +132,8 @@ function arrTakeEveryX() {
130132
local -ri offset=$4
131133
shift 4 || traceAndDie "could not shift by 4"
132134

135+
# arrFilter will check that arrFilterMod_arrIn and arrFilterMod_arrOut are arrays and out non empty
136+
133137
# shellcheck disable=SC2317 # is passed by name to arrFilter
134138
function arrFilterMod_fn() {
135139
local -r index=$2
@@ -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
151156

152157
local -i i maxLength=0 arrLength="${#arrStringEntryMaxLength_arr[@]}"
153158
for ((i = 0; i < arrLength; ++i)); do

0 commit comments

Comments
 (0)