From bb7e844125973025b82bbf9491b54933a05d5c70 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 27 Nov 2012 01:28:42 -0800 Subject: [PATCH] Added better message for missing ]/]] --- ShellCheck/Parser.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index cb0e040..bced3dd 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -429,8 +429,14 @@ readCondition = do then "You need spaces after the opening [ and before the closing ]." else "You need spaces after the opening [[ and before the closing ]]." condition <- readConditionContents single + cpos <- getPosition - close <- (try $ string "]]") <|> (string "]") + close <- (try $ string "]]") <|> (string "]") <|> do + let match = (if single then "]" else "]]") + parseProblemAt opos ErrorC $ "Couldn't find matching " ++ match ++ "." + parseProblem ErrorC $ "Expected " ++ match + fail "condition" + when (open == "[[" && close /= "]]") $ parseProblemAt cpos ErrorC "Did you mean ]] ?" when (open == "[" && close /= "]" ) $ parseProblemAt opos ErrorC "Did you mean [[ ?" return $ T_Condition id (if single then SingleBracket else DoubleBracket) condition