mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-14 00:53:15 -07:00
Add support for coproc
This commit is contained in:
parent
895d83afc5
commit
a485482979
3 changed files with 35 additions and 2 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue