Context
Two verified string-library issues should be fixed together because both are small lib_str.sh API hardening items.
Findings
str_contains, str_starts_with, and str_ends_with do not call assert_arg_count. Missing arguments silently produce misleading predicate results.
str_split declares a local array named fields; if the caller also uses fields as the result array name, Bash scoping causes the assignment to hit the function-local array and the caller array remains unchanged.
Failure Scenarios
str_contains "needle-only" # currently returns success because needle defaults to empty
fields=()
str_split fields "a:b:c" ":" # caller array remains empty
Scope
- Add explicit arity checks to all string predicate helpers.
- Rename
str_split internal locals to collision-resistant private names.
- Add BATS coverage for missing predicate args and result variable names that match old internal names.
Acceptance Criteria
- Predicate helpers fail consistently on wrong arity.
str_split fields ... updates the caller-owned fields array.
- Existing string helper behavior remains unchanged for valid calls.
./tests/validate.sh passes.
Validation
Context
Two verified string-library issues should be fixed together because both are small
lib_str.shAPI hardening items.Findings
str_contains,str_starts_with, andstr_ends_withdo not callassert_arg_count. Missing arguments silently produce misleading predicate results.str_splitdeclares a local array namedfields; if the caller also usesfieldsas the result array name, Bash scoping causes the assignment to hit the function-local array and the caller array remains unchanged.Failure Scenarios
Scope
str_splitinternal locals to collision-resistant private names.Acceptance Criteria
str_split fields ...updates the caller-ownedfieldsarray../tests/validate.shpasses.Validation
./tests/validate.sh