From 951073b74dd92110f33f7757bf754c93a3e4794a Mon Sep 17 00:00:00 2001 From: koalaman Date: Wed, 10 Jan 2018 10:10:55 -0800 Subject: [PATCH] Created SC1039 (markdown) --- SC1039.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 SC1039.md diff --git a/SC1039.md b/SC1039.md new file mode 100644 index 0000000..6e26e20 --- /dev/null +++ b/SC1039.md @@ -0,0 +1,37 @@ +## Remove indentation before end token (or use `<<-` and indent with tabs). + +### Problematic code: + +```sh +for f in *.png +do + cat << EOF +
+ EOF +done > index.html +``` + +### Correct code: + +```sh +for f in *.png +do + cat << EOF +
+EOF +done > index.html +``` +### Rationale: + +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 the script is reformatted, copy-pasted, or saved with a different editor. + +### Exceptions: + +If the line was supposed to be a literal part of the here document, consider choosing a less ambiguous token. \ No newline at end of file