From 6d257bfa17917a1af5ec8738a2f6f145c9a310a1 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 17 Feb 2018 21:58:29 -0800 Subject: [PATCH] Warn about 'while!' and 'while:' --- ShellCheck/Parser.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index 89b54f0..4be7b7f 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -2582,11 +2582,14 @@ tryParseWordToken keyword t = try $ do str <- anycaseString keyword optional $ do - try . lookAhead $ char '[' - parseProblem ErrorC 1069 "You need a space before the [." - optional $ do - try . lookAhead $ char '#' - parseProblem ErrorC 1099 "You need a space before the #." + c <- try . lookAhead $ anyChar + let warning code = parseProblem ErrorC code $ "You need a space before the " ++ [c] ++ "." + case c of + '[' -> warning 1069 + '#' -> warning 1099 + '!' -> warning 1129 + ':' -> warning 1130 + _ -> return () lookAhead keywordSeparator when (str /= keyword) $