diff --git a/ShellCheck/Checker.hs b/ShellCheck/Checker.hs index ce63a75..3a7cd2e 100644 --- a/ShellCheck/Checker.hs +++ b/ShellCheck/Checker.hs @@ -158,5 +158,25 @@ prop_sourceDirectiveDoesntFollowFile = [("foo", "source bar"), ("bar", "baz=3")] "#shellcheck source=foo\n. \"$1\"; echo \"$baz\"" +prop_filewideAnnotationBase = [2086] == check "#!/bin/sh\necho $1" +prop_filewideAnnotation1 = null $ + check "#!/bin/sh\n# shellcheck disable=2086\necho $1" +prop_filewideAnnotation2 = null $ + check "#!/bin/sh\n# shellcheck disable=2086\ntrue\necho $1" +prop_filewideAnnotation3 = null $ + check "#!/bin/sh\n#unerlated\n# shellcheck disable=2086\ntrue\necho $1" +prop_filewideAnnotation4 = null $ + check "#!/bin/sh\n# shellcheck disable=2086\n#unrelated\ntrue\necho $1" +prop_filewideAnnotation5 = null $ + check "#!/bin/sh\n\n\n\n#shellcheck disable=2086\ntrue\necho $1" +prop_filewideAnnotation6 = null $ + check "#shellcheck shell=sh\n#unrelated\n#shellcheck disable=2086\ntrue\necho $1" +prop_filewideAnnotation7 = null $ + check "#!/bin/sh\n# shellcheck disable=2086\n#unrelated\ntrue\necho $1" + +prop_filewideAnnotationBase2 = [2086, 2181] == check "true\n[ $? == 0 ] && echo $1" +prop_filewideAnnotation8 = null $ + check "# Disable $? warning\n#shellcheck disable=SC2181\n# Disable quoting warning\n#shellcheck disable=2086\ntrue\n[ $? == 0 ] && echo $1" + return [] runTests = $quickCheckAll diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index 72d2e47..a1837ab 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -2563,6 +2563,7 @@ readScriptFile = do verifyShell pos (getShell sb) if isValidShell (getShell sb) /= Just False then do + allspacing annotationId <- getNextId annotations <- readAnnotations commands <- withAnnotations annotations readCompoundListOrEmpty