Include shebang in AST traversal (fixes #1858)

This commit is contained in:
Vidar Holen 2020-03-16 21:36:41 -07:00
parent acee69676b
commit 7963eeab9d
2 changed files with 12 additions and 1 deletions

View File

@ -249,7 +249,11 @@ analyze f g i =
list <- mapM round group list <- mapM round group
return $ T_ForArithmetic id x y z list return $ T_ForArithmetic id x y z list
delve (T_Script id s l) = dl l $ T_Script id s delve (T_Script id shebang list) = do
newShebang <- round shebang
newList <- roundAll list
return $ T_Script id newShebang newList
delve (T_Function id a b name body) = d1 body $ T_Function id a b name delve (T_Function id a b name body) = d1 body $ T_Function id a b name
delve (T_Condition id typ token) = d1 token $ T_Condition id typ delve (T_Condition id typ token) = d1 token $ T_Condition id typ
delve (T_Extglob id str l) = dl l $ T_Extglob id str delve (T_Extglob id str l) = dl l $ T_Extglob id str

View File

@ -288,6 +288,13 @@ prop_deducesTypeFromExtension2 = result == [2079]
csScript = "(( 3.14 ))" csScript = "(( 3.14 ))"
} }
prop_canDisableShebangWarning = null $ result
where
result = checkWithSpec [] emptyCheckSpec {
csFilename = "file.sh",
csScript = "#shellcheck disable=SC2148\nfoo"
}
prop_shExtensionDoesntMatter = result == [2148] prop_shExtensionDoesntMatter = result == [2148]
where where
result = checkWithSpec [] emptyCheckSpec { result = checkWithSpec [] emptyCheckSpec {