shellcheck
shellcheck copied to clipboard
shellcheck should ignore multiline literal strings
For bugs
- Rule Id (if any, e.g. SC1000):
SC2006, SC1009, SC1072 - My shellcheck version (
shellcheck --versionor "online"):0.8.0 - [ ] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- [x] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
For new checks and feature suggestions
- [ ] 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 the problem:
echo "
.-. .-. .----. .-. .-. .---. .-. .-. .---. .---. .-. .----.
{ {_} | } |__} } | } | / {-. \ | { } | / {-. \ } }}_} } | } {-. \
| { } } } '__} } '--. } '--. \ '-} / { /\ } \ '-} / | } \ } '--. } '-} /
`-' `-' `----' `----' `----' `---' `-' `-' `---' `-'-' `----' `----'
"
Here's what shellcheck currently says:

Here's what I wanted or expected to see:
The multiple literal should be ignore.
The code is indeed malformed, and Shellcheck rightly complains about it.
$ echo "$BASH_VERSION"
5.1.9(1)-release
$ echo "
> .-. .-. .----. .-. .-. .---. .-. .-. .---. .---. .-. .----.
> { {_} | } |__} } | } | / {-. \ | { } | / {-. \ } }}_} } | } {-. \
> | { } } } '__} } '--. } '--. \ '-} / { /\ } \ '-} / | } \ } '--. } '-} /
> `-' `-' `----' `----' `----' `---' `-' `-' `---' `-'-' `----' `----'
> "
bash: command substitution: line 1: unexpected EOF while looking for matching `''
bash: command substitution: line 2: syntax error: unexpected end of file
bash: command substitution: line 1: unexpected EOF while looking for matching `''
bash: command substitution: line 2: syntax error: unexpected end of file
bash: command substitution: line 1: unexpected EOF while looking for matching `''
bash: command substitution: line 2: syntax error: unexpected end of file
bash: command substitution: line 1: unexpected EOF while looking for matching `''
bash: command substitution: line 2: syntax error: unexpected end of file
bash: command substitution: line 1: unexpected EOF while looking for matching `''
bash: command substitution: line 2: syntax error: unexpected end of file
bash: command substitution: line 1: unexpected EOF while looking for matching `''
bash: command substitution: line 2: syntax error: unexpected end of file
.-. .-. .----. .-. .-. .---. .-. .-. .---. .---. .-. .----.
{ {_} | } |__} } | } | / {-. \ | { } | / {-. \ } }}_} } | } {-. \
| { } } } '__} } '--. } '--. \ '-} / { /\ } \ '-} / | } \ } '--. } '-} /
-' ----' ---' -' -'-' ----'
and also
bash-2.04.0p96-release-2.04$ echo $BASH_VERSION
2.04.0(96)-release
bash-2.04.0p96-release-2.04$ echo "
> .-. .-. .----. .-. .-. .---. .-. .-. .---. .---. .-. .----.
> { {_} | } |__} } | } | / {-. \ | { } | / {-. \ } }}_} } | } {-. \
> | { } } } '__} } '--. } '--. \ '-} / { /\ } \ '-} / | } \ } '--. } '-} /
> `-' `-' `----' `----' `----' `---' `-' `-' `---' `-'-' `----' `----'
> "
bash-2.04.0p96-release: command substitution: line 1: unexpected EOF while looking for matching `''
bash-2.04.0p96-release: command substitution: line 2: syntax error: unexpected end of file
bash-2.04.0p96-release: command substitution: line 1: unexpected EOF while looking for matching `''
bash-2.04.0p96-release: command substitution: line 2: syntax error: unexpected end of file
bash-2.04.0p96-release: command substitution: line 1: unexpected EOF while looking for matching `''
bash-2.04.0p96-release: command substitution: line 2: syntax error: unexpected end of file
bash-2.04.0p96-release: command substitution: line 1: unexpected EOF while looking for matching `''
bash-2.04.0p96-release: command substitution: line 2: syntax error: unexpected end of file
bash-2.04.0p96-release: command substitution: line 1: unexpected EOF while looking for matching `''
bash-2.04.0p96-release: command substitution: line 2: syntax error: unexpected end of file
bash-2.04.0p96-release: command substitution: line 1: unexpected EOF while looking for matching `''
bash-2.04.0p96-release: command substitution: line 2: syntax error: unexpected end of file
.-. .-. .----. .-. .-. .---. .-. .-. .---. .---. .-. .----.
{ {_} | } |__} } | } | / {-. \ | { } | / {-. \ } }}_} } | } {-. \
| { } } } '__} } '--. } '--. \ '-} / { /\ } \ '-} / | } \ } '--. } '-} /
-' ----' ---' -' -'-' ----'
The issue isn't with the multiple lines; the issue is with backticks that don't contain valid commands.
Additionally, a literal string in bash is surround by $'' and not ""
Example: echo $'ls ``'