First I've read about passing arrays in general -- all examples I saw first created temporary variable for array and then passed it. Taken from https://stackoverflow.com/a/26443029/210342
show_value () # array index
{
local -n myarray=$1
local idx=$2
echo "${myarray[$idx]}"
}
shadock=(ga bu zo meu)
show_value shadock 2
Is there a way to pass array directly as literal, i.e. without creating temporary variable?
I tried naive approach simply substituting the name with data, but I syntax error on "(".
Update:
I use openSUSE Leap 15.3 with bash 4.4. The above code of course works, but I would like to change the call into:
show_value (ga bu zo meu) 2
i.e. pass array data directly (without using extra variable).