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 SC1003 (escape single quote) #1548
Comments
You're right, this is a false positive. The wiki suggests writing I'm not sure if counting quotes in the line is the best heuristic, since
would not. I do see that this old warning has a pretty high false positive rate though, particularly for Perhaps it could be as simple as looking for something that isn't whitespace or quotes after the |
Another false positive with the $ cat foo
#!/usr/bin/bash
echo 'a\b\c\d' | cut -d '\' -f 2
$ shellcheck foo
In foo line 3:
echo 'a\b\c\d' | cut -d '\' -f 2
^-- SC1003: Want to escape a single quote? echo 'This is how it'\''s done'.
For more information:
https://www.shellcheck.net/wiki/SC1003 -- Want to escape a single quote? ec... The workaround would be using |
shellcheck sees '\\' as trying to escape the trailing quote (see koalaman/shellcheck#1548 ).
shellcheck sees '\\' as trying to escape the trailing quote (see koalaman/shellcheck#1548 ).
shellcheck sees '\\' as trying to escape the trailing quote (see koalaman/shellcheck#1548 ).
A less wordy workaround is |
For bugs
Here's a snippet or screenshot that shows the problem:
According to:
https://unix.stackexchange.com/questions/31947/how-to-add-a-newline-to-the-end-of-a-file
The following is a legit usecase of sed when trying to add a newline to the end of a file, (it does not append again if there is already a new line).
Shellsheck.net now thinks I want to escape the single quote. Maybe you could refine this errormessage to a literal string which has at least 3 single quotes, that would indicate that i tried to escape a single quote with the backslash.
But if I only have 2 single quotes, I think that would be exactly the reason to not escape anything and also not show this warning?
This would also make the rule to match:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
It should not say anything, the bashscript should be fine. But this is just my humble opinion. I just want to have my script to be "perfect" according to your rules :-).
Thanks for the great work I love your tool it helps me a lot!
The text was updated successfully, but these errors were encountered: