Skip to content

local var="$(cmd)" in bats helper masks command-substitution exit status (SC2155) #291

Description

@codeforester

Summary

One line in the bats test helper combines local declaration and command-substitution assignment, which discards the substitution's exit status.

Details

integrations/bats/base_bats_helper.bash:24:

local launcher="$(base_bats_repo_root)/bin/base-bash"

local's own exit status overwrites the status of $(...), so a failure in base_bats_repo_root is silently swallowed and $launcher ends up built from an empty/partial string. This is the only occurrence of this pattern in the whole repo (verified by grep) — the rest of the codebase consistently declares-then-assigns for exactly this reason, making this an outlier.

Impact

A failure in resolving the repo root (e.g. BASH_SOURCE resolving oddly) is silently swallowed rather than surfaced, producing a broken $launcher path with no error.

Suggested fix

Split into local launcher; launcher="$(base_bats_repo_root)/bin/base-bash" || return 1.

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Status
Triage

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions