Skip to content

quote-in-quotes

Shellsuspiciousno fixdefault: offshell/shellcheck

Reports a word made of two double-quoted strings with unquoted text between them, where a quoted part has a blank, as in "say "hi" now".

It is usually a quote that was meant to be inside the string, written without a backslash. The text between the quotes is outside any quotes, so it is split and globbed, and the words are not what the string looks like.

To fix, escape the inner quotes ("say \"hi\" now") or use single quotes outside.

Reported
a="x "\""$v"\"" y"
...
shell:
lint:
rules:
quote-in-quotes: warn # off (default), warn, error

Enabled by the presets: shell/shellcheck.

Suppress one line with sudsy-disable-next-line quote-in-quotes in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
shellcheck SC2140 partial Only a word whose middle part touches a space inside one of the two strings (the "a "\""$b"\"" idiom).