Skip to content

shellcheck fails with SC2043 for a for loop with ${{ }} #355

@nakamasato

Description

@nakamasato

Error

shellcheck reported issue in this script: SC2043:warning:1:13: This loop will only ever run once. Bad quoting or missing glob/expansion?

GitHub Actions

The following step causes the error. (I'm using an example in https://github.com/tj-actions/changed-files)

        run: |
          for file in ${{ steps.changed-files.outputs.shell_all_changed_files }}; do
            echo "$file was changed"
            shellcheck "$file"
          done

Is there any way to write this step to make shellcheck pass?

full yaml
name: shellcheck

on:
  pull_request:
    paths:
      - '**.sh'

jobs:
  shellcheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: changed shell scripts
        id: changed-files
        uses: tj-actions/changed-files@v39
        with:
          files_yaml: |
            shell:
              - '**.sh'
      - name: run shellcheck for all changed shell scripts
        if: steps.changed-files.outputs.shell_any_changed == 'true'
        run: |
          for file in ${{ steps.changed-files.outputs.shell_all_changed_files }}; do
            echo "$file was changed"
            shellcheck "$file"
          done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions