Silence SC2103 when using 'set -e' (fixes #667)

This commit is contained in:
Cristian Adrián Ontivero 2019-01-13 16:18:39 +01:00
parent ec6f9e4d49
commit b34f4c1f4b
No known key found for this signature in database
GPG Key ID: 00B7629CAD43E113
1 changed files with 8 additions and 7 deletions

View File

@ -2133,6 +2133,8 @@ prop_checkCdAndBack2 = verifyNot checkCdAndBack "for f in *; do cd $f || continu
prop_checkCdAndBack3 = verifyNot checkCdAndBack "while [[ $PWD != / ]]; do cd ..; done" prop_checkCdAndBack3 = verifyNot checkCdAndBack "while [[ $PWD != / ]]; do cd ..; done"
prop_checkCdAndBack4 = verify checkCdAndBack "cd $tmp; foo; cd -" prop_checkCdAndBack4 = verify checkCdAndBack "cd $tmp; foo; cd -"
prop_checkCdAndBack5 = verifyNot checkCdAndBack "cd ..; foo; cd .." prop_checkCdAndBack5 = verifyNot checkCdAndBack "cd ..; foo; cd .."
prop_checkCdAndBack6 = verify checkCdAndBack "for dir in */; do cd \"$dir\"; some_cmd; cd ..; done"
prop_checkCdAndBack7 = verifyNot checkCdAndBack "set -e; for dir in */; do cd \"$dir\"; some_cmd; cd ..; done"
checkCdAndBack params = doLists checkCdAndBack params = doLists
where where
shell = shellType params shell = shellType params
@ -2163,14 +2165,13 @@ checkCdAndBack params = doLists
else findCdPair (b:rest) else findCdPair (b:rest)
_ -> Nothing _ -> Nothing
doList list = doList list =
let cds = filter ((== Just "cd") . getCmd) list in if hasSetE params
potentially $ do then return ()
cd <- findCdPair cds else let cds = filter ((== Just "cd") . getCmd) list
return $ info cd 2103 message in potentially $ do
cd <- findCdPair cds
message = "Use a ( subshell ) to avoid having to cd back." return $ info cd 2103 "Use a ( subshell ) to avoid having to cd back."
prop_checkLoopKeywordScope1 = verify checkLoopKeywordScope "continue 2" prop_checkLoopKeywordScope1 = verify checkLoopKeywordScope "continue 2"
prop_checkLoopKeywordScope2 = verify checkLoopKeywordScope "for f; do ( break; ); done" prop_checkLoopKeywordScope2 = verify checkLoopKeywordScope "for f; do ( break; ); done"