From 28b10537ac08dd74727459e2d60b112cb2695862 Mon Sep 17 00:00:00 2001 From: koalaman Date: Tue, 23 Dec 2014 19:44:55 -0800 Subject: [PATCH] Updated SC2140 (markdown) --- SC2140.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SC2140.md b/SC2140.md index 2a94795..5731c9f 100644 --- a/SC2140.md +++ b/SC2140.md @@ -12,12 +12,12 @@ 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"`. -In other cases, like `echo "$USER"@"$HOSTNAME"`, they are merely pointless and can be removed for improved readability: `echo "$USER@HOSTNAME"`. +It's common not to realize that double quotes can span multiple elements. For example, the following strings are identical: -Note that in some of these cases, curly brackets would have to be added: `"$lastname"_"$firstname"` would be `"${lastname}_$firstname"`, otherwise it'd look for a variable named `$lastname_`. - -It's common to quote individual parts of a path: `"$dir"/"$file"`. This is pointless and hard to read, but rarely indicates a bug. ShellCheck doesn't warn in this particular case. + 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. ### Contraindications