Skip to content
Vidar Holen edited this page Jan 21, 2015 · 7 revisions

The double quotes around this do nothing. Remove or escape them.

Problematic code:

echo "<img src="foo.png" />" > file.html

Correct code:

echo "<img src=\"foo.png\" />" > file.html

Rationale:

This warning triggers when an unquoted literal string is found between two double quoted strings. In many such cases (like the example) the quotes were supposed to be literal, and should be escaped. Without escaping, the quotes are simply removed, resulting in src=foo.png instead of src="foo.png".

It's common not to realize that double quotes can span multiple elements. For example, the following strings are identical:

http://"$user":"$password"@"$host"/"$path"
"http://$user:$password@$host/$path"

When ShellCheck detects the former style (i.e. the double quotes include only a single element each), it will suppress the warning.

Exceptions

If you know that the quotes are ineffectual but you prefer it stylistically, you can ignore this message.

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally