Skip to content

Fix SC2086 shellcheck warnings in compiler-generated shell scripts#3098

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-shellcheck-warnings-batch-1
Nov 4, 2025
Merged

Fix SC2086 shellcheck warnings in compiler-generated shell scripts#3098
pelikhan merged 2 commits intomainfrom
copilot/fix-shellcheck-warnings-batch-1

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

Shellcheck reported SC2086 warnings (unquoted variables causing potential word splitting/globbing) in compiler-generated .lock.yml files across all workflows.

Changes

Compiler code generation:

  • pkg/workflow/artifacts.go - Quote path variables in find commands and $GITHUB_ENV redirects
  • pkg/workflow/safe_jobs.go - Quote path variables in find commands and $GITHUB_ENV redirects
  • pkg/workflow/sh/generate_git_patch.sh - Quote git ref variables ($BRANCH_NAME, $DEFAULT_BRANCH)

Before:

find /tmp/gh-aw/safeoutputs/ -type f -print
echo "VAR=value" >> $GITHUB_ENV
git show-ref --verify --quiet refs/heads/$BRANCH_NAME

After:

find "/tmp/gh-aw/safeoutputs/" -type f -print
echo "VAR=value" >> "$GITHUB_ENV"
git show-ref --verify --quiet "refs/heads/$BRANCH_NAME"

Test updates:

  • pkg/workflow/safe_output_helpers_test.go - Update expected strings to match quoted format

All 68 workflows recompiled with fixes applied.

Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Fix SC2086 shellcheck warnings in high-priority workflows (batch 1/3)</issue_title>
<issue_description>## Objective
Fix SC2086 shellcheck warnings (unquoted variables) in the first batch of affected workflows to improve code reliability and prevent potential word splitting issues.

Context

Static analysis identified 120+ instances of unquoted variables across 22 workflows. This task addresses the first batch of 7 high-traffic workflows. Part of discussion #3090.

Approach

Add double quotes around all variable references in shell script blocks within workflow markdown files.

Common Patterns to Fix

  1. GITHUB_ENV assignments:

    # Before
    echo "VAR=value" >> $GITHUB_ENV
    
    # After
    echo "VAR=value" >> "$GITHUB_ENV"
  2. Git commands:

    # Before
    git diff origin/$DEFAULT_BRANCH...$GITHUB_SHA
    
    # After
    git diff "origin/$DEFAULT_BRANCH...$GITHUB_SHA"
  3. GitHub API calls:

    # Before
    gh api .../pulls/$PR_NUMBER/reviewers
    
    # After
    gh api .../pulls/"$PR_NUMBER"/reviewers

Files to Modify

  • .github/workflows/artifacts-summary.md
  • .github/workflows/audit-workflows.md
  • .github/workflows/blog-auditor.md
  • .github/workflows/brave.md
  • .github/workflows/changeset.md
  • .github/workflows/ci-doctor.md
  • .github/workflows/cli-version-checker.md

Acceptance Criteria

  • All unquoted variables in shell script blocks have double quotes added
  • No changes to logic or command behavior
  • Workflows recompile successfully: gh aw compile --actionlint
  • No SC2086 warnings remain in modified workflows
  • All formatting and indentation preserved

Implementation Notes

AI generated by Plan Command for discussion #3090</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix SC2086 shellcheck warnings in high-priority workflows Fix SC2086 shellcheck warnings in compiler-generated shell scripts Nov 4, 2025
Copilot AI requested a review from pelikhan November 4, 2025 01:44
@pelikhan pelikhan marked this pull request as ready for review November 4, 2025 01:56
Copilot AI review requested due to automatic review settings November 4, 2025 01:56
@pelikhan pelikhan enabled auto-merge (squash) November 4, 2025 01:56
@pelikhan pelikhan merged commit 2e70d73 into main Nov 4, 2025
48 checks passed
@pelikhan pelikhan deleted the copilot/fix-shellcheck-warnings-batch-1 branch November 4, 2025 01:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds proper quoting around variables and file paths in shell scripts and GitHub Actions workflow files to prevent potential issues with word splitting and special characters.

  • Adds quotes around Git command variables in shell scripts (branch names, refs)
  • Adds quotes around file paths in find and echo commands
  • Adds quotes around $GITHUB_ENV environment variable references

Reviewed Changes

Copilot reviewed 62 out of 62 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/workflow/sh/generate_git_patch.sh Added quotes to Git branch/ref variables and commands
pkg/workflow/safe_output_helpers_test.go Updated test expectations to match quoted paths
pkg/workflow/safe_jobs.go Added quotes to file paths and $GITHUB_ENV in generated steps
pkg/workflow/artifacts.go Added quotes to file paths and $GITHUB_ENV in artifact download steps
Multiple .github/workflows/*.lock.yml files Regenerated workflow lockfiles with quoted paths and variables

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[task] Fix SC2086 shellcheck warnings in high-priority workflows (batch 1/3)

3 participants