18.9. Menus
When creating menus, the null command comes in very handy with the while loop. A while and null combined mean loop forever, which is what we want for a menu, unless of course the user selects exit or a valid option.
To create a menu you need only a while loop and a case statement to catch all the patterns the user inputs. If an invalid input is given then sound the bell, echo a error message and then carry on with the loop until the user has finished his processing and selected the exit option.
A menu should also be friendly; the user should not have to guess what to do. The main screen would also look good with the hostname and date on it, coupled with the name of the user who is running the menu. For our test purposes, all the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access