From eb1f83423dc3a2fd5ae44d5b080bdccf0883e12f Mon Sep 17 00:00:00 2001 From: Josh Chorlton Date: Sun, 23 May 2021 19:43:42 -0700 Subject: [PATCH] add check for set e and operator --- src/ShellCheck/Analytics.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index e61c30a..aece6e6 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -190,6 +190,7 @@ nodeChecks = [ ,checkDollarQuoteParen ,checkUselessBang ,checkTranslatedStringVariable + ,checkPipelineE ,checkModifiedArithmeticInRedirection ,checkBlatantRecursion ,checkBadTestAndOr @@ -3808,6 +3809,12 @@ checkUselessBang params t = when (hasSetE params) $ mapM_ check (getNonReturning x:rest -> x : dropLast rest _ -> [] +prop_checkPipelineE1 = verify checkPipelineE "set -e; echo hi && echo hello" +prop_checkPipelineE2 = verifyNot checkPipelineE "echo hi && echo hello" +checkPipelineE params x@(T_AndIf id _ _) = when (hasSetE params) $ + info id 3061 "&& operators running with -e set will not exit on error" +checkPipelineE _ _ = return () + prop_checkModifiedArithmeticInRedirection1 = verify checkModifiedArithmeticInRedirection "ls > $((i++))" prop_checkModifiedArithmeticInRedirection2 = verify checkModifiedArithmeticInRedirection "cat < \"foo$((i++)).txt\"" prop_checkModifiedArithmeticInRedirection3 = verifyNot checkModifiedArithmeticInRedirection "while true; do true; done > $((i++))"