Merge pull request #1906 from josephcsible/shellsupport
Simplify ShellSupport
This commit is contained in:
commit
30523555af
|
@ -289,10 +289,11 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
||||||
-- Get the literal options from a list of arguments,
|
-- Get the literal options from a list of arguments,
|
||||||
-- up until the first non-literal one
|
-- up until the first non-literal one
|
||||||
getLiteralArgs :: [Token] -> [(Id, String)]
|
getLiteralArgs :: [Token] -> [(Id, String)]
|
||||||
getLiteralArgs (first:rest) = fromMaybe [] $ do
|
getLiteralArgs = foldr go []
|
||||||
str <- getLiteralString first
|
where
|
||||||
return $ (getId first, str) : getLiteralArgs rest
|
go first rest = case getLiteralString first of
|
||||||
getLiteralArgs [] = []
|
Just str -> (getId first, str) : rest
|
||||||
|
Nothing -> []
|
||||||
|
|
||||||
-- Check a flag-option pair (such as -o errexit)
|
-- Check a flag-option pair (such as -o errexit)
|
||||||
checkOptions (flag@(fid,flag') : opt@(oid,opt') : rest)
|
checkOptions (flag@(fid,flag') : opt@(oid,opt') : rest)
|
||||||
|
@ -390,11 +391,10 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
||||||
("unset", Just ["f", "v"]),
|
("unset", Just ["f", "v"]),
|
||||||
("wait", Just [])
|
("wait", Just [])
|
||||||
]
|
]
|
||||||
bashism t@(T_SourceCommand id src _) =
|
bashism t@(T_SourceCommand id src _)
|
||||||
let name = fromMaybe "" $ getCommandName src
|
| getCommandName src == Just "source" = warnMsg id "'source' in place of '.' is"
|
||||||
in when (name == "source") $ warnMsg id "'source' in place of '.' is"
|
bashism (TA_Expansion _ (T_Literal id str : _))
|
||||||
bashism (TA_Expansion _ (T_Literal id str : _)) | str `matches` radix =
|
| str `matches` radix = warnMsg id "arithmetic base conversion is"
|
||||||
when (str `matches` radix) $ warnMsg id "arithmetic base conversion is"
|
|
||||||
where
|
where
|
||||||
radix = mkRegex "^[0-9]+#"
|
radix = mkRegex "^[0-9]+#"
|
||||||
bashism _ = return ()
|
bashism _ = return ()
|
||||||
|
|
Loading…
Reference in New Issue