I want to define a variable my_stacklist with the value for {mypc}_stacklist
so if mypc=kast I get to access the content of kast_stacklist via my_stacklist.
I thougt this was the same as my earlier questions about dynamic variables , but cant fix it with declare or eval.
I use bash on a RPi 4 with the latest OS.
# want to have a my_stacklist for the current mypc and associating stacklist {mypc}_stacklist
mypc=kast
kast_stacklist=( stack1 stack2 stack3 stack4 )
screen_stacklist=( stack1 stack2 stack3 )
# First attempt
xxxx=$(eval "echo ${mypc}_stacklist")
my_stacklist=$(eval "echo \$$xxxx")
printf "my_stacklist=${my_stacklist[@]}"
# Second attempt
#declare -n my_stacklist2=${xxxx[@]}
declare -n my_stacklist2=${xxxx}
printf "my_stacklist=${my_stacklist[@]}"
# i only get the first item instead of all items