koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.45k stars 1.78k forks source link

SC2027 doesn't account for escaped quotes #2940

Closed ChemGuy88 closed 8 months ago

ChemGuy88 commented 8 months ago

For bugs

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/bash
fromPath="path/to/here"
echo "    \`fromPath\`: \""$fromPath"\"."

Here's what shellcheck currently says:

$ shellcheck myscript

[Line 3:](javascript:setPosition(3, 28))
echo "    \`fromPath\`: \""$fromPath"\"."
                           ^-- [SC2027](https://www.shellcheck.net/wiki/SC2027) (warning): The surrounding quotes actually unquote this. Remove or escape them.

$

Here's what I wanted or expected to see:

I expected my syntax to not raise a warning, since I'm doing exactly what it's telling me to do: to escape the quotes. I do not want to disable the warning because it's useful in other situations. I searched the issues on GitHub and the only other work-around i can think of is using unicode quotes, as seen here

Thanks and I appreciate any advice you can give.

ChemGuy88 commented 8 months ago

Sorry I realized my mistake right after posting this 😅