Shell

Shell

Made by DeepSource

Trailing spaces after \ SH-1101

Anti-pattern
Major

\\ is used before the line break to break a line. But, if there are spaces after the backslash, the escape will apply to the space instead of the line break, and the command will not continue on the next line.

Delete the trailing spaces to make the line break work correctly.

Problematic code:

# There are spaces after the backslash:
echo hello \
     world

Preferred code:

# No spaces after the backslash:
echo hello \
     world

Exception:

If you do want a literal escaped space at the end of a line you can ignore this error, but please reconsider and use quotes instead. Trailing whitespace is invisible and frequently stripped on purpose (by editor settings / precommits) or accident (copy-paste), and therefore, should not be relied upon for correctness.