Arrays
Index¶
arrays::to_lines¶
Print each element of an array on its own line. Output: stdout — one element per line
Arguments¶
- ... (array): elements to print
arrays::contains¶
Return true if the given value equals any of the remaining arguments. Comparison is literal: glob metacharacters in the needle match themselves. An empty haystack (needle only) always returns false.
Arguments¶
- $1 (needle): value to search for
- ... (haystack): candidate values to compare against
Exit codes¶
- 0: needle matches one of the haystack values
- 1: needle matches none of them
arrays::diff¶
Set difference: elements in first sorted array missing from second sorted array. Both arrays must already be sorted in ascending order; results are undefined for unsorted input. Empty arrays are handled correctly: an empty first array yields no output; an empty second array yields all elements of the first.
Arguments¶
- $1 (name): of first sorted array (variable name passed as a name-ref)
- $2 (name): of second sorted array (variable name passed as a name-ref)
Output on stdout¶
- Elements present in first array but not in second, one per line
arrays::from_env_override¶
Populate an array from a space-separated environment-variable override when that
variable is SET — even to the empty string — and from the given default elements when it is unset.
The distinction is the point: a set-but-empty override means "no elements", which a test needs in
order to clear a non-empty default, whereas an unset one means "use the defaults". ${VAR:-}
collapses the two cases and cannot express it.
Arguments¶
- $1 (name): of the output array (variable name passed as a name-ref; cleared and repopulated)
- $2 (name): of the override environment variable
- ... (default): elements to use when the override is unset