From d01b59a8270e08205c30e17e7964dd369dcf4bcc Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 13 Oct 2015 12:16:39 -0700 Subject: [PATCH] Don't warn about empty assignments when at end of command. --- ShellCheck/Parser.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index 964ff8e..429daaf 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -2071,6 +2071,8 @@ prop_readAssignmentWord7 = isOk readAssignmentWord "a[3$n'']=42" prop_readAssignmentWord8 = isOk readAssignmentWord "a[4''$(cat foo)]=42" prop_readAssignmentWord9 = isOk readAssignmentWord "IFS= " prop_readAssignmentWord9a= isOk readAssignmentWord "foo=" +prop_readAssignmentWord9b= isOk readAssignmentWord "foo= " +prop_readAssignmentWord9c= isOk readAssignmentWord "foo= #bar" prop_readAssignmentWord10= isWarning readAssignmentWord "foo$n=42" prop_readAssignmentWord11= isOk readAssignmentWord "foo=([a]=b [c] [d]= [e f )" prop_readAssignmentWord12= isOk readAssignmentWord "a[b <<= 3 + c]='thing'" @@ -2089,7 +2091,7 @@ readAssignmentWord = try $ do isEndOfCommand <- liftM isJust $ optionMaybe (try . lookAhead $ (disregard (oneOf "\r\n;&|)") <|> eof)) if not hasLeftSpace && (hasRightSpace || isEndOfCommand) then do - when (variable /= "IFS" && hasRightSpace) $ + when (variable /= "IFS" && hasRightSpace && not isEndOfCommand) $ parseNoteAt pos WarningC 1007 "Remove space after = if trying to assign a value (for empty string, use var='' ... )." value <- readEmptyLiteral