shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

allow source-path to be relative to the shellcheckrc

Open alexmaras opened this issue 4 months ago • 0 comments

For new checks and feature suggestions

  • [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
  • [x] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related

I'm hoping to be able to specify the source-path in a shellcheckrc to be relative to the shellcheckrc itself. The use-case for this is for a project repository which stores shell scripts in various locations through the repo but frequently uses source "${PROJECT_ROOT}/blah/blah.sh to source files.

Without this, every developer has to either have the same path, or we have to dynamically create the shellcheck file. Having the source-path directive able to be relative to the shellcheckrc itself (maybe through some special CONSTANT_VAR?) would mean we can keep the shellcheckrc at the top of the repo and simplify things. At the moment, I'm using a script that runs the CI and developer shellchecks to create the shellcheckrc itself.

Here's a snippet or screenshot that shows a potential problem:

sheckcheckrc at the top of the repo

source-path=.
#!/bin/sh

source "${PROJECT_ROOT}/src/something/blah.sh"

Here's what shellcheck currently says:

 # I: Not following: ./src/something/blah.sh: openBinaryFile: does not exist (No such file or directory)

Here's what I wanted to see:

no error (if the file exists relative to the root of the project)

alexmaras avatar Oct 03 '25 10:10 alexmaras