mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-11 15:46:26 -07:00
SC2267: Warn about xargs -i (fixes #2058)
This commit is contained in:
parent
f100c2939e
commit
3104cec770
2 changed files with 15 additions and 0 deletions
|
@ -94,6 +94,7 @@ commandChecks = [
|
|||
,checkSudoArgs
|
||||
,checkSourceArgs
|
||||
,checkChmodDashr
|
||||
,checkXargsDashi
|
||||
]
|
||||
|
||||
optionalChecks = map fst optionalCommandChecks
|
||||
|
@ -1129,5 +1130,18 @@ checkChmodDashr = CommandCheck (Basename "chmod") f
|
|||
guard $ flag == "-r"
|
||||
return $ warn (getId t) 2253 "Use -R to recurse, or explicitly a-r to remove read permissions."
|
||||
|
||||
prop_checkXargsDashi1 = verify checkXargsDashi "xargs -i{} echo {}"
|
||||
prop_checkXargsDashi2 = verifyNot checkXargsDashi "xargs -I{} echo {}"
|
||||
prop_checkXargsDashi3 = verifyNot checkXargsDashi "xargs sed -i -e foo"
|
||||
prop_checkXargsDashi4 = verify checkXargsDashi "xargs -e sed -i foo"
|
||||
prop_checkXargsDashi5 = verifyNot checkXargsDashi "xargs -x sed -i foo"
|
||||
checkXargsDashi = CommandCheck (Basename "xargs") f
|
||||
where
|
||||
f t = sequence_ $ do
|
||||
opts <- parseOpts $ arguments t
|
||||
(option, value) <- lookup "i" opts
|
||||
return $ info (getId option) 2267 "GNU xargs -i is deprecated in favor of -I{}"
|
||||
parseOpts = getBsdOpts "0oprtxadR:S:J:L:l:n:P:s:e:E:i:I:"
|
||||
|
||||
return []
|
||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue