Skip to content

fix: handle file paths containing spaces - #102

Merged
shogo82148 merged 1 commit into
reviewdog:masterfrom
somaz94:fix/handle-paths-with-spaces
Aug 7, 2026
Merged

fix: handle file paths containing spaces#102
shogo82148 merged 1 commit into
reviewdog:masterfrom
somaz94:fix/handle-paths-with-spaces

Conversation

@somaz94

@somaz94 somaz94 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

FILES was a space-joined string passed unquoted to shellcheck, so any path containing a space got word-split into fragments that do not exist. shellcheck printed openBinaryFile: does not exist on stderr and the file was never actually linted. Because reviewdog is last in the pipeline, the exit code was unaffected, so this failed silently.

This collects matches into an array via -print0 and passes "${files[@]}". The awk shebang pass now emits NUL-separated output to match. No mapfile/readarray, so the macOS runner (bash 3.2) still works.

Validation

Run locally with shellcheck 0.11.0, the version action.yml pins.

Using this repo's own step 4 config (path: . + ./testdata, check_all_files_with_shebangs: true) against the new fixtures:

before: 13 argv entries, spaced paths shattered into ./testdata/space , dir/spaced , test.sh
after:   7 argv entries, paths intact

Also checked:

  • shellcheck --external-sources --severity=style script.sh is clean (same flags as the shellcheck-github-check step)
  • parses under bash 3.2.57 and 5.3.9
  • all four workflow step configs collect and exclude correctly
  • the no-match path still prints No matching files found to check. and exits 0 under set -u on bash 3.2
  • awk 'printf "%s%c", FILENAME, 0' verified to emit real NUL bytes on BSD awk for the macOS leg

Test fixtures

Added under testdata/space dir/ to cover both collection paths:

  • spaced test.sh has a space in both the directory and the filename, and exercises the pattern find
  • non-sh-test has a shebang and no .sh extension, and exercises the awk shebang find

Both names fall under the existing .gitattributes rules (*.sh and non-sh-test), so the Windows leg checks them out with LF and shebang matching still works.

Not addressed here

Step 4 lists overlapping paths (. and ./testdata), so testdata files are collected twice. That predates this change and is unaffected by it, so I left it alone.

closes: #41

@somaz94
somaz94 marked this pull request as ready for review August 3, 2026 06:24
somaz94 added a commit to somaz94/somaz94 that referenced this pull request Aug 3, 2026
@shogo82148
shogo82148 merged commit 0722bbd into reviewdog:master Aug 7, 2026
5 checks passed
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🚀 [bumpr] Bumped!
New version:v1.32.1
Changes:v1.32.0...v1.32.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sh file paths with spaces are not handled

2 participants