mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 06:59:39 +08:00
Add support for coproc
This commit is contained in:
@@ -1459,7 +1459,11 @@ readPipe = do
|
||||
spacing
|
||||
return $ T_Pipe id ('|':qualifier)
|
||||
|
||||
readCommand = readCompoundCommand <|> readSimpleCommand
|
||||
readCommand = choice [
|
||||
readCompoundCommand,
|
||||
readCoProc,
|
||||
readSimpleCommand
|
||||
]
|
||||
|
||||
readCmdName = do
|
||||
f <- readNormalWord
|
||||
@@ -1797,6 +1801,26 @@ readFunctionDefinition = called "function" $ do
|
||||
|
||||
readFunctionName = many functionChars
|
||||
|
||||
prop_readCoProc1 = isOk readCoProc "coproc foo { echo bar; }"
|
||||
prop_readCoProc2 = isOk readCoProc "coproc { echo bar; }"
|
||||
prop_readCoProc3 = isOk readCoProc "coproc echo bar"
|
||||
readCoProc = called "coproc" $ do
|
||||
id <- getNextId
|
||||
try $ do
|
||||
string "coproc"
|
||||
whitespace
|
||||
choice [ try $ readCompoundCoProc id, readSimpleCoProc id ]
|
||||
where
|
||||
readCompoundCoProc id = do
|
||||
var <- optionMaybe $
|
||||
readVariableName `thenSkip` whitespace
|
||||
body <- readCompoundCommand
|
||||
return $ T_CoProc id var body
|
||||
readSimpleCoProc id = do
|
||||
body <- readSimpleCommand
|
||||
return $ T_CoProc id Nothing body
|
||||
|
||||
|
||||
readPattern = (readNormalWord `thenSkip` spacing) `sepBy1` (char '|' `thenSkip` spacing)
|
||||
|
||||
prop_readCompoundCommand = isOk readCompoundCommand "{ echo foo; }>/dev/null"
|
||||
|
Reference in New Issue
Block a user