-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2140
Vidar Holen edited this page Jan 21, 2015
·
7 revisions
echo "<img src="foo.png" />" > file.html
echo "<img src=\"foo.png\" />" > file.html
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.
If you know that the quotes are ineffectual but you prefer it stylistically, you can ignore this message.