BASH: shellcheck warning SC2178 for declare -n

238 Views Asked by At

New to shellcheck here. See pseudocode and error below.

#!/bin/bash
function throwAwayFunc() {
        local _array=();
}

function arraysFromArray() {
  local i _id; _id=$1;
  declare -n _array="${_id}";
#               ***^-- SC2178 (warning): Variable was used as an array but is now assigned a string.***
  for i in "${_array[@]}"; do
    makeArr "$i";
  done;
}

Edited to clarify context: I am, indeed, expecting an array here. Am I doing this wrong? My point here is that the declare -n here is, at worst, ambiguous, and yet, this is the error. So, can I ignore this?

0

There are 0 best solutions below