From 8111406f3851ec21b3d2cbc2a26c005d0b2d86ba Mon Sep 17 00:00:00 2001 From: Benjamin Gordon Date: Wed, 17 Jul 2019 17:42:40 -0600 Subject: [PATCH] Make SC2164 recommend die when running in portage Ebuilds should use "die" for errors instead of "exit" to integrate cleanly with the rest of the build system. --- src/ShellCheck/Analytics.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 3be1077..e6479f3 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -2815,14 +2815,15 @@ checkUncheckedCdPushdPopd params root = && not (name `elem` ["pushd", "popd"] && ("n" `elem` map snd (getAllFlags t))) && not (isCondition $ getPath (parentMap params) t)) $ warnWithFix (getId t) 2164 - ("Use '" ++ name ++ " ... || exit' or '" ++ name ++ " ... || return' in case " ++ name ++ " fails.") - (fixWith [replaceEnd (getId t) params 0 " || exit"]) + ("Use '" ++ name ++ " ... || " ++ exit ++ "' or '" ++ name ++ " ... || return' in case " ++ name ++ " fails.") + (fixWith [replaceEnd (getId t) params 0 (" || " ++ exit)]) checkElement _ = return () getName t = fromMaybe "" $ getCommandName t isSafeDir t = case oversimplify t of [_, str] -> str `matches` regex _ -> False regex = mkRegex "^/*((\\.|\\.\\.)/+)*(\\.|\\.\\.)?$" + exit = if isPortageBuild params then "die" else "exit" prop_checkLoopVariableReassignment1 = verify checkLoopVariableReassignment "for i in *; do for i in *.bar; do true; done; done" prop_checkLoopVariableReassignment2 = verify checkLoopVariableReassignment "for i in *; do for((i=0; i<3; i++)); do true; done; done"