Results 1 to 3 of 3
Hi all,
Trying to build a series of options in a bash script and im fine with 1 menu but i want to put a sub menu in one of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-30-2012 #1Just Joined!
- Join Date
- Dec 2012
- Posts
- 6
submenus in bash
Hi all,
Trying to build a series of options in a bash script and im fine with 1 menu but i want to put a sub menu in one of the options...
#!/bin/bash
menu ()
{
clear
echo "-------------------------------"
echo " M A I N - M E N U"
echo " 1) option "
echo " 2) option "
echo " 3) option "
echo " 4) option "
echo "-------------------------------"
while
do
read action
case $action in
"1")
do something
;;
"2")
do something else
;;
"3")
submenu ()
{
clear
echo "-------------------------------"
echo "SUB -MENU"
echo "a) option"
echo "b) option"
echo "-------------------------------"
while :
do
read subaction
case $subaction in
"a")
do something ;;
"b")
do something else ;;
esac
done
}
submenu;
;;
"4")
echo "Bye!"
exit 0
;;
*)
echo "Error: Invalid option..."
read -p "Press [Enter] key to continue..." readEnterKey
;;
esac
done
}
menu;
but bash is complaining that there's a syntax error, can someone tell me how can i create in submenus in bash ?
thanks,
- 12-30-2012 #2Just Joined!
- Join Date
- Dec 2012
- Posts
- 6
Solved it
Hadnt added a ;; what i wrote is actually correct. Can see why its called bash...
solution:
3)
submenu ()
{
clear
echo "-------------------------------"
echo "SUB -MENU"
echo "a) option"
echo "b) option"
echo "-------------------------------"
while :
do
read subaction
case $subaction in
"a")
do something ;;
"b")
do something else ;;
esac
done
}
submenu;
;;
4)
- 12-30-2012 #3Linux Newbie
- Join Date
- Nov 2012
- Posts
- 134
hi,
«there's a tree in a forrest.» let me guess, it's made of wood! XDbash is complaining that there's a syntax error
what's the error message? exactly.
functions don't have to be nested because they are called inside another.
don't you have something to test in the first `while'?



