diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 78b5366..6230f5b 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -484,7 +484,7 @@ checkShebang params (T_Annotation _ list t) = checkShebang params (T_Script id sb _) = execWriter $ do unless (shellTypeSpecified params) $ do when (sb == "") $ - err id 2148 "Tips depend on target shell and yours is unknown. Add a shebang or a .bash, .ksh, .dash extension to the filename." + err id 2148 "Tips depend on target shell and yours is unknown. Add a shebang." when (executableFromShebang sb == "ash") $ warn id 2187 "Ash scripts will be checked as Dash. Add '# shellcheck shell=dash' to silence." unless (null sb) $ do diff --git a/src/ShellCheck/Checker.hs b/src/ShellCheck/Checker.hs index ac51ddd..2c5eea0 100644 --- a/src/ShellCheck/Checker.hs +++ b/src/ShellCheck/Checker.hs @@ -244,5 +244,35 @@ prop_sourcePartOfOriginalScript = -- #1181: -x disabled posix warning for 'sourc prop_spinBug1413 = null $ check "fun() {\n# shellcheck disable=SC2188\n> /dev/null\n}\n" +prop_deducesTypeFromExtension = null result + where + result = checkWithSpec [] emptyCheckSpec { + csFilename = "file.ksh", + csScript = "(( 3.14 ))" + } + +prop_deducesTypeFromExtension2 = result == [2079] + where + result = checkWithSpec [] emptyCheckSpec { + csFilename = "file.bash", + csScript = "(( 3.14 ))" + } + +prop_shExtensionDoesntMatter = result == [2148] + where + result = checkWithSpec [] emptyCheckSpec { + csFilename = "file.sh", + csScript = "echo 'hello world'" + } + +prop_sourcedFileUsesOriginalShellExtension = result == [2079] + where + result = checkWithSpec [("file.ksh", "(( 3.14 ))")] emptyCheckSpec { + csFilename = "file.bash", + csScript = "source file.ksh", + csCheckSourced = True + } + + return [] runTests = $quickCheckAll