shellcheck
shellcheck copied to clipboard
support --stdin-filename when passing files via stdin
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
Here's a snippet or screenshot that shows the problem:
#!/bin/sh
[[ $# -eq 0 ]]
Here's what shellcheck currently says:
$ shellcheck test.sh
In test.sh line 2:
[[ $# -eq 0 ]]
^------------^ SC3010 (warning): In POSIX sh, [[ ]] is undefined.
For more information:
https://www.shellcheck.net/wiki/SC3010 -- In POSIX sh, [[ ]] is undefined.
$ shellcheck - <test.sh
In - line 2:
[[ $# -eq 0 ]]
^------------^ SC3010 (warning): In POSIX sh, [[ ]] is undefined.
For more information:
https://www.shellcheck.net/wiki/SC3010 -- In POSIX sh, [[ ]] is undefined.
Here's what I wanted or expected to see:
The output of - in the diagnostics is confusing, especially when passing other files. It's also problematic when using --external-sources as SCRIPTDIR isn't set to anything useful.
Would like to have an option like --stdin-filename so that I can pass test.sh and it'll use that name when processing stdin.
This feature would be useful. Right now I have to annotate stdin checks separately to distinguish them from one another.
This would be useful when hacking together a simple shellcheck wrapper where parsing shellcheck's JSON output is not worth it. For example, in markdown-shellcheck I have to use regexes to replace the - with the filename.