ci: fix BB_HASHSERVE conditional quoting inside bash -c - #16625
Merged
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #16624 attempted to make
BB_HASHSERVE/OEEquivHashconditional for fork PRs, but the fix didn't work because of shell quoting insidebash -c '...'.The workflow uses
sudo ... bash -c '...'with single quotes. Inside this, the escaped quotes\"\"produce literal quote characters — so:This means the block always executes, writing an empty
BB_HASHSERVE+OEEquivHasheven for fork PRs.Fix
Assign the GitHub expression to a shell variable first, then use proper shell variable expansion in the test:
When the expression is empty (fork PRs),
HASHSERVis empty, and[ -n "\$HASHSERV" ]correctly evaluates to false.Unblocks fork PRs like #16292 (greengrass-lite).