In #464 and elsewhere it's noted that some warnings should be disabled on a whole-of-source basis because they're essentially trying to catch "newby errors", or because you're doing something unusual like running a custom version of [ instead of the built-in one. It would make sense if that could be embedded in the file rather than requiring a command-line option, or having to be repeated at each location where it's otherwise triggered.
That led me to thinking about two related options:
global directives that apply for the whole file
selecting groups of warnings by type (syntax, builtin-commands, expansions, arithmetic, redirections, posix, better-than-posix, obsolete-commands ... and probably others) and rank or strength (always-wrong-no-matter-what, wrong-unless-your-name-is-Stephen-or-Chet, almost-always-errors, warnings, newbie-errors, style-guide, super-picky)
In particular, "posix" and "better than posix" would be effectively mutually contradictory, so you'd only want one or the other. (Currently this would be selected based on the shebang line; it'd be nice to be explicit about it.)
Select coverage of a warning:
# shellcheck disable SC1007 # applies to the next line
# shellcheck lines 5 disable SC1007 # applies to the next 5 lines
# shellcheck scope disable SC1007 # applies to end of current compound command
# shellcheck global disable SC1007 # applies to rest of file
Select warnings by type or class:
# shellcheck global enable special-[ # rules where [ is treated as a special built-in
# shellcheck global enable posix # warnings about lack of POSIX compliance
# shellcheck global enable bash # suggestions where Bash has better ways
# of doing things, like [[ instead of [
# shellcheck global enable assignment # warnings about variable assignments
# shellcheck global enable arithmetic # warnings about arithmetic context
Select warnings by strength or rank:
# shellcheck global quiet # approximately the same as "disable all"
# shellcheck global normal
# shellcheck global nitpick
# shellcheck global lint
Allow combinations in one line:
# shellcheck global disable all enable errors enable redirection enable
In #464 and elsewhere it's noted that some warnings should be disabled on a whole-of-source basis because they're essentially trying to catch "newby errors", or because you're doing something unusual like running a custom version of
[
instead of the built-in one. It would make sense if that could be embedded in the file rather than requiring a command-line option, or having to be repeated at each location where it's otherwise triggered.That led me to thinking about two related options:
In particular, "posix" and "better than posix" would be effectively mutually contradictory, so you'd only want one or the other. (Currently this would be selected based on the shebang line; it'd be nice to be explicit about it.)
Select coverage of a warning:
Select warnings by type or class:
Select warnings by strength or rank:
Allow combinations in one line: