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.
This commit is contained in:
parent
c1adc588fb
commit
c6c615217b
|
@ -257,7 +257,8 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
||||||
when (name `elem` unsupportedCommands) $
|
when (name `elem` unsupportedCommands) $
|
||||||
warnMsg id $ "'" ++ name ++ "' is"
|
warnMsg id $ "'" ++ name ++ "' is"
|
||||||
potentially $ do
|
potentially $ do
|
||||||
allowed <- Map.lookup name allowedFlags
|
allowed' <- Map.lookup name allowedFlags
|
||||||
|
allowed <- allowed'
|
||||||
(word, flag) <- listToMaybe $
|
(word, flag) <- listToMaybe $
|
||||||
filter (\x -> (not . null . snd $ x) && snd x `notElem` allowed) flags
|
filter (\x -> (not . null . snd $ x) && snd x `notElem` allowed) flags
|
||||||
return . warnMsg (getId word) $ name ++ " -" ++ flag ++ " is"
|
return . warnMsg (getId word) $ name ++ " -" ++ flag ++ " is"
|
||||||
|
@ -292,20 +293,19 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
||||||
"typeset"
|
"typeset"
|
||||||
] ++ if not isDash then ["local"] else []
|
] ++ if not isDash then ["local"] else []
|
||||||
allowedFlags = Map.fromList [
|
allowedFlags = Map.fromList [
|
||||||
("cd", ["L", "P"]),
|
("cd", Just ["L", "P"]),
|
||||||
("exec", []),
|
("exec", Just []),
|
||||||
("export", ["p"]),
|
("export", Just ["p"]),
|
||||||
("jobs", ["l", "p"]),
|
("jobs", Just ["l", "p"]),
|
||||||
("printf", []),
|
("printf", Just []),
|
||||||
("read", if isDash then ["r", "p"] else ["r"]),
|
("read", Just $ if isDash then ["r", "p"] else ["r"]),
|
||||||
("readonly", ["p"]),
|
("readonly", Just ["p"]),
|
||||||
("ulimit", if isDash then ["H", "S", "t", "f", "d", "s", "c", "m", "l", "p", "n"] else ["f"]),
|
("ulimit", if isDash then Nothing else Just ["f"]),
|
||||||
("umask", ["S"])
|
("umask", Just ["S"])
|
||||||
]
|
]
|
||||||
bashism t@(T_SourceCommand id src _) =
|
bashism t@(T_SourceCommand id src _) =
|
||||||
let name = fromMaybe "" $ getCommandName src
|
let name = fromMaybe "" $ getCommandName src
|
||||||
in do
|
in when (name == "source") $ warnMsg id "'source' in place of '.' is"
|
||||||
when (name == "source") $ warnMsg id "'source' in place of '.' is"
|
|
||||||
bashism _ = return ()
|
bashism _ = return ()
|
||||||
|
|
||||||
varChars="_0-9a-zA-Z"
|
varChars="_0-9a-zA-Z"
|
||||||
|
|
Loading…
Reference in New Issue