diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 8f66aaf..78b5366 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 an extension to the filename." + err id 2148 "Tips depend on target shell and yours is unknown. Add a shebang or a .bash, .ksh, .dash extension to the filename." 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 67bd1c3..ac51ddd 100644 --- a/src/ShellCheck/Checker.hs +++ b/src/ShellCheck/Checker.hs @@ -51,9 +51,10 @@ tokenToPosition startMap t = fromMaybe fail $ do shellFromFilename filename = foldl mplus Nothing candidates where shellExtensions = [(".ksh", Ksh) - ,(".sh", Sh) ,(".bash", Bash) ,(".dash", Dash)] + -- The `.sh` is too generic to determine the shell: + -- We fallback to Bash in this case and emit SC2148 if there is no shebang candidates = map (\(ext,sh) -> if ext `isSuffixOf` filename then Just sh else Nothing) shellExtensions