Problem
At main commit a107134, __std_run_cleanup_hooks__ evaluates the pre-existing EXIT trap before registered hooks and paths. Because the saved command is evaluated inside the dispatcher function, a trap containing return returns from the dispatcher and skips all registered cleanup. A trap containing exit terminates the shell before library cleanup runs.
Both behaviors were reproduced: a registered hook did not create its marker after either trap 'return 0' EXIT or trap 'exit 7' EXIT was installed before registration.
The current composable-cleanup contract should not allow control flow in an older trap to bypass later registered cleanup.
Scope
- Isolate or sequence the original trap so
return and exit cannot skip registered hooks and paths.
- Preserve the original trap's observable side effects and intended final exit status.
- Define and document execution order and status precedence.
- Retain support for multiline commands and embedded single quotes.
Acceptance Criteria
- Registered hooks and paths run when the original trap contains
return.
- Registered hooks and paths run before the shell honors an explicit exit status from the original trap.
- Normal, multiline, and quoted original traps continue to run exactly once.
- The incoming shell exit status remains available to the original trap and cleanup hooks.
Validation
bats lib/bash/std/tests/lib_std.bats
./tests/validate.sh
git diff --check
Problem
At
maincommita107134,__std_run_cleanup_hooks__evaluates the pre-existingEXITtrap before registered hooks and paths. Because the saved command is evaluated inside the dispatcher function, a trap containingreturnreturns from the dispatcher and skips all registered cleanup. A trap containingexitterminates the shell before library cleanup runs.Both behaviors were reproduced: a registered hook did not create its marker after either
trap 'return 0' EXITortrap 'exit 7' EXITwas installed before registration.The current composable-cleanup contract should not allow control flow in an older trap to bypass later registered cleanup.
Scope
returnandexitcannot skip registered hooks and paths.Acceptance Criteria
return.Validation
bats lib/bash/std/tests/lib_std.bats./tests/validate.shgit diff --check