Chapter 29. Flow Control: Looping with while and until
In the previous chapter, we developed a menu-driven program to produce various kinds of system information. The program works, but it still has a significant usability problem. It executes only a single choice and then terminates. Even worse, if an invalid selection is made, the program terminates with an error, without giving the user an opportunity to try again. It would be better if we could somehow construct the program so that it could repeat the menu display and selection over and over, until the user chooses to exit the program.
In this chapter, we will look at a programming concept called looping, which can be used to make portions of programs repeat. The shell provides three compound ...