Skip to content
Vidar Holen edited this page Jul 27, 2021 · 1 revision

Quote repeated spaces to avoid them collapsing into one.

Problematic code:

echo Hello        World

Correct code:

echo "Hello        World"

Rationale:

ShellCheck found multiple unquoted spaces between words passed to echo. Due to the way arguments are interpreted and passed in the shell, these will collapse into a single space:

$ echo Hello        World
Hello World

If you want to output multiple spaces, such as when creating a notice or banner, make sure the spaces are quoted, e.g. by adding (or extending) double quotes to include them:

$ echo "Hello        World"
Hello        World

Exceptions:

If you're aware of this behavior and didn't want multiple spaces to show up in the output, you can either remove the unnecessary spaces or ignore this issue.

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature guerraart8 to find a specific , or see Checks.

Clone this wiki locally