Expand as follows:
mbfl_slot_spec(ARRAYNAME, KEY) → ARRAYNAME[KEY]
This is useful both to build other macros and in situations like the argument to the option
-v of printf
:
declare -A ARRY printf -v mbfl_slot_spec(ARRY, KEY) 'A%sC' 'B'
Expand as follows:
mbfl_slot_ref(ARRAYNAME, KEY) → ${ARRAYNAME[KEY]} mbfl_slot_qref(ARRAYNAME, KEY) → "${ARRAYNAME[KEY]}"
which evaluate to the value of the slot KEY in the array variable ARRAYNAME. These macros works with both indexed and associative arrays.
Expands into the expression:
ARRAYNAME[KEY]=EXPR
which stores the value of EXPR in the slot KEY of the array variable ARRAYNAME. This macro works with both indexed and associative arrays.
Expands into the expression:
ARRAYNAME[KEY]+=EXPR
which appends the value of EXPR in the slot KEY of the array variable ARRAYNAME. This macro works with both indexed and associative arrays.
Example:
mbfl_declare_assoc_array(PAIRS) mbfl_slot_set(PAIRS, 'abc', '123') mbfl_slot_append(PAIRS, 'abc', ' 456') mbfl_slot_qref(PAIRS, 'abc') ⇒ 123\ 456
Expand into the expression:
${#ARRAYNAME[KEY]}
which is meant to evaluate to the number of characters in the value of the slot KEY.
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.