In the "hostmenu" function below I want the concatenated strings $site and $system to be used to identify which array will be used to build the next menu. The functions "sitemenu" and "sysmenu" set the two required variables needed to set $sitesystem. All arrays are defined outside of any functions. The problem I am having is that "$sitesystem" ends up empty when select goes to use it. An echo of "$sitesystem shows the positional parameters "site""system" (example: "siteasysb") instead of the strings defined in the array "$siteasysb". How can I have have select successfully use the "$sitesystem" variable?
#!/bin/bash
main ()
{
sitemenu
sysmenu
hostmenu
}
## functions omitted which set $site and $system ##
hostmenu ()
{
PS3="Please choose a $site $system device to connect to.."
clear
sitesystem=("$site""$system")
echo $sitesystem
select opt in "${sitesystem[@]}"
do
case $opt in
## Omitted selected host section ##
;;
"Return to previous system menu")
sysmenu
;;
"Return to site menu")
sitemenu
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done
}
siteoptions=("sitea" "siteb" "Quit")
sysoptions=("sysa" "sysb" "Return to site menu" "Quit")
siteasysa=("a" "b" "Return to previous system menu" "Return to site menu" "Quit")
siteasysb=("a" "b" "Return to previous system menu" "Return to site menu" "Quit")
`main "$@"