SC2267: Warn about xargs -i (fixes #2058)
This commit is contained in:
parent
f100c2939e
commit
3104cec770
|
@ -6,6 +6,7 @@
|
|||
- SC2262/SC2263: Warn about aliases declared and used in the same parsing unit
|
||||
- SC2264: Warn about wrapper functions that blatantly recurse
|
||||
- SC2265/SC2266: Warn when using & or | with test statements
|
||||
- SC2267: Warn when using xargs -i instead of -I
|
||||
|
||||
### Fixed
|
||||
- SC1072/SC1073 now respond to disable annotations, though ignoring parse errors
|
||||
|
|
|
@ -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…
Reference in New Issue