mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-11 15:46:26 -07:00
Fixed parsing for [] in =~ regex
This commit is contained in:
parent
1b8b3b84d0
commit
103b037921
1 changed files with 5 additions and 3 deletions
|
@ -326,13 +326,13 @@ readConditionContents single = do
|
||||||
<|> return False
|
<|> return False
|
||||||
readRegex = called "regex" $ do
|
readRegex = called "regex" $ do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
parts <- many1 (readGroup <|> readSingleQuoted <|> readDoubleQuoted <|> readDollar <|> readNormalLiteral "( " <|> readGlobLiteral)
|
parts <- many1 (readGroup <|> readSingleQuoted <|> readDoubleQuoted <|> readDollarExpression <|> readNormalLiteral "( " <|> readGlobLiteral)
|
||||||
disregard spacing
|
disregard spacing
|
||||||
return $ T_NormalWord id parts
|
return $ T_NormalWord id parts
|
||||||
where
|
where
|
||||||
readGlobLiteral = do
|
readGlobLiteral = do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
s <- many1 extglobStart
|
s <- many1 (extglobStart <|> oneOf "[]$")
|
||||||
return $ T_Literal id s
|
return $ T_Literal id s
|
||||||
readGroup = do -- Fixme: account for vars and quotes in groups
|
readGroup = do -- Fixme: account for vars and quotes in groups
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
|
@ -532,6 +532,7 @@ prop_readCondition2 = isOk readCondition "[[ (a = b) || (c = d) ]]"
|
||||||
prop_readCondition3 = isOk readCondition "[[ $c = [[:alpha:].~-] ]]"
|
prop_readCondition3 = isOk readCondition "[[ $c = [[:alpha:].~-] ]]"
|
||||||
prop_readCondition4 = isOk readCondition "[[ $c =~ *foo* ]]"
|
prop_readCondition4 = isOk readCondition "[[ $c =~ *foo* ]]"
|
||||||
prop_readCondition5 = isOk readCondition "[[ $c =~ f( ]] )* ]]"
|
prop_readCondition5 = isOk readCondition "[[ $c =~ f( ]] )* ]]"
|
||||||
|
prop_readCondition6 = isOk readCondition "[[ $c =~ ^[yY]$ ]]"
|
||||||
readCondition = called "test expression" $ do
|
readCondition = called "test expression" $ do
|
||||||
opos <- getPosition
|
opos <- getPosition
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
|
@ -811,7 +812,8 @@ readBraced = try $ do
|
||||||
char '}'
|
char '}'
|
||||||
return $ T_BraceExpansion id $ concat str
|
return $ T_BraceExpansion id $ concat str
|
||||||
|
|
||||||
readDollar = readDollarArithmetic <|> readDollarBraced <|> readDollarExpansion <|> readDollarVariable <|> readDollarSingleQuote <|> readDollarDoubleQuote <|> readDollarLonely
|
readDollar = readDollarExpression <|> readDollarLonely
|
||||||
|
readDollarExpression = readDollarArithmetic <|> readDollarBraced <|> readDollarExpansion <|> readDollarVariable <|> readDollarSingleQuote <|> readDollarDoubleQuote
|
||||||
|
|
||||||
prop_readDollarSingleQuote = isOk readDollarSingleQuote "$'foo\\\'lol'"
|
prop_readDollarSingleQuote = isOk readDollarSingleQuote "$'foo\\\'lol'"
|
||||||
readDollarSingleQuote = called "$'..' expression" $ do
|
readDollarSingleQuote = called "$'..' expression" $ do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue