mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-14 17:13:08 -07:00
Fix handling of spaces in shebangs.
This commit is contained in:
parent
db0c8c2dc9
commit
f835c2d4c1
4 changed files with 21 additions and 5 deletions
|
@ -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?",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue