How can I go out to a "case" boucle, but not finish the program :
echo " your choice :"
read grp1
do
case ${grp1} in
1)grp1="toto1";;
2)grp1="toto2";;
3)grp1="toto3";;
4)grp1="toto4";;
5)grp1=t;;
6)grp1=t;;
7)grp1=t;;
8)grp1=t;;
9)grp1=t;;
10)autreprofil;;
-> C) exit;; ?????????????
*)clear; echo; echo "-- not good --";
sleep 2;;
esac
"break" is an option and in fact intended for exactly this purpose, but I don't think it should be used, because it makes the code somewhat hard to read if using multiple nested loops. After all, "break" could even be used with a number designating the number of loop levels you'd like to jump out.
while [ $x ] ; do
while [ $y ] ; do
while [ $z ] ; do
break 2
done
done
# the "break 2" will bring you here
done
I'd use the following construction:
typeset -i continuation=1
while [ $continuation -gt 0 ] ; do
print "enter a value: " ; read input
case $input in
a)
# do somenthing
;;
b)
# do something else
;;
z)
continuation=0 # exit loop
;;
*)
print "don't enter garbage svp"
;;
esac
done