shellcheck
shellcheck copied to clipboard
[Feature Request] Disable then enable
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 couldn't find anything similar other than #2196 which is a "global" toggle, and not what I'm referring to here.
Problem
In many static analysers you can do this
// disable 1234
var something = that.Causes(theError); // error is not reported
and.this.AlsoCausesTheError(); // error is not reported
// enable 1234
foo.causeErrorAgain(); // error is reported
So we can disable a rule for one or more lines, then enable it again for the rest of the file.
Feature Request
Please consider something like this for shellcheck:
# shellcheck disable=SC1083
...
# shellcheck enable=SC1083
Alternatively put the SC disable commands into a commands block that shares the same shellcheck disabled entries:
# shellcheck disable=SCxxx
{
var something = that.Causes(theError); // error is not reported
and.this.AlsoCausesTheError(); // error is not reported
}
foo.causeErrorAgain(); // error is reported
``
That is a nice trick @leagris, thanks.
Sadly it doesn't work when using templating, as discussed here, but it's a nice workaround in other cases.
This would be useful for my use case too, which is that I have a shell script with a man page embedded in it.
Came across an instance of this yesterday..
I was thinking something like:
# shellcheck disable=SC1234:5
meaning disable the check for the next 5 lines.