Readlist
readlist¶
Read a comma-separated list into an indexed array, modelled on readarray/mapfile. Accepts bare words, quoted strings, or Python-style bracket notation. Strips commas, brackets, and surrounding whitespace from each element. Defaults to READLIST as the target array name.
Example¶
readlist dev, prod, test
printf '%s\n' "${READLIST[@]}"
# => dev
# => prod
# => test
Arguments¶
- $1 (string): Optional: '-n
' to specify target array name - ... (string): One or more comma-separated values, optionally enclosed in []
Exit codes¶
- 0: Always