From 42f7479fb894f81b3204c1d1e0e49d53e08354be Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Fri, 1 Jul 2016 22:02:06 -0700 Subject: [PATCH] Don't warn about missing shebang when using directives. --- ShellCheck/Analytics.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index d36b8b4..53a4d73 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -439,10 +439,16 @@ checkShebangParameters _ (T_Script id sb _) = prop_checkShebang1 = verifyNotTree checkShebang "#!/usr/bin/env bash -x\necho cow" prop_checkShebang2 = verifyNotTree checkShebang "#! /bin/sh -l " prop_checkShebang3 = verifyTree checkShebang "ls -l" -checkShebang params (T_Annotation _ _ t) = checkShebang params t +prop_checkShebang4 = verifyNotTree checkShebang "#shellcheck shell=sh\nfoo" +checkShebang params (T_Annotation _ list t) = + if any isOverride list then [] else checkShebang params t + where + isOverride (ShellOverride _) = True + isOverride _ = False checkShebang params (T_Script id sb _) = - [makeComment ErrorC id 2148 "Tips depend on target shell and yours is unknown. Add a shebang." - | not (shellTypeSpecified params) && sb == "" ] + [makeComment ErrorC id 2148 + "Tips depend on target shell and yours is unknown. Add a shebang." + | not (shellTypeSpecified params) && sb == "" ] prop_checkBashisms = verify checkBashisms "while read a; do :; done < <(a)" prop_checkBashisms2 = verify checkBashisms "[ foo -nt bar ]"