Skip to content

ci: fix BB_HASHSERVE conditional quoting inside bash -c - #16625

Merged
rpcme merged 1 commit into
master-nextfrom
fix/hashserv-quoting
Aug 9, 2026
Merged

rpcme merged 1 commit into
master-nextfrom
fix/hashserv-quoting

Conversation

@rpcme

@rpcme rpcme commented Aug 9, 2026

Copy link
Copy Markdown
Member

Problem

PR #16624 attempted to make BB_HASHSERVE/OEEquivHash conditional for fork PRs, but the fix didn't work because of shell quoting inside bash -c '...'.

The workflow uses sudo ... bash -c '...' with single quotes. Inside this, the escaped quotes \"\" produce literal quote characters — so:

if [ -n \"\" ]; then   # tests string '""' (two chars) → NON-EMPTY → TRUE!

This means the block always executes, writing an empty BB_HASHSERVE + OEEquivHash even for fork PRs.

Fix

Assign the GitHub expression to a shell variable first, then use proper shell variable expansion in the test:

HASHSERV=${{ vars[format('HASHSERV_{0}', ...)] }}
if [ -n "\$HASHSERV" ]; then
  echo BB_HASHSERVE = \"\$HASHSERV\" >> conf/local.conf
  echo BB_SIGNATURE_HANDLER = \"OEEquivHash\" >> conf/local.conf
fi

When the expression is empty (fork PRs), HASHSERV is empty, and [ -n "\$HASHSERV" ] correctly evaluates to false.

Unblocks fork PRs like #16292 (greengrass-lite).

The previous fix (PR #16624) used escaped quotes inside a
bash -c '...' single-quoted heredoc:
  if [ -n \"\" ]; then

Inside single quotes, \"\" produces literal quote characters,
which is a non-empty 2-char string - so the test always passes.

Fix: assign the GitHub expression to a shell variable first
(HASHSERV=<value>), then test with proper double-quoted shell
variable expansion: if [ -n "$HASHSERV" ]; then

This correctly evaluates to false when the expression is empty
(fork PRs where vars context is unavailable).
@rpcme
rpcme requested a review from a team as a code owner August 9, 2026 16:10
@rpcme
rpcme merged commit b6b32c1 into master-next Aug 9, 2026
7 of 11 checks passed
@rpcme
rpcme deleted the fix/hashserv-quoting branch August 9, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant