Problem
The return-slot pattern only works when the helper runs in the caller's
shell. Wrap it in $( ) and the assignment happens in a subshell that exits
immediately, so the caller reads the previous value — silently, with no error
anywhere.
That boundary has produced real bugs (#1145, #1147) and cost another cycle
while fixing the coverage gate (#1171), where pct=$(…) discarded the totals
the gate needed.
An audit of src/ finds no current instance, so this is a guard against
reintroduction rather than a fix.
Proposal
A project test that lists functions assigning a _BASHUNIT_*_OUT slot in their
body and fails if any call site wraps one in a command substitution.
Two things it needs to get right, both of which I got wrong first:
- Indentation distinguishes an assignment inside a body from the file-scope
declaration of the slot itself. Without that the scan blames whichever
function precedes the declaration.
- A check that cannot fail proves nothing. The tree is expected to be
clean, so the scan is verified against a fixture that is an instance, and
against one that only calls the helper directly.
Problem
The return-slot pattern only works when the helper runs in the caller's
shell. Wrap it in
$( )and the assignment happens in a subshell that exitsimmediately, so the caller reads the previous value — silently, with no error
anywhere.
That boundary has produced real bugs (#1145, #1147) and cost another cycle
while fixing the coverage gate (#1171), where
pct=$(…)discarded the totalsthe gate needed.
An audit of
src/finds no current instance, so this is a guard againstreintroduction rather than a fix.
Proposal
A project test that lists functions assigning a
_BASHUNIT_*_OUTslot in theirbody and fails if any call site wraps one in a command substitution.
Two things it needs to get right, both of which I got wrong first:
declaration of the slot itself. Without that the scan blames whichever
function precedes the declaration.
clean, so the scan is verified against a fixture that is an instance, and
against one that only calls the helper directly.