mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 18:25:17 +08:00
Fix handling of spaces in shebangs.
This commit is contained in:
@@ -2345,8 +2345,10 @@ ifParse p t f =
|
||||
prop_readShebang1 = isOk readShebang "#!/bin/sh\n"
|
||||
prop_readShebang2 = isWarning readShebang "!# /bin/sh\n"
|
||||
prop_readShebang3 = isNotOk readShebang "#shellcheck shell=/bin/sh\n"
|
||||
prop_readShebang4 = isWarning readShebang "! /bin/sh"
|
||||
readShebang = do
|
||||
try readCorrect <|> try readSwapped
|
||||
try readCorrect <|> try readSwapped <|> try readMissingHash
|
||||
many linewhitespace
|
||||
str <- many $ noneOf "\r\n"
|
||||
optional carriageReturn
|
||||
optional linefeed
|
||||
@@ -2359,6 +2361,15 @@ readShebang = do
|
||||
parseProblemAt pos ErrorC 1084
|
||||
"Use #!, not !#, for the shebang."
|
||||
|
||||
readMissingHash = do
|
||||
pos <- getPosition
|
||||
char '!'
|
||||
lookAhead $ do
|
||||
many linewhitespace
|
||||
char '/'
|
||||
parseProblemAt pos ErrorC 1104
|
||||
"Use #!, not just !, for the shebang."
|
||||
|
||||
verifyEof = eof <|> choice [
|
||||
ifParsable g_Lparen $
|
||||
parseProblem ErrorC 1088 "Parsing stopped here. Invalid use of parentheses?",
|
||||
|
Reference in New Issue
Block a user