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