mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-13 08:33:20 -07:00
Merge pull request #2119 from josephcsible/refactors
Various refactorings
This commit is contained in:
commit
15ff87cf80
6 changed files with 28 additions and 35 deletions
|
@ -122,7 +122,7 @@ checkGetOpts str flags args f =
|
|||
toTokens = map (T_Literal (Id 0)) . words
|
||||
opts = fromMaybe [] $ f (toTokens str)
|
||||
actualFlags = filter (not . null) $ map fst opts
|
||||
actualArgs = map (\(_, (_, x)) -> onlyLiteralString x) $ filter (null . fst) opts
|
||||
actualArgs = [onlyLiteralString x | ("", (_, x)) <- opts]
|
||||
|
||||
-- Short options
|
||||
prop_checkGetOptsS1 = checkGetOpts "-f x" ["f"] [] $ getOpts (True, True) "f:" []
|
||||
|
@ -916,7 +916,7 @@ checkWhileGetoptsCase = CommandCheck (Exactly "getopts") f
|
|||
|
||||
fromGlob t =
|
||||
case t of
|
||||
T_Glob _ ('[':c:']':[]) -> return [c]
|
||||
T_Glob _ ['[', c, ']'] -> return [c]
|
||||
T_Glob _ "*" -> return "*"
|
||||
T_Glob _ "?" -> return "?"
|
||||
_ -> Nothing
|
||||
|
@ -951,7 +951,7 @@ checkCatastrophicRm = CommandCheck (Basename "rm") $ \t ->
|
|||
when (isRecursive t) $
|
||||
mapM_ (mapM_ checkWord . braceExpand) $ arguments t
|
||||
where
|
||||
isRecursive = any (`elem` ["r", "R", "recursive"]) . map snd . getAllFlags
|
||||
isRecursive = any ((`elem` ["r", "R", "recursive"]) . snd) . getAllFlags
|
||||
|
||||
checkWord token =
|
||||
case getLiteralString token of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue