-
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 SC1003 #3032
Comments
Perhaps the Exceptions section in the wiki could be altered.
https://www.shellcheck.net/wiki/SC1003
# As it is:
"If you want your single-quoted string to end in a backslash, you can
rewrite as 'string'\\ or ignore this warning."
# Possible edit:
"If you want for your single-quoted string to end in a backslash you can
rewrite it as 'string'\\, or if you're quoting a single backslash such as
in `tr -d '\\'`, you can ignore <https://www.shellcheck.net/wiki/ignore> this
warning."
…On Tue, Jul 30, 2024, 08:06 ale5000 ***@***.***> wrote:
For bugs
- Rule Id (if any, e.g. SC1000): SC1003
- My shellcheck version (shellcheck --version or "online"): online
- The rule's wiki page does not already cover this (e.g.
https://shellcheck.net/wiki/SC2086)
- I tried on https://www.shellcheck.net/ and verified that this is
still a problem on the latest commit
Here's a snippet or screenshot that shows the problem:
#!/bin/sh
echo 'abc test' | tr -d '\\'
Here's what shellcheck currently says:
echo 'abc test' | tr -d '\'
^-- SC1003 (info): Want to escape a single quote? echo 'This is how it'''s
done'.
Here's what I wanted or expected to see:
It is the backslash that is escaped, not the single quote.
The backslash in tr need to be escaped, otherwise bash say this:
echo 'abc test' | tr -d '\'
tr: warning: an unescaped backslash at end of string is not portable
—
Reply to this email directly, view it on GitHub
<#3032>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUF2F2YX5JDWTMJAQZQUQLTZO6TVZAVCNFSM6AAAAABLWSNLQOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZTQMBWHEZDEMA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@wileyhy a edit to the wiki is helpful indeed. but the case pointed out by OP is still valid I think. Not sure it will be possible to handle all the permutations with a nice and easy information message though. |
Because bash warn against this: |
It was meant as a point in an imaginary internal reasoning leading up to that it's hard to understand the exact intent of code. |
For bugs
shellcheck --version
or "online"): onlineHere's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
It is the backslash that is escaped, not the single quote.
The backslash in tr need to be escaped, otherwise bash say this:
The text was updated successfully, but these errors were encountered: