mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-24 07:05:43 -07:00
Add --exit-zero option to exit with 0 in case of shell errors or warnings
This commit is contained in:
parent
499c99372e
commit
94d5dd76ae
1 changed files with 20 additions and 4 deletions
|
@ -74,7 +74,8 @@ data Options = Options {
|
||||||
externalSources :: Bool,
|
externalSources :: Bool,
|
||||||
sourcePaths :: [FilePath],
|
sourcePaths :: [FilePath],
|
||||||
formatterOptions :: FormatterOptions,
|
formatterOptions :: FormatterOptions,
|
||||||
minSeverity :: Severity
|
minSeverity :: Severity,
|
||||||
|
exitZero :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultOptions = Options {
|
defaultOptions = Options {
|
||||||
|
@ -84,7 +85,8 @@ defaultOptions = Options {
|
||||||
formatterOptions = newFormatterOptions {
|
formatterOptions = newFormatterOptions {
|
||||||
foColorOption = ColorAuto
|
foColorOption = ColorAuto
|
||||||
},
|
},
|
||||||
minSeverity = StyleC
|
minSeverity = StyleC,
|
||||||
|
exitZero = False
|
||||||
}
|
}
|
||||||
|
|
||||||
usageHeader = "Usage: shellcheck [OPTIONS...] FILES..."
|
usageHeader = "Usage: shellcheck [OPTIONS...] FILES..."
|
||||||
|
@ -105,6 +107,8 @@ options = [
|
||||||
(NoArg $ Flag "list-optional" "true") "List checks disabled by default",
|
(NoArg $ Flag "list-optional" "true") "List checks disabled by default",
|
||||||
Option "" ["norc"]
|
Option "" ["norc"]
|
||||||
(NoArg $ Flag "norc" "true") "Don't look for .shellcheckrc files",
|
(NoArg $ Flag "norc" "true") "Don't look for .shellcheckrc files",
|
||||||
|
Option "" ["exit-zero"]
|
||||||
|
(NoArg $ Flag "exit-zero" "true") "Exit with status code 0 even if there are errors.",
|
||||||
Option "o" ["enable"]
|
Option "o" ["enable"]
|
||||||
(ReqArg (Flag "enable") "check1,check2..")
|
(ReqArg (Flag "enable") "check1,check2..")
|
||||||
"List of optional checks to enable (or 'all')",
|
"List of optional checks to enable (or 'all')",
|
||||||
|
@ -188,8 +192,15 @@ main = do
|
||||||
process flags files
|
process flags files
|
||||||
exitWith $ statusToCode status
|
exitWith $ statusToCode status
|
||||||
|
|
||||||
statusToCode status =
|
statusToCode status flags =
|
||||||
case status of
|
if getOption flags "exit-zero"
|
||||||
|
then case status of
|
||||||
|
NoProblems -> ExitSuccess
|
||||||
|
SomeProblems -> ExitSuccess
|
||||||
|
SyntaxFailure -> ExitFailure 3
|
||||||
|
SupportFailure -> ExitFailure 4
|
||||||
|
RuntimeException -> ExitFailure 2
|
||||||
|
else case status of
|
||||||
NoProblems -> ExitSuccess
|
NoProblems -> ExitSuccess
|
||||||
SomeProblems -> ExitFailure 1
|
SomeProblems -> ExitFailure 1
|
||||||
SyntaxFailure -> ExitFailure 3
|
SyntaxFailure -> ExitFailure 3
|
||||||
|
@ -312,6 +323,11 @@ parseOption flag options =
|
||||||
liftIO printOptional
|
liftIO printOptional
|
||||||
throwError NoProblems
|
throwError NoProblems
|
||||||
|
|
||||||
|
Flag "exit-zero" _ -> do
|
||||||
|
return options {
|
||||||
|
exitZero = True
|
||||||
|
}
|
||||||
|
|
||||||
Flag "help" _ -> do
|
Flag "help" _ -> do
|
||||||
liftIO $ putStrLn getUsageInfo
|
liftIO $ putStrLn getUsageInfo
|
||||||
throwError NoProblems
|
throwError NoProblems
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue