Skip to content

Add composable cleanup and trap registration to lib_std.sh #54

@codeforester

Description

@codeforester

Context

Bash trap handlers overwrite previous handlers unless callers manually compose them. Scripts that need multiple cleanup responsibilities can accidentally lose earlier cleanup behavior. External shell libraries show the value of composable trap/cleanup helpers, but this repository should implement the behavior in Base style.

Scope

Add Base-native cleanup and trap registration helpers to lib_std.sh. Do not copy external implementations.

Acceptance Criteria

  • Callers can register multiple cleanup hooks without clobbering prior EXIT behavior.
  • Callers can remove a registered cleanup/trap hook when appropriate.
  • Cleanup path registration rejects dangerous paths such as an empty value or /.
  • Duplicate hook/path registration is handled predictably.
  • Existing trap behavior in current tests remains stable.
  • Public API and behavior are documented in lib/bash/std/README.md.
  • BATS coverage verifies stacking, removal, duplicate behavior, path safety, and source-once behavior.

Validation

  • Focused stdlib BATS coverage.
  • ./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