Skip to content

Argument-validation helpers mix silent-return and hard-exit failure modes for the same class of caller error #284

Description

@codeforester

Summary

Some argument-name/type validators return an error code the caller can catch; others call base_std_fatal_error and terminate the whole process — for what is the same kind of mistake (an invalid array/variable-name argument).

Details

  • lib/bash/list/lib_list.sh:30 (__base_bash_libs_std_assert_public_variable_names__ ... || return 1) followed by :34-35 calling base_std_assert_variable_name / base_std_assert_indexed_array.
  • Implementations in lib/bash/std/lib_std.sh:3367-3380 are soft (return 1); :3412-3426 and :3448-3463 call base_std_fatal_errorexit. This pattern repeats across arg, str, app, cli.

Reproduced directly:

base_list_append __badname value   # returns 1, caller can catch it
base_list_append "1bad" value      # calls exit via base_std_fatal_error — kills the whole process/shell

The library's own README (README.md:431-433) says usage mistakes should "return 2" rather than exit, but the assert helpers don't follow that for this class of caller error.

Impact

A consuming script/interactive shell can be killed outright by what looks like a recoverable "bad argument" mistake, depending on which specific validator happens to fire.

Suggested fix

Make identifier/type validation consistently non-fatal (return an error code) within the same function, or explicitly document why array/variable-name validity is treated as a fatal contract violation while namespace-prefix validity is not.

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Status
Triage

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions