I am trying to pass a array into a function and whatever changes made to the array is reflected outside the function
function update_array()
{
${1[0]}="abc" # trying to change zero-index array to "abc" ,
# bad substitution error
}
foo=(foo bar)
update_array foo[@]
for i in ${foo[@]}
do
echo "$i" # currently changes are not reflected outside the function
done
My questions are
1) How do i access the index array eg: zero index array , in the function , what is the syntax for it
2) How do i make changes to this index array so that the changes are reflected outsite the function also