How to pass the value from variable inside the array list.
The below code works, it assigns the repo_libs elements to repo_list. Is there a way to read the value from variable to form the array name inside the array list.
if [[ "$service" == "all" || "$service" == "libs" ]] ; then
# below working
repo_list=("${repo_libs[@]}")
echo "repo_list : ${repo_list[*]}"
fi
Looking for statements like below
repo_list=(${repo_`echo $service`[@]})
repo_list=("${repo_$service[@]}")
seeing the error like below.
./build.sh: line 168: ${repo_`echo $service`[@]}: bad substitution
./build.sh: line 173: ${repo_$service[@]}: bad substitution
[EDIT] Here is the code using if .. else as an alternative approach that I am using.
if [ "$service" = "all" ] ; then
repo_list=("${repo_all[@]}")
elif [ "$service" = "libs" ] ; then
repo_list=("${repo_libs[@]}")
elif [ "$service" = "portlets" ] ; then
repo_list=("${repo_portlets[@]}")
else
repo_list=("$service")
fi