Skip to content

Files

Latest commit

 

History

History
43 lines (30 loc) · 960 Bytes

SC1039.md

File metadata and controls

43 lines (30 loc) · 960 Bytes

Pattern: Indentation before << token

Issue: -

Description

The here-document delimiter will not be recognized if it is indented.

You can fix it in one of two ways:

  1. Simply remove the indentation, even though this may break formatting.
  2. Use <<- instead of <<, and indent the script with tabs only (spaces will not be recognized).

Removing the indentation is preferred, since the script won't suddenly break if it's reformatted, copy-pasted, or saved with a different editor.

Example of incorrect code:

for f in *.png
do
  cat << EOF
     <img src="$f" /><br/>
  EOF
done > index.html

Example of correct code:

for f in *.png
do
  cat << EOF
     <img src="$f" /><br/>
EOF
done > index.html

Exceptions

If the line was supposed to be a literal part of the here-document, consider choosing a less ambiguous token.

Further Reading