I am trying modify an array that I have passed as a parameter to a function. So far, I have an empty array outside of the function:
buckets=()
Then I have the function which takes in 2 arguments. The first argument is the empty array that I want to fill. The second argument is the name of the file that contains the data I want to use to fill the array.
So far, what I have done is create a temporary array. Then fill the temporary array with the contents of the file. This is how I do that:
fillarray ()
{
# Declare the paramater as a temporary array
declare -a tempArray=("${!1}")
# Fill it up
while IFS= read -r entry; do
tempArray+=("$entry")
done < <(jq -r '.data | .[].name' $2)
The final step is to set the parameter array(aka buckets) to be the contents of the temporary array which we just filled up. Any suggestions on how to go about doing this?