Skip to content

Commit 950578a

Browse files
committed
Merge branch 'Flu-ignore-sc2015-true'
2 parents 85066dd + f78714e commit 950578a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ShellCheck/Analytics.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,15 @@ prop_checkShorthandIf6 = verifyNot checkShorthandIf "if foo && bar || baz; then
882882
prop_checkShorthandIf7 = verifyNot checkShorthandIf "while foo && bar || baz; do true; done"
883883
prop_checkShorthandIf8 = verify checkShorthandIf "if true; then foo && bar || baz; fi"
884884
prop_checkShorthandIf9 = verifyNot checkShorthandIf "foo && [ -x /file ] || bar"
885+
prop_checkShorthandIf10 = verifyNot checkShorthandIf "foo && bar || true"
886+
prop_checkShorthandIf11 = verify checkShorthandIf "foo && bar || false"
885887
checkShorthandIf params x@(T_OrIf _ (T_AndIf id _ b) (T_Pipeline _ _ t))
886888
| not (isOk t || inCondition) && not (isTestCommand b) =
887889
info id 2015 "Note that A && B || C is not if-then-else. C may run when A is true."
888890
where
889891
isOk [t] = isAssignment t || fromMaybe False (do
890892
name <- getCommandBasename t
891-
return $ name `elem` ["echo", "exit", "return", "printf"])
893+
return $ name `elem` ["echo", "exit", "return", "printf", "true", ":"])
892894
isOk _ = False
893895
inCondition = isCondition $ getPath (parentMap params) x
894896
checkShorthandIf _ _ = return ()

0 commit comments

Comments
 (0)