Added check for find / -exec foo && bar \;
This commit is contained in:
parent
3308ac9173
commit
1bc6086aec
|
@ -73,6 +73,7 @@ basicChecks = [
|
||||||
,checkNeedlessCommands
|
,checkNeedlessCommands
|
||||||
,checkQuotedCondRegex
|
,checkQuotedCondRegex
|
||||||
,checkForInCat
|
,checkForInCat
|
||||||
|
,checkFindExec
|
||||||
]
|
]
|
||||||
|
|
||||||
modifyMap = modify
|
modifyMap = modify
|
||||||
|
@ -254,6 +255,29 @@ checkForInLs (T_ForIn _ f [T_NormalWord _ [T_DollarExpansion id [x]]] _) =
|
||||||
checkForInLs _ = return ()
|
checkForInLs _ = return ()
|
||||||
|
|
||||||
|
|
||||||
|
prop_checkFindExec1 = verify checkFindExec "find / -name '*.php' -exec rm {};"
|
||||||
|
prop_checkFindExec2 = verify checkFindExec "find / -exec touch {} && ls {} \\;"
|
||||||
|
prop_checkFindExec3 = verify checkFindExec "find / -execdir cat {} | grep lol +"
|
||||||
|
prop_checkFindExec4 = verifyNot checkFindExec "find / -name '*.php' -exec foo {} +"
|
||||||
|
prop_checkFindExec5 = verifyNot checkFindExec "find / -execdir bash -c 'a && b' \\;"
|
||||||
|
checkFindExec (T_SimpleCommand _ _ t) | isBrokenFind t =
|
||||||
|
let wordId = getId $ last t in
|
||||||
|
err wordId "Missing ';' or + terminating -exec. You can't use |/||/&&, and ';' has to be a separate, quoted argument."
|
||||||
|
|
||||||
|
where
|
||||||
|
isBrokenFind (w:r) = w `isCommand` "find" && broken r False
|
||||||
|
isBrokenFind _ = False
|
||||||
|
|
||||||
|
broken [] v = v
|
||||||
|
broken (w:r) v = case getLiteralString w of
|
||||||
|
Just "-exec" -> broken r True
|
||||||
|
Just "-execdir" -> broken r True
|
||||||
|
Just "+" -> broken r False
|
||||||
|
Just ";" -> broken r False
|
||||||
|
_ -> broken r v
|
||||||
|
checkFindExec _ = return ()
|
||||||
|
|
||||||
|
|
||||||
prop_checkUnquotedExpansions1 = verifyFull checkUnquotedExpansions "rm $(ls)"
|
prop_checkUnquotedExpansions1 = verifyFull checkUnquotedExpansions "rm $(ls)"
|
||||||
prop_checkUnquotedExpansions2 = verifyFull checkUnquotedExpansions "rm foo$(date)"
|
prop_checkUnquotedExpansions2 = verifyFull checkUnquotedExpansions "rm foo$(date)"
|
||||||
prop_checkUnquotedExpansions3 = verifyFull checkUnquotedExpansions "[ $(foo) == cow ]"
|
prop_checkUnquotedExpansions3 = verifyFull checkUnquotedExpansions "[ $(foo) == cow ]"
|
||||||
|
|
Loading…
Reference in New Issue