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
Context
Bash
traphandlers 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
EXITbehavior./.lib/bash/std/README.md.Validation
./tests/validate.sh