diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 7906e7a..9ad53ae 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -2228,6 +2228,7 @@ prop_checkUnassignedReferences37= verifyNotTree checkUnassignedReferences "var=h prop_checkUnassignedReferences38= verifyTree (checkUnassignedReferences' True) "echo $VAR" prop_checkUnassignedReferences39= verifyNotTree checkUnassignedReferences "builtin export var=4; echo $var" prop_checkUnassignedReferences40= verifyNotTree checkUnassignedReferences ": ${foo=bar}" +prop_checkUnassignedReferences41= verifyNotTree checkUnassignedReferences "mapfile -t files <(cat); echo \"${files[@]}\"" checkUnassignedReferences = checkUnassignedReferences' False checkUnassignedReferences' includeGlobals params t = warnings diff --git a/src/ShellCheck/AnalyzerLib.hs b/src/ShellCheck/AnalyzerLib.hs index 1ff50b2..ba2c901 100644 --- a/src/ShellCheck/AnalyzerLib.hs +++ b/src/ShellCheck/AnalyzerLib.hs @@ -659,13 +659,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)