on macOS with it's zsh - the below script (snippet) did work with bash. I have two text files, the first one that keeps a variable of menu file we are working with now, the other one, that can be mane of them - showing the menu text (a1=Some menu description item) , and the command line (c1=Some command to run).
The following shell script:
CommandDesc="a$1"
CommandString="c$1" # The Command string ie. cmd3
case "$1" in
"")
for (( i=0; i<=$ans_menu_count; i++ ))
do
#eval var1="ans"$i"_opt" #creating a var ans1_opt
eval desc="a"$i #Creating a var ans1_desc
#echo "${!var1} : ${!var2}"
echo "$i : ${!desc}"
done ;
(The full script can be found here, above just a snippet: https://github.com/IoTPlay/menu_ansible/tree/master/ans-menu)
the above script, working with bash, produces an error bad substitution
at the line echo "$i : ${!desc}"
with zsh.
I read the other articles - but cannot see how to fix it. Any guidance please?
question from:
https://stackoverflow.com/questions/65876476/zsh-bad-substitution-for-echo 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…