mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-07 13:31:36 -07:00
Parse FD move operations like 2>&1- correctly. Fixes #1180.
This commit is contained in:
parent
aa3b3fdc56
commit
cf608dc2f6
3 changed files with 11 additions and 1 deletions
|
@ -16,6 +16,7 @@
|
||||||
- Associative arrays are now respected in arithmetic contexts
|
- Associative arrays are now respected in arithmetic contexts
|
||||||
- SC1087 about `$var[@]` now correctly triggers on any index
|
- SC1087 about `$var[@]` now correctly triggers on any index
|
||||||
- Bad expansions in here documents are no longer ignored
|
- Bad expansions in here documents are no longer ignored
|
||||||
|
- FD move operations like {fd}>1- now parse correctly
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- SC1073: 'else if' is now parsed correctly and not like 'elif'
|
- SC1073: 'else if' is now parsed correctly and not like 'elif'
|
||||||
|
|
|
@ -1401,6 +1401,7 @@ prop_checkSpuriousExec4 = verifyNot checkSpuriousExec "if a; then exec b; fi"
|
||||||
prop_checkSpuriousExec5 = verifyNot checkSpuriousExec "exec > file; cmd"
|
prop_checkSpuriousExec5 = verifyNot checkSpuriousExec "exec > file; cmd"
|
||||||
prop_checkSpuriousExec6 = verify checkSpuriousExec "exec foo > file; cmd"
|
prop_checkSpuriousExec6 = verify checkSpuriousExec "exec foo > file; cmd"
|
||||||
prop_checkSpuriousExec7 = verifyNot checkSpuriousExec "exec file; echo failed; exit 3"
|
prop_checkSpuriousExec7 = verifyNot checkSpuriousExec "exec file; echo failed; exit 3"
|
||||||
|
prop_checkSpuriousExec8 = verifyNot checkSpuriousExec "exec {origout}>&1- >tmp.log 2>&1; bar"
|
||||||
checkSpuriousExec _ = doLists
|
checkSpuriousExec _ = doLists
|
||||||
where
|
where
|
||||||
doLists (T_Script _ _ cmds) = doList cmds
|
doLists (T_Script _ _ cmds) = doList cmds
|
||||||
|
|
|
@ -1716,8 +1716,15 @@ readIoFileOp = choice [g_DGREAT, g_LESSGREAT, g_GREATAND, g_LESSAND, g_CLOBBER,
|
||||||
readIoDuplicate = try $ do
|
readIoDuplicate = try $ do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
op <- g_GREATAND <|> g_LESSAND
|
op <- g_GREATAND <|> g_LESSAND
|
||||||
target <- readIoVariable <|> many1 digit <|> string "-"
|
target <- readIoVariable <|> digitsAndOrDash
|
||||||
return $ T_IoDuplicate id op target
|
return $ T_IoDuplicate id op target
|
||||||
|
where
|
||||||
|
-- either digits with optional dash, or a required dash
|
||||||
|
digitsAndOrDash = do
|
||||||
|
str <- many digit
|
||||||
|
dash <- (if null str then id else option "") $ string "-"
|
||||||
|
return $ str ++ dash
|
||||||
|
|
||||||
|
|
||||||
prop_readIoFile = isOk readIoFile ">> \"$(date +%YYmmDD)\""
|
prop_readIoFile = isOk readIoFile ">> \"$(date +%YYmmDD)\""
|
||||||
readIoFile = called "redirection" $ do
|
readIoFile = called "redirection" $ do
|
||||||
|
@ -1744,6 +1751,7 @@ prop_readIoRedirect3 = isOk readIoRedirect "4>&-"
|
||||||
prop_readIoRedirect4 = isOk readIoRedirect "&> lol"
|
prop_readIoRedirect4 = isOk readIoRedirect "&> lol"
|
||||||
prop_readIoRedirect5 = isOk readIoRedirect "{foo}>&2"
|
prop_readIoRedirect5 = isOk readIoRedirect "{foo}>&2"
|
||||||
prop_readIoRedirect6 = isOk readIoRedirect "{foo}<&-"
|
prop_readIoRedirect6 = isOk readIoRedirect "{foo}<&-"
|
||||||
|
prop_readIoRedirect7 = isOk readIoRedirect "{foo}>&1-"
|
||||||
readIoRedirect = do
|
readIoRedirect = do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
n <- readIoSource
|
n <- readIoSource
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue