8.5 Inspecting arrays

Preprocessor Macro: mbfl_slots_number (ARRAYNAME)

Expands into the expression:

${#ARRAYNAME[@]}

evaluating to the number of pairs in the array variable ARRAYNAME.

Preprocessor Macro: mbfl_slots_values (ARRAYNAME)
Preprocessor Macro: mbfl_slots_qvalues (ARRAYNAME)

Expand to a “list” of array values, respectively:

 mbfl_slots_values(ARRAYNAME)     →  ${ARRAYNAME[@]}
mbfl_slots_qvalues(ARRAYNAME)     → "${ARRAYNAME[@]}"
Preprocessor Macro: mbfl_slots_keys (ARRAYNAME)
Preprocessor Macro: mbfl_slots_qkeys (ARRAYNAME)

Expand to a “list” of array keys, respectively:

 mbfl_slots_keys(ARRAYNAME)       →  ${!ARRAYNAME[@]}
mbfl_slots_qkeys(ARRAYNAME)       → "${!ARRAYNAME[@]}"
Function: mbfl_array_is_empty ARRAY_VARNAME

Return successfully if the array is empty.

declare -a ARRY
mbfl_array_is_empty ARRY        ⇒ 0
ARRY=(a b c)
mbfl_array_is_empty ARRY        ⇒ 1
Function: mbfl_array_is_not_empty ARRAY_VARNAME

Return successfully if the array is not empty.

declare -a ARRY
mbfl_array_is_not_empty ARRY    ⇒ 1
ARRY=(a b c)
mbfl_array_is_not_empty ARRY    ⇒ 0
Function: mbfl_array_length ARRAY_VARNAME
Function: mbfl_array_length_var _RV ARRAY_VARNAME

Print the number of pairs in the array.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

declare -a ARRY
mbfl_array_length ARRY          -| 0
ARRY=(a b c)
mbfl_array_length ARRY          -| 3

local _RV
mbfl_array_length_var _RV ARRY
"$_RV"   -| 3

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.