Fixed incorrect parsing of [ foo -a -f bar ]

This commit is contained in:
Vidar Holen 2013-11-24 18:49:49 -08:00
parent d603ee1e89
commit 1011ae7b3c
1 changed files with 2 additions and 1 deletions

View File

@ -255,6 +255,7 @@ readConditionContents single = do
otherOp = try $ do otherOp = try $ do
id <- getNextId id <- getNextId
s <- readOp s <- readOp
when (s == "-a" || s == "-o") $ fail "Wrong operator"
return $ TC_Binary id typ s return $ TC_Binary id typ s
readCondUnaryExp = do readCondUnaryExp = do
@ -303,7 +304,6 @@ readConditionContents single = do
softCondSpacing softCondSpacing
return $ TC_And id typ x return $ TC_And id typ x
readCondOrOp = do readCondOrOp = do
id <- getNextId id <- getNextId
x <- try (string "||" <|> string "-o") x <- try (string "||" <|> string "-o")
@ -584,6 +584,7 @@ prop_readCondition5b= isOk readCondition "[[ $c =~ f( ($var ]]) )* ]]"
prop_readCondition6 = isOk readCondition "[[ $c =~ ^[yY]$ ]]" prop_readCondition6 = isOk readCondition "[[ $c =~ ^[yY]$ ]]"
prop_readCondition7 = isOk readCondition "[[ ${line} =~ ^[[:space:]]*# ]]" prop_readCondition7 = isOk readCondition "[[ ${line} =~ ^[[:space:]]*# ]]"
prop_readCondition8 = isOk readCondition "[[ $l =~ ogg|flac ]]" prop_readCondition8 = isOk readCondition "[[ $l =~ ogg|flac ]]"
prop_readCondition9 = isOk readCondition "[ foo -a -f bar ]"
readCondition = called "test expression" $ do readCondition = called "test expression" $ do
opos <- getPosition opos <- getPosition
id <- getNextId id <- getNextId