mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-22 14:23:53 -07:00
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.
This commit is contained in:
parent
a313b48ca6
commit
8111406f38
1 changed files with 3 additions and 2 deletions
|
@ -2815,14 +2815,15 @@ checkUncheckedCdPushdPopd params root =
|
||||||
&& not (name `elem` ["pushd", "popd"] && ("n" `elem` map snd (getAllFlags t)))
|
&& not (name `elem` ["pushd", "popd"] && ("n" `elem` map snd (getAllFlags t)))
|
||||||
&& not (isCondition $ getPath (parentMap params) t)) $
|
&& not (isCondition $ getPath (parentMap params) t)) $
|
||||||
warnWithFix (getId t) 2164
|
warnWithFix (getId t) 2164
|
||||||
("Use '" ++ name ++ " ... || exit' or '" ++ name ++ " ... || return' in case " ++ name ++ " fails.")
|
("Use '" ++ name ++ " ... || " ++ exit ++ "' or '" ++ name ++ " ... || return' in case " ++ name ++ " fails.")
|
||||||
(fixWith [replaceEnd (getId t) params 0 " || exit"])
|
(fixWith [replaceEnd (getId t) params 0 (" || " ++ exit)])
|
||||||
checkElement _ = return ()
|
checkElement _ = return ()
|
||||||
getName t = fromMaybe "" $ getCommandName t
|
getName t = fromMaybe "" $ getCommandName t
|
||||||
isSafeDir t = case oversimplify t of
|
isSafeDir t = case oversimplify t of
|
||||||
[_, str] -> str `matches` regex
|
[_, str] -> str `matches` regex
|
||||||
_ -> False
|
_ -> False
|
||||||
regex = mkRegex "^/*((\\.|\\.\\.)/+)*(\\.|\\.\\.)?$"
|
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_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"
|
prop_checkLoopVariableReassignment2 = verify checkLoopVariableReassignment "for i in *; do for((i=0; i<3; i++)); do true; done; done"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue