You have the following shell that has a while (while) loop inside a while (while) loop. I am trying to break the inner loop using "break", but it is not. I want to break the inner loop and display the parameters of the 1st loop to the user; offers pls.
#!/bin/ksh
sub_menu() {
echo "~~~~~~~~~~~~~~~~~~~~~~~~~"
echo " S U B - M E N U "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "1. Display properties"
echo "2. Back"
}
read_sub_options(){
echo "Please select option"
read option
case $option in
1) sub_menu ;;
***2) break ;;***
*) echo "Please insert options 1 ~ 2";;
esac
}
showSubMenu(){
while true
do
sub_menu
read_sub_options
done
}
read_options(){
echo "Please select option "
read option
case $option in
1) showSubMenu ;;
2) exit 0;;
*) echo "Please insert options ";;
esac
}
show_menus() {
echo "~~~~~~~~~~~~~~~~~~~~~"
echo " M A I N - M E N U "
echo "~~~~~~~~~~~~~~~~~~~~~"
echo "1. Sub Menu"
echo "2. Exit"
}
while true
do
show_menus
read_options
done
Here is the result:
~~~~~~~~~~~~~~~~~~~~~
M A I N - M E N U
~~~~~~~~~~~~~~~~~~~~~
1. Sub Menu
2. Exit
Please select option
1
~~~~~~~~~~~~~~~~~~~~~~~~~
S U B - M E N U
~~~~~~~~~~~~~~~~~~~~~~~~~
1. Display properties
2. Back
Please select option
2
~~~~~~~~~~~~~~~~~~~~~~~~~
S U B - M E N U
~~~~~~~~~~~~~~~~~~~~~~~~~
1. Display properties
2. Back
Please select option
2
source
share