Skip to content

Files

Latest commit

 

History

History
35 lines (24 loc) · 878 Bytes

SC1143.md

File metadata and controls

35 lines (24 loc) · 878 Bytes

Pattern: Use of comment for backslash line continuation

Issue: -

Description

Backslash line continuations are not respected in comments, and the line instead simply terminates. This is a problem when commenting out one line in a multi-line command like the example.

Instead, either move the line away from its statement, or use an `# inline comment` in an unquoted backtick command substitution.

Example of incorrect code:

sed \
  -e "s/HOST/$HOSTNAME/g"   \
# -e "s/USER/$USER/g"       \
  -e "s/ARCH/$(uname -m)/g" \
  "$buildfile"

Example of correct code:

sed \
  -e "s/HOST/$HOSTNAME/g"   \
  -e "s/ARCH/$(uname -m)/g" \
  "$buildfile"

# This comment is moved out:
# -e "s/USER/$USER/g"       \

Further Reading