You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug / regression?] In file ignore directives (# shellcheck disable=<check_id>) are not specific & disable all checks instead (not just check_id)
#2975
Closed
fedy-cz opened this issue
Apr 25, 2024
· 1 comment
Stumbled upon this randomly, but it seems that shellcheck (v 0.9.0) ignores the rule numbers/IDs and just disables all the checks when ignore directives are used inside a file.
For example, here I try to ignore the rule SC2251:
#!/bin/bashset -o errexit -o pipefail -o noclobber -o nounset
# -allow a command to fail with !’s side effect on errexit# -use return value from ${PIPESTATUS[0]}, because ! hosed $?#shellcheck disable=SC2251! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]}-ne 4 ]];thenecho"I’m sorry, 'getopt --test' failed in this environment.">&2exit 1
fi
... So far so good.
But if I change the line from: #shellcheck disable=SC2251
to #shellcheck disable=SC1000
Nice catch! This was due to one of ShellCheck's design mistakes: making directives separate nodes in the AST that checks match against to identify problems.
In this case, the check looked for ! cmd inside various compound command bodies. It neglected to look for ! cmdinside directives inside the compound command bodies. As a result, any type of directive (whether or not related to disabling warnings) would cause this particular check not to recognize the problem it aimed to.
It was fortunately not a general problem with disabling specific codes, but it's definitely not the first bug caused by this design mistake, and it certainly won't be the last.
Shellcheck version: 0.9.0
Stumbled upon this randomly, but it seems that shellcheck (v 0.9.0) ignores the rule numbers/IDs and just disables all the checks when ignore directives are used inside a file.
For example, here I try to ignore the rule SC2251:
... So far so good.
But if I change the line from:
#shellcheck disable=SC2251
to
#shellcheck disable=SC1000
I still get no errors.
Other versions affected:
https://www.shellcheck.net/ seems to be affected as well.
The text was updated successfully, but these errors were encountered: