The best way is to pass as position arguments. Nothing else. You may pass as string. But, but this way may cause some troubles. Example:
array=(one two three forfour five)
function show_passed_array(){
echo $@
}
or
function show_passed_array(){
while $# -gt 0;do
echo $1;shift
done
}
show_passed_array ${array[@]}
output:
one two three forfour five
You mean if array value has space symbols you must quoitquote elements first before pass for assesaccessing value by index in function use $1 $2 $3 ... position parameters. Where index 0 -> 1, 1 -> 2,... To iterate access it is best to use always $1 and after shiftShift. Nothing additional is needed. You may pass arguments without any array like thatthis:
show_pased_arrayshow_passed_array one two three forfour five
bash media automatically buildbuilds an array from passed arguments that passed them to function and then you have position arguments. ForemoreFurthermore when you write ${array[2]} you in real whitereally write consequent argument one one two three four and passed them to the function. So those calls are equivalent.