Diagnose multi-line quoted strings
For new checks and feature suggestions
- [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
- [x] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related
Here's a snippet or screenshot that shows a potential problem:
#!/bin/sh
echo "
echo Hello world
echo "
Here's what shellcheck currently says:
(nothing)
Here's what I wanted to see:
A warning about missing double-quote characters on the first and third echo commands
I know that the shell permits multi-line quoted strings, and that the above script is strictly legal.
But if an opening quotation mark is not closed on the same line in any script I write, it's almost certainly an error.
I've seen more complicated cases where shellcheck reports a problem caused by a missing quotation mark, but doesn't tell me where the actual problem is. The shell thinks the first line has the beginning of a long multi-line quoted string, and shellcheck thinks that's ok. I've had to search through the script to find the missing quotation mark. (I don't have an example of this at the moment.)
My first preference would be for shellcheck to complain by default about quotation marks that aren't matched on the same line, with an option to disable the warning.
My second preference would be a command-line option to tell shellcheck to complain about quotation marks that aren't matched on the same line.