From c6c615217b64a802f4a6a8f9be9832eed7b6139e Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 15 Jan 2019 19:19:45 -0800 Subject: [PATCH] Allow specifying that flags should not be checked for support. This was motivated by the fact that `-a` was missing from Dash's long list. --- src/ShellCheck/Checks/ShellSupport.hs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ShellCheck/Checks/ShellSupport.hs b/src/ShellCheck/Checks/ShellSupport.hs index 644cee2..2ffe30d 100644 --- a/src/ShellCheck/Checks/ShellSupport.hs +++ b/src/ShellCheck/Checks/ShellSupport.hs @@ -257,7 +257,8 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do when (name `elem` unsupportedCommands) $ warnMsg id $ "'" ++ name ++ "' is" potentially $ do - allowed <- Map.lookup name allowedFlags + allowed' <- Map.lookup name allowedFlags + allowed <- allowed' (word, flag) <- listToMaybe $ filter (\x -> (not . null . snd $ x) && snd x `notElem` allowed) flags return . warnMsg (getId word) $ name ++ " -" ++ flag ++ " is" @@ -292,20 +293,19 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do "typeset" ] ++ if not isDash then ["local"] else [] allowedFlags = Map.fromList [ - ("cd", ["L", "P"]), - ("exec", []), - ("export", ["p"]), - ("jobs", ["l", "p"]), - ("printf", []), - ("read", if isDash then ["r", "p"] else ["r"]), - ("readonly", ["p"]), - ("ulimit", if isDash then ["H", "S", "t", "f", "d", "s", "c", "m", "l", "p", "n"] else ["f"]), - ("umask", ["S"]) + ("cd", Just ["L", "P"]), + ("exec", Just []), + ("export", Just ["p"]), + ("jobs", Just ["l", "p"]), + ("printf", Just []), + ("read", Just $ if isDash then ["r", "p"] else ["r"]), + ("readonly", Just ["p"]), + ("ulimit", if isDash then Nothing else Just ["f"]), + ("umask", Just ["S"]) ] bashism t@(T_SourceCommand id src _) = let name = fromMaybe "" $ getCommandName src - in do - when (name == "source") $ warnMsg id "'source' in place of '.' is" + in when (name == "source") $ warnMsg id "'source' in place of '.' is" bashism _ = return () varChars="_0-9a-zA-Z"