The following post solution works as expected:
Therefore - from his answer:
function copyFiles() {
arr=("$@")
for i in "${arr[@]}";
do
echo "$i"
done
}
array=("one 1" "two 2" "three 3")
copyFiles "${array[@]}"
The reason of this post is what if the following case happens:
copyFiles "${array[@]}" "Something More"
copyFiles "Something More" "${array[@]}"
Problem: I did do realize about the arguments sent, when they are received how parameters in the function - they are practically merged - so $1
and $2
does not work as expected any more, the "array" argument integrates with the other argument
I already did do a research:
Sadly typeset -n
does not work
and in:
does not work as expected - in that answer there is a comment indicating an issue - with a link with a demo testing/verification - about the array size (${#array[@]}
) being different within the function.
So how accomplish this goal?