Skip to content

test(project): fail when a return-slot helper is called inside $( ) - #1174

Merged
Chemaclass merged 1 commit into
mainfrom
test/1173-return-slot-subshell-guard
Aug 13, 2026
Merged

test(project): fail when a return-slot helper is called inside $( )#1174
Chemaclass merged 1 commit into
mainfrom
test/1173-return-slot-subshell-guard

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1173

The return-slot pattern only works when the helper runs in the caller's
shell. Wrapped in $( ) the assignment happens in a subshell that exits
immediately, so the caller reads the previous value — silently, with no error
anywhere. That boundary produced #1145 and #1147, and cost another cycle while
fixing the coverage gate in #1171.

An audit of src/ finds no current instance, so this guards against
reintroduction rather than fixing anything.

💡 Changes

  • Project test listing functions that assign a _BASHUNIT_*_OUT slot in their body, failing if any call site wraps one in a command substitution
  • Indentation separates an in-body assignment from the slot's file-scope declaration — without it the scan blames the preceding function
  • Verified against a fixture that is an instance and one that only calls the helper directly: a check over a clean tree cannot fail otherwise

The return-slot pattern only works when the helper runs in the caller's shell.
Wrapped in $( ) the assignment happens in a subshell that exits immediately,
so the caller reads the previous value -- silently, with no error anywhere.
That boundary produced #1145 and #1147, and cost another cycle while fixing
the coverage gate in #1171.

An audit of src/ finds no current instance, so this guards against
reintroduction rather than fixing anything.

Two details the scan has to get right, both of which I got wrong first:
indentation is what separates an assignment inside a body from the file-scope
declaration of the slot itself, and a check over a tree that is expected to be
clean cannot fail -- so the scan is verified against a fixture that is an
instance and one that only calls the helper directly.

Closes #1173
@Chemaclass Chemaclass added the enhancement New feature or request label Aug 13, 2026
@Chemaclass Chemaclass self-assigned this Aug 13, 2026
@Chemaclass
Chemaclass merged commit d12716d into main Aug 13, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the test/1173-return-slot-subshell-guard branch August 13, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant