mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 21:53:29 +08:00
Parse empty and comment-only backtick expansions.
This commit is contained in:
@@ -811,6 +811,8 @@ prop_readBackTicked3 = isWarning readBackTicked "´grep \"\\\"\"´"
|
|||||||
prop_readBackTicked4 = isOk readBackTicked "`echo foo\necho bar`"
|
prop_readBackTicked4 = isOk readBackTicked "`echo foo\necho bar`"
|
||||||
prop_readBackTicked5 = isOk readSimpleCommand "echo `foo`bar"
|
prop_readBackTicked5 = isOk readSimpleCommand "echo `foo`bar"
|
||||||
prop_readBackTicked6 = isWarning readSimpleCommand "echo `foo\necho `bar"
|
prop_readBackTicked6 = isWarning readSimpleCommand "echo `foo\necho `bar"
|
||||||
|
prop_readBackTicked7 = isOk readSimpleCommand "`#inline comment`"
|
||||||
|
prop_readBackTicked8 = isOk readSimpleCommand "echo `#comment` \\\nbar baz"
|
||||||
readBackTicked = called "backtick expansion" $ do
|
readBackTicked = called "backtick expansion" $ do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
startPos <- getPosition
|
startPos <- getPosition
|
||||||
@@ -826,7 +828,7 @@ readBackTicked = called "backtick expansion" $ do
|
|||||||
suggestForgotClosingQuote startPos endPos "backtick expansion"
|
suggestForgotClosingQuote startPos endPos "backtick expansion"
|
||||||
|
|
||||||
-- Result positions may be off due to escapes
|
-- Result positions may be off due to escapes
|
||||||
result <- subParse subStart readCompoundList (unEscape subString)
|
result <- subParse subStart readTermOrNone (unEscape subString)
|
||||||
return $ T_Backticked id result
|
return $ T_Backticked id result
|
||||||
where
|
where
|
||||||
unEscape [] = []
|
unEscape [] = []
|
||||||
@@ -1390,6 +1392,12 @@ readAndOr = do
|
|||||||
then andOr
|
then andOr
|
||||||
else T_Annotation aid annotations andOr
|
else T_Annotation aid annotations andOr
|
||||||
|
|
||||||
|
readTermOrNone = do
|
||||||
|
allspacing
|
||||||
|
readTerm <|> do
|
||||||
|
eof
|
||||||
|
return []
|
||||||
|
|
||||||
readTerm = do
|
readTerm = do
|
||||||
allspacing
|
allspacing
|
||||||
m <- readAndOr
|
m <- readAndOr
|
||||||
|
Reference in New Issue
Block a user