mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-16 10:03:08 -07:00
Replace !!! with pattern-matching where it's easy
This commit is contained in:
parent
6e5b5401c6
commit
a786f996a1
3 changed files with 8 additions and 14 deletions
|
@ -1237,8 +1237,7 @@ checkSudoArgs = CommandCheck (Basename "sudo") f
|
|||
where
|
||||
f t = sequence_ $ do
|
||||
opts <- parseOpts $ arguments t
|
||||
let nonFlags = [x | ("",(x, _)) <- opts]
|
||||
commandArg <- nonFlags !!! 0
|
||||
(_,(commandArg, _)) <- find (null . fst) opts
|
||||
command <- getLiteralString commandArg
|
||||
guard $ command `elem` builtins
|
||||
return $ warn (getId t) 2232 $ "Can't use sudo with builtins like " ++ command ++ ". Did you want sudo sh -c .. instead?"
|
||||
|
|
|
@ -79,9 +79,8 @@ prop_checkForDecimals3 = verifyNot checkForDecimals "declare -A foo; foo[1.2]=ba
|
|||
checkForDecimals = ForShell [Sh, Dash, BusyboxSh, Bash] f
|
||||
where
|
||||
f t@(TA_Expansion id _) = sequence_ $ do
|
||||
str <- getLiteralString t
|
||||
first <- str !!! 0
|
||||
guard $ isDigit first && '.' `elem` str
|
||||
first:rest <- getLiteralString t
|
||||
guard $ isDigit first && '.' `elem` rest
|
||||
return $ err id 2079 "(( )) doesn't support decimals. Use bc or awk."
|
||||
f _ = return ()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue