Issue 1759 mapfile and process substition

https://github.com/koalaman/shellcheck/issues/1759

When a simple process substition is used, this tripped up
the getMapfileArray function by making the last argument
not a variable
This commit is contained in:
Gandalf- 2019-12-22 23:11:20 -08:00
parent 9008a6833b
commit fdd02c94c0
2 changed files with 7 additions and 2 deletions

View file

@ -670,13 +670,17 @@ getModifiedVariableCommand base@(T_SimpleCommand id cmdPrefix (T_NormalWord _ (T
-- mapfile has some curious syntax allowing flags plus 0..n variable names
-- where only the first non-option one is used if any. Here we cheat and
-- just get the last one, if it's a variable name.
-- just get the last one, if it's a variable name, and omitting process
-- substitions.
getMapfileArray base arguments = do
lastArg <- listToMaybe (reverse arguments)
lastArg <- listToMaybe (filter notProcSub $ reverse arguments)
name <- getLiteralString lastArg
guard $ isVariableName name
return (base, lastArg, name, DataArray SourceExternal)
notProcSub (T_NormalWord _ (T_ProcSub{} :_)) = False
notProcSub _ = True
-- get all the array variables used in read, e.g. read -a arr
getReadArrayVariables args =
map (getLiteralArray . snd)