Skip to content

Use in-place string transformations #64

@codeforester

Description

@codeforester

Summary

Change lib/bash/str/lib_str.sh so string transformation helpers mutate named variables in place instead of printing transformed values for command substitution.

Motivation

The current str_lower, str_upper, and trim helpers encourage command substitution such as value=$(str_trim "$value"), which creates a subshell. Since these helpers are shell-library functions, the preferred API should avoid subshells and use validated variable names with printf -v.

Scope

  • Add a public stdlib assertion for valid Bash variable names.
  • Change string transformation helpers to accept variable names and mutate values in place.
  • Keep predicate helpers value-based because they do not transform data.
  • Keep split/join/member helpers result-variable or predicate style, but use the public stdlib assertion instead of the private validator.
  • Update README and BATS coverage.

Validation

  • Focused BATS for stdlib and string helpers.
  • ./tests/validate.sh.
  • git diff --check.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or product improvement

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions