mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-09-21 11:19:26 +08:00
Added check for "#!/usr/bin/env bash -x"
This commit is contained in:
@@ -33,6 +33,7 @@ checks = concat [
|
|||||||
,[subshellAssignmentCheck]
|
,[subshellAssignmentCheck]
|
||||||
,[checkSpacefulness]
|
,[checkSpacefulness]
|
||||||
,[checkUnquotedExpansions]
|
,[checkUnquotedExpansions]
|
||||||
|
,[checkShebang]
|
||||||
]
|
]
|
||||||
|
|
||||||
runAllAnalytics = checkList checks
|
runAllAnalytics = checkList checks
|
||||||
@@ -223,6 +224,14 @@ bracedString l = concat $ deadSimple l
|
|||||||
isMagicInQuotes (T_DollarBraced _ l) | '@' `elem` (bracedString l) = True
|
isMagicInQuotes (T_DollarBraced _ l) | '@' `elem` (bracedString l) = True
|
||||||
isMagicInQuotes _ = False
|
isMagicInQuotes _ = False
|
||||||
|
|
||||||
|
prop_checkShebang1 = verifyFull checkShebang "#!/usr/bin/env bash -x\necho cow"
|
||||||
|
prop_checkShebang2 = verifyNotFull checkShebang "#! /bin/sh -l "
|
||||||
|
checkShebang (T_Script id sb _) m =
|
||||||
|
if (length $ words sb) > 2 then
|
||||||
|
let note = Note ErrorC $ "On most OS, shebangs can only specify a single parameter."
|
||||||
|
in Map.adjust (\(Metadata pos notes) -> Metadata pos (note:notes)) id m
|
||||||
|
else m
|
||||||
|
|
||||||
prop_checkForInQuoted = verify checkForInQuoted "for f in \"$(ls)\"; do echo foo; done"
|
prop_checkForInQuoted = verify checkForInQuoted "for f in \"$(ls)\"; do echo foo; done"
|
||||||
prop_checkForInQuoted2 = verifyNot checkForInQuoted "for f in \"$@\"; do echo foo; done"
|
prop_checkForInQuoted2 = verifyNot checkForInQuoted "for f in \"$@\"; do echo foo; done"
|
||||||
prop_checkForInQuoted3 = verify checkForInQuoted "for f in 'find /'; do true; done"
|
prop_checkForInQuoted3 = verify checkForInQuoted "for f in 'find /'; do true; done"
|
||||||
|
@@ -1338,8 +1338,8 @@ wtf = do
|
|||||||
readShebang = do
|
readShebang = do
|
||||||
try $ string "#!"
|
try $ string "#!"
|
||||||
str <- anyChar `reluctantlyTill` oneOf "\r\n"
|
str <- anyChar `reluctantlyTill` oneOf "\r\n"
|
||||||
optional $ carriageReturn
|
optional carriageReturn
|
||||||
linefeed
|
optional linefeed
|
||||||
return str
|
return str
|
||||||
|
|
||||||
readScript = do
|
readScript = do
|
||||||
|
Reference in New Issue
Block a user