From 12ec6413800f4ae848d874ef191c26ef6ad581d3 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 8 Jul 2017 15:35:05 -0700 Subject: [PATCH] Updated SC1041 (markdown) --- SC1041.md | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/SC1041.md b/SC1041.md index 0a2ec98..0ebb139 100644 --- a/SC1041.md +++ b/SC1041.md @@ -1,3 +1,44 @@ -# Close matches include 'eof ' (!= 'eof'). +## Found 'eof' further down, but not on a separate line. -See companion warning [[SC1042]]. \ No newline at end of file + Close matches include '-eof' (!= 'eof'). + +### Problematic code: + +```sh +cat <<-eof +Hello World +-eof +``` + +### Correct code: + +```sh +cat <<- eof +Hello World +eof +``` +### Rationale: + +Your here document isn't properly terminated. + +There is a line containing the terminator you've chosen, but it's not by itself on a separate line. + +In the example code, the script uses `<<-eof`, which is the operator `<<-` followed by `eof`. The script therefore looks for `eof` and skips right past the intended terminator because it starts with a dash. + +You will get some companion SC1042 errors mentioning lines that contain the string as a substring, though they all point to the start of the here document and not the relevant line: + +``` +In foo line 4: +Hello +^-- SC1041: Found 'eof' further down, but not on a separate line. +^-- SC1042: Close matches include '-eof' (!= 'eof'). +``` + +Look at your here document and see which line was supposed to terminate it. Then ensure it matches the token exactly, and that it's on its own line with no text before or after. + +### Exceptions: + +None. + +--- +Note that SC1041 and SC1042 swapped numbers after v0.4.6 to improve the display order. This rare instance of number reuse was justified by them always occuring together on the same line. \ No newline at end of file