From 71bc26aefad6b28f2d2f4562a5f7ebb42e6a1cb8 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 3 Nov 2013 13:13:24 -0800 Subject: [PATCH] Fixed parsing of | outside of groups in =~ regex --- ShellCheck/Parser.hs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index 234e49c..8208979 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -357,7 +357,14 @@ readConditionContents single = do <|> return False readRegex = called "regex" $ do id <- getNextId - parts <- many1 (readGroup <|> readSingleQuoted <|> readDoubleQuoted <|> readDollarExpression <|> readNormalLiteral "( " <|> readGlobLiteral) + parts <- many1 ( + readGroup <|> + readSingleQuoted <|> + readDoubleQuoted <|> + readDollarExpression <|> + readNormalLiteral "( " <|> + readPipeLiteral <|> + readGlobLiteral) disregard spacing return $ T_NormalWord id parts where @@ -375,6 +382,10 @@ readConditionContents single = do id <- getNextId str <- readGenericLiteral1 (singleQuote <|> doubleQuotable <|> oneOf "()") return $ T_Literal id str + readPipeLiteral = do + id <- getNextId + str <- string "|" + return $ T_Literal id str readCondTerm = readCondNot <|> readCondExpr readCondNot = do @@ -571,6 +582,7 @@ prop_readCondition5a= isOk readCondition "[[ $c =~ a(b) ]]" prop_readCondition5b= isOk readCondition "[[ $c =~ f( ($var ]]) )* ]]" prop_readCondition6 = isOk readCondition "[[ $c =~ ^[yY]$ ]]" prop_readCondition7 = isOk readCondition "[[ ${line} =~ ^[[:space:]]*# ]]" +prop_readCondition8 = isOk readCondition "[[ $l =~ ogg|flac ]]" readCondition = called "test expression" $ do opos <- getPosition id <- getNextId