-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Double braces can't be ignored #1329
Comments
I've played around with this a bit and it looks like certain directives (SC1009,SC1072,SC1073) cannot be disabled globally (i.e. per file). To clarify by example, this:
does the same as this:
I'm no expert but my guess is that has to do with the fact that they all have to do with Parse Errors. I don't think they could be disabled globally because ShellCheck needs to be able to parse code in order to lint it. As ShellCheck can not work without parsing, disabling those directives would be exactly the same as simply not using ShellCheck at all... |
Hello @balloonpopper and @Potherca, this is an interesting issue and I had similar ones. My solution is to use mostly variables whenever possible. An example: #/bin/bash
external_ip="{{ external_ip }}"
port="{{ port }}"
python -m http.server --bind "$external_ip" "$port" While this is admittedly an oversimplified example, it works in most cases from my experience. The added benefit is, that your templated shell scripts look much cleaner and easier to grasp most of the time. WDYT? |
Thanks for your replies. In my opinion, the setting should apply globally, regardless of the file contents. I should be able to throw any type of file at it, with any contents, and as long as the global ignore rule is there, it shouldn't trigger the error. Implementing that might not end up feasible due to how shellcheck parses the file, but that is my expectation for how it should behave. |
Did you find a workaround? These days ansible is used heavily for automation, so scripts contain (And this triggers SC1083) |
We use Ansible onsite to replace contents in placeholders dynamically within shell script "templates". Shellcheck complains about the placeholders (marked by "{{ name }}" which is fine, but I'm unable to use the disable directive to bypass the errors generated.
For bugs
Rule Id (if any, e.g. SC1000):
SC1009,SC1073,SC1072 (SC1083, SC1056, and SC1054 also fire but can be successfully bypassed)
My shellcheck version (
shellcheck --version
or "online"):0.5.0
I read the issue's wiki page, e.g. https://github.com/koalaman/shellcheck/wiki/SC2086
I tried on shellcheck.net and verified that this is still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
In a.sh line 4:
{{ abcd }}
^-- SC1009: The mentioned syntax error was in this brace group.
^-- SC1073: Couldn't parse this brace group. Fix to allow more checks.
In a.sh line 5:
^-- SC1072: Missing '}'. Fix any mentioned problems and try again.
Here's what I wanted or expected to see:
No errors reported
The text was updated successfully, but these errors were encountered: