-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive for 1072 when there's inline disable
directives
#1036
Comments
It's because the disable directive is in the wrong place. (source) The following raises no errors:
|
@Nightfirecat That's my point. It should be treated as referring to the line immediately following it or, if it's not supposed to ever be used there, throw an error indicating that. Instead it falsely reports a different error. |
I agree, you should at least be getting a warning. Scoping directives to statements wasn't as clever as I thought it would be |
@koalaman I assume this might not be that easy to fix. Do you mind if I add a note to the relevant page on the wiki (the one Nightfirecat linked to) that mentions this bug and recommends avoiding directives within Just so people have an obvious place to look for an answer until this can be resolved. edit - It seems it consistently throws 1072 no matter where the directive is placed within the |
Feel free to update the wiki. I suspect it's actually relatively easy to fix (in the sense of adding a warning), but I'll have to look more into that when I get a chance. |
Wiki updated on the Directive, SC1072 and Parser Error pages. I hopefully made the note clear but discreet. I'll try to keep an eye out to revert the changes when you get around to fixing this. Thanks! |
Now you should at least get an explicit warning rather than a weird parsing failure, both for elif/else/fi/done and for branches in statements. |
@koalaman I'll modify the wiki to mention that this bug will be fixed in the next version and is already fixed on |
I’m still able to regenerate this error on shellcheck.net with only the following code #!/bin/sh
[ ! ] |
There's an unhelpful hadolint error that simply says: > Dockerfile:3 SC1072 error: Fix any mentioned problems and try again. It is unclear what we're supposed to do here, and it could be a false positive because of koalaman/shellcheck#1036
For bugs
Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
No error exists in that code. The false positive does not occur if the
disable
directive is missing or at the block level (outside theif
or a function block).The text was updated successfully, but these errors were encountered: