From 3a041954d1b960e2578d81f799c5e1443675a543 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 24 May 2015 12:41:54 -0700 Subject: [PATCH] Don't warn about a&&b||c if c == printf --- ShellCheck/Analytics.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index bdbb31e..e5a536f 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -916,13 +916,14 @@ prop_checkShorthandIf = verify checkShorthandIf "[[ ! -z file ]] && scp file ho prop_checkShorthandIf2 = verifyNot checkShorthandIf "[[ ! -z file ]] && { scp file host || echo 'Eek'; }" prop_checkShorthandIf3 = verifyNot checkShorthandIf "foo && bar || echo baz" prop_checkShorthandIf4 = verifyNot checkShorthandIf "foo && a=b || a=c" +prop_checkShorthandIf5 = verifyNot checkShorthandIf "foo && rm || printf b" checkShorthandIf _ (T_AndIf id _ (T_OrIf _ _ (T_Pipeline _ _ t))) | not $ isOk t = info id 2015 "Note that A && B || C is not if-then-else. C may run when A is true." where isOk [t] = isAssignment t || fromMaybe False (do name <- getCommandBasename t - return $ name `elem` ["echo", "exit", "return"]) + return $ name `elem` ["echo", "exit", "return", "printf"]) isOk _ = False checkShorthandIf _ _ = return ()