Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nakamasato opened this issue Sep 25, 2023 · 0 comments
Closed

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

nakamasato opened this issue Sep 25, 2023 · 0 comments

Comments

@nakamasato
Copy link

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
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

No branches or pull requests

1 participant