Skip to content

Commit 8480563

Browse files
committed
Use syntactic sugar instead of building lists by hand
1 parent dfbcc95 commit 8480563

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/ShellCheck/ASTLib.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ getOpts (gnu, arbitraryLongOpts) string longopts args = process args
177177
process [] = return []
178178
process (token:rest) = do
179179
case getLiteralStringDef "\0" token of
180-
'-':'-':[] -> return $ listToArgs rest
180+
"--" -> return $ listToArgs rest
181181
'-':'-':word -> do
182182
let (name, arg) = span (/= '=') word
183183
needsArg <-

src/ShellCheck/Analytics.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ prop_checkAssignAteCommand4 = verifyNot checkAssignAteCommand "A=foo ls -l"
394394
prop_checkAssignAteCommand5 = verify checkAssignAteCommand "PAGER=cat grep bar"
395395
prop_checkAssignAteCommand6 = verifyNot checkAssignAteCommand "PAGER=\"cat\" grep bar"
396396
prop_checkAssignAteCommand7 = verify checkAssignAteCommand "here=pwd"
397-
checkAssignAteCommand _ (T_SimpleCommand id (T_Assignment _ _ _ _ assignmentTerm:[]) list) =
397+
checkAssignAteCommand _ (T_SimpleCommand id [T_Assignment _ _ _ _ assignmentTerm] list) =
398398
-- Check if first word is intended as an argument (flag or glob).
399399
if firstWordIsArg list
400400
then
@@ -426,7 +426,7 @@ checkArithmeticOpCommand _ _ = return ()
426426

427427
prop_checkWrongArit = verify checkWrongArithmeticAssignment "i=i+1"
428428
prop_checkWrongArit2 = verify checkWrongArithmeticAssignment "n=2; i=n*2"
429-
checkWrongArithmeticAssignment params (T_SimpleCommand id (T_Assignment _ _ _ _ val:[]) []) =
429+
checkWrongArithmeticAssignment params (T_SimpleCommand id [T_Assignment _ _ _ _ val] []) =
430430
sequence_ $ do
431431
str <- getNormalString val
432432
match <- matchRegex regex str
@@ -2844,7 +2844,7 @@ checkTestArgumentSplitting params t =
28442844
then
28452845
-- Ksh appears to stop processing after unrecognized tokens, so operators
28462846
-- will effectively work with globs, but only the first match.
2847-
when (op `elem` ['-':c:[] | c <- "bcdfgkprsuwxLhNOGRS" ]) $
2847+
when (op `elem` [['-', c] | c <- "bcdfgkprsuwxLhNOGRS" ]) $
28482848
warn (getId token) 2245 $
28492849
op ++ " only applies to the first expansion of this glob. Use a loop to check any/all."
28502850
else

src/ShellCheck/Checks/Commands.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ checkWhileGetoptsCase = CommandCheck (Exactly "getopts") f
916916

917917
fromGlob t =
918918
case t of
919-
T_Glob _ ('[':c:']':[]) -> return [c]
919+
T_Glob _ ['[', c, ']'] -> return [c]
920920
T_Glob _ "*" -> return "*"
921921
T_Glob _ "?" -> return "?"
922922
_ -> Nothing

0 commit comments

Comments
 (0)