From ef332217a1daad7e378054033f30c5e3fc8bc282 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Mon, 26 Nov 2012 22:49:23 -0800 Subject: [PATCH] Check for if[ foo ] --- ShellCheck/Parser.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index 335f2a2..211434c 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -1123,6 +1123,9 @@ tryWordToken s t = tryParseWordToken (string s) t `thenSkip` spacing tryParseWordToken parser t = try $ do id <- getNextId parser + optional (do + try . lookAhead $ char '[' + parseProblem ErrorC "You need a space before the [.") try $ lookAhead (keywordSeparator) return $ t id @@ -1162,7 +1165,7 @@ g_Semi = do notFollowedBy g_DSEMI tryToken ";" T_Semi -keywordSeparator = eof <|> disregard whitespace <|> (disregard $ oneOf ";()") +keywordSeparator = eof <|> disregard whitespace <|> (disregard $ oneOf ";()[") readKeyword = choice [ g_Then, g_Else, g_Elif, g_Fi, g_Do, g_Done, g_Esac, g_Rbrace, g_Rparen, g_DSEMI ]