From ea4176691d476573cf6eac168312dfa89b8525bb Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Fri, 30 Nov 2012 09:25:49 -0800 Subject: [PATCH] Added warning for fi }, and not for ) } --- ShellCheck/Parser.hs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index 00a84f8..e09b65c 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -1199,11 +1199,24 @@ readPattern = (readNormalWord `thenSkip` spacing) `sepBy1` (char '|' `thenSkip` readCompoundCommand = do id <- getNextId - cmd <- choice [ readBraceGroup, readArithmeticExpression, readSubshell, readCondition, readWhileClause, readUntilClause, readIfClause, readForClause, readCaseClause, readFunctionDefinition] + -- This is all Bash specific. fi } fails, but ) } works. + cmd <- do + x <- needsSeparator + return (True, x) + <|> do + x <- noSeparator + return (False, x) spacing redirs <- many readIoRedirect - return $ T_Redirecting id redirs $ cmd + when (fst cmd) $ optional $ do + try . lookAhead $ (spacing >> g_Rbrace) + parseProblem WarningC "Bash requires semicolon or linefeed before the } here." + return $ T_Redirecting id redirs $ snd cmd + + where + needsSeparator = choice [ readArithmeticExpression, readCondition, readWhileClause, readUntilClause, readIfClause, readForClause, readCaseClause] + noSeparator = choice [ readBraceGroup, readSubshell, readFunctionDefinition] readCompoundList = readTerm