From 10b5e44ad0ce878576a9d2296643c6bad05c38ef Mon Sep 17 00:00:00 2001
From: Vidar Holen <spam@vidarholen.net>
Date: Thu, 4 Jul 2013 14:19:54 -0700
Subject: [PATCH] Improved help for missing here doc terminator.

---
 ShellCheck/Parser.hs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs
index 8e9834e..114652c 100644
--- a/ShellCheck/Parser.hs
+++ b/ShellCheck/Parser.hs
@@ -977,7 +977,12 @@ verifyHereDoc dashed quoted spacing hereInfo = do
 
 debugHereDoc pos endToken doc =
     if endToken `isInfixOf` doc
-        then parseProblemAt pos ErrorC ("Found " ++ endToken ++ " further down, but not by itself at the start of the line.")
+        then
+              let lookAt line = when (endToken `isInfixOf` line) $
+                        parseProblemAt pos ErrorC ("Close matches include '" ++ line ++ "' (!= '" ++ endToken ++ "').")
+              in do
+                    parseProblemAt pos ErrorC ("Found '" ++ endToken ++ "' further down, but not entirely by itself.")
+                    mapM_ lookAt (lines doc)
         else if (map toLower endToken) `isInfixOf` (map toLower doc)
             then parseProblemAt pos ErrorC ("Found " ++ endToken ++ " further down, but with wrong casing.")
             else parseProblemAt pos ErrorC ("Couldn't find end token `" ++ endToken ++ "' in the here document.")