I am looking for the correct syntax of the switch statement with fallthrough cases in Bash (ideally case-insensitive). In PHP I would program it like:
switch
Recent bash versions allow fall-through by using ;& in stead of ;;:
they also allow resuming the case checks by using ;;& there.
for n in 4 14 24 34
do
echo -n "$n = "
case "$n" in
3? )
echo -n thirty-
;;& #resume (to find ?4 later )
"24" )
echo -n twenty-
;& #fallthru
"4" | [13]4)
echo -n four
;;& # resume ( to find teen where needed )
"14" )
echo -n teen
esac
echo
done
sample output
4 = four
14 = fourteen
24 = twenty-four
34 = thirty-four