Fixed warning for 'exec foo; exit 3'
This commit is contained in:
parent
6905373b6c
commit
7fda86d6e2
|
@ -1241,6 +1241,7 @@ prop_checkSpuriousExec3 = verifyNot checkSpuriousExec "echo cow; exec foo"
|
||||||
prop_checkSpuriousExec4 = verifyNot checkSpuriousExec "if a; then exec b; fi"
|
prop_checkSpuriousExec4 = verifyNot checkSpuriousExec "if a; then exec b; fi"
|
||||||
prop_checkSpuriousExec5 = verifyNot checkSpuriousExec "exec > file; cmd"
|
prop_checkSpuriousExec5 = verifyNot checkSpuriousExec "exec > file; cmd"
|
||||||
prop_checkSpuriousExec6 = verify checkSpuriousExec "exec foo > file; cmd"
|
prop_checkSpuriousExec6 = verify checkSpuriousExec "exec foo > file; cmd"
|
||||||
|
prop_checkSpuriousExec7 = verifyNot checkSpuriousExec "exec file; echo failed; exit 3"
|
||||||
checkSpuriousExec = doLists
|
checkSpuriousExec = doLists
|
||||||
where
|
where
|
||||||
doLists (T_Script _ _ cmds) = doList cmds
|
doLists (T_Script _ _ cmds) = doList cmds
|
||||||
|
@ -1253,13 +1254,19 @@ checkSpuriousExec = doLists
|
||||||
doList elses
|
doList elses
|
||||||
doLists _ = return ()
|
doLists _ = return ()
|
||||||
|
|
||||||
doList t@(current:following:_) = do
|
stripCleanup = reverse . dropWhile cleanup . reverse
|
||||||
|
cleanup (T_Pipeline _ [cmd]) =
|
||||||
|
isCommandMatch cmd (`elem` ["echo", "exit"])
|
||||||
|
cleanup _ = False
|
||||||
|
|
||||||
|
doList = doList' . stripCleanup
|
||||||
|
doList' t@(current:following:_) = do
|
||||||
commentIfExec current
|
commentIfExec current
|
||||||
doList (tail t)
|
doList (tail t)
|
||||||
doList _ = return ()
|
doList' _ = return ()
|
||||||
|
|
||||||
commentIfExec (T_Pipeline id list) =
|
commentIfExec (T_Pipeline id list) =
|
||||||
mapM_ commentIfExec list
|
mapM_ commentIfExec $ take 1 list
|
||||||
commentIfExec (T_Redirecting _ _ f@(
|
commentIfExec (T_Redirecting _ _ f@(
|
||||||
T_SimpleCommand id _ (cmd:arg:_))) =
|
T_SimpleCommand id _ (cmd:arg:_))) =
|
||||||
when (f `isUnqualifiedCommand` "exec") $
|
when (f `isUnqualifiedCommand` "exec") $
|
||||||
|
|
Loading…
Reference in New Issue