Context
lib_list.sh and the array-oriented parts of lib_str.sh document caller-owned indexed arrays, but they currently validate only the variable name. Passing a scalar can silently coerce it into an indexed array, and passing an associative array reads values in hash order.
lib_arg.sh already has a local pattern for checking declared array kind before mutating caller-owned variables.
Scope
- Add or reuse a standard helper for checking declared Bash array kind.
- Require indexed arrays for
list_append, list_prepend, list_remove, list_contains, list_unique, list_length, str_split, str_join, and str_in_array where the argument is documented as an array.
- Preserve valid indexed-array behavior and in-place mutation semantics.
- Add BATS coverage for scalar and associative-array rejection.
- Update docs if callers must explicitly
declare -a result arrays before use.
Acceptance Criteria
- List and string array helpers reject scalar variables and associative arrays with clear diagnostics.
- Existing valid indexed-array examples continue to pass.
- The implementation follows existing Bash 4.2-compatible style and avoids nameref requirements.
./tests/validate.sh passes.
Context
lib_list.shand the array-oriented parts oflib_str.shdocument caller-owned indexed arrays, but they currently validate only the variable name. Passing a scalar can silently coerce it into an indexed array, and passing an associative array reads values in hash order.lib_arg.shalready has a local pattern for checking declared array kind before mutating caller-owned variables.Scope
list_append,list_prepend,list_remove,list_contains,list_unique,list_length,str_split,str_join, andstr_in_arraywhere the argument is documented as an array.declare -aresult arrays before use.Acceptance Criteria
./tests/validate.shpasses.