diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dc25f3..125d0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Git (0.8.0) ### Added +- `disable=all` now conveniently disables all warnings - `external-sources=true` directive can be added to .shellcheckrc to make shellcheck behave as if `-x` was specified. - SC2286-SC2288: Warn when command name ends in a symbol like `/.)'"` diff --git a/shellcheck.1.md b/shellcheck.1.md index 070c3a4..1103acc 100644 --- a/shellcheck.1.md +++ b/shellcheck.1.md @@ -237,6 +237,7 @@ Valid keys are: The command can be a simple command like `echo foo`, or a compound command like a function definition, subshell block or loop. A range can be be specified with a dash, e.g. `disable=SC3000-SC4000` to exclude 3xxx. + All warnings can be disabled with `disable=all`. **enable** : Enable an optional check by name, as listed with **--list-optional**. diff --git a/src/ShellCheck/Checker.hs b/src/ShellCheck/Checker.hs index 514f97d..cce1063 100644 --- a/src/ShellCheck/Checker.hs +++ b/src/ShellCheck/Checker.hs @@ -306,6 +306,13 @@ prop_canDisableShebangWarning = null $ result csScript = "#shellcheck disable=SC2148\nfoo" } +prop_canDisableAllWarnings = result == [2086] + where + result = checkWithSpec [] emptyCheckSpec { + csFilename = "file.sh", + csScript = "#!/bin/sh\necho $1\n#shellcheck disable=all\necho `echo $1`" + } + prop_canDisableParseErrors = null $ result where result = checkWithSpec [] emptyCheckSpec { diff --git a/src/ShellCheck/Parser.hs b/src/ShellCheck/Parser.hs index b59ebc2..4f26a80 100644 --- a/src/ShellCheck/Parser.hs +++ b/src/ShellCheck/Parser.hs @@ -984,6 +984,7 @@ prop_readAnnotation4 = isWarning readAnnotation "# shellcheck cats=dogs disable= prop_readAnnotation5 = isOk readAnnotation "# shellcheck disable=SC2002 # All cats are precious\n" prop_readAnnotation6 = isOk readAnnotation "# shellcheck disable=SC1234 # shellcheck foo=bar\n" prop_readAnnotation7 = isOk readAnnotation "# shellcheck disable=SC1000,SC2000-SC3000,SC1001\n" +prop_readAnnotation8 = isOk readAnnotation "# shellcheck disable=all\n" readAnnotation = called "shellcheck directive" $ do try readAnnotationPrefix many1 linewhitespace @@ -1004,8 +1005,12 @@ readAnnotationWithoutPrefix sandboxed = do key <- many1 (letter <|> char '-') char '=' <|> fail "Expected '=' after directive key" annotations <- case key of - "disable" -> readRange `sepBy` char ',' + "disable" -> readElement `sepBy` char ',' where + readElement = readRange <|> readAll + readAll = do + string "all" + return $ DisableComment 0 1000000 readRange = do from <- readCode to <- choice [ char '-' *> readCode, return $ from+1 ]