mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-07 13:31:36 -07:00
Merge branch 'bats-support' of https://github.com/damienrg/shellcheck
This commit is contained in:
commit
c97cb8cf54
5 changed files with 37 additions and 1 deletions
|
@ -425,6 +425,7 @@ getVariableFlow params t =
|
|||
|
||||
assignFirst T_ForIn {} = True
|
||||
assignFirst T_SelectIn {} = True
|
||||
assignFirst (T_BatsTest {}) = True
|
||||
assignFirst _ = False
|
||||
|
||||
setRead t =
|
||||
|
@ -442,6 +443,7 @@ leadType params t =
|
|||
T_Backticked _ _ -> SubshellScope "`..` expansion"
|
||||
T_Backgrounded _ _ -> SubshellScope "backgrounding &"
|
||||
T_Subshell _ _ -> SubshellScope "(..) group"
|
||||
T_BatsTest {} -> SubshellScope "@bats test"
|
||||
T_CoProcBody _ _ -> SubshellScope "coproc"
|
||||
T_Redirecting {} ->
|
||||
if fromMaybe False causesSubshell
|
||||
|
@ -482,6 +484,12 @@ getModifiedVariables t =
|
|||
guard $ op `elem` ["=", "*=", "/=", "%=", "+=", "-=", "<<=", ">>=", "&=", "^=", "|="]
|
||||
return (t, t, name, DataString $ SourceFrom [rhs])
|
||||
|
||||
T_BatsTest {} -> [
|
||||
(t, t, "lines", DataArray SourceExternal),
|
||||
(t, t, "status", DataString SourceInteger),
|
||||
(t, t, "output", DataString SourceExternal)
|
||||
]
|
||||
|
||||
-- Count [[ -v foo ]] as an "assignment".
|
||||
-- This is to prevent [ -v foo ] being unassigned or unused.
|
||||
TC_Unary id _ "-v" token -> maybeToList $ do
|
||||
|
@ -701,6 +709,12 @@ getReferencedVariables parents t =
|
|||
then concatMap (getIfReference t) [lhs, rhs]
|
||||
else []
|
||||
|
||||
T_BatsTest {} -> [ -- pretend @test references vars to avoid warnings
|
||||
(t, t, "lines"),
|
||||
(t, t, "status"),
|
||||
(t, t, "output")
|
||||
]
|
||||
|
||||
t@(T_FdRedirect _ ('{':var) op) -> -- {foo}>&- references and closes foo
|
||||
[(t, t, takeWhile (/= '}') var) | isClosingFileOp op]
|
||||
x -> getReferencedVariableCommand x
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue