Skip to Main Content
Learning the Korn Shell, 2nd Edition
book

Learning the Korn Shell, 2nd Edition

by Arnold Robbins, Bill Rosenblatt
April 2002
Beginner content levelBeginner
432 pages
18h 29m
English
O'Reilly Media, Inc.
Content preview from Learning the Korn Shell, 2nd Edition

Chapter 5. Flow Control

If you are a programmer, you may have read the last chapter — with its claim at the outset that the Korn shell has an advanced set of programming capabilities — and wondered where many features from conventional languages are. Perhaps the most glaringly obvious “hole” in our coverage thus far concerns flow control constructs like if, for, while, and so on.

Flow control gives a programmer the power to specify that only certain portions of a program run, or that certain portions run repeatedly, according to conditions such as the values of variables, whether or not commands execute properly, and others. We call this the ability to control the flow of a program’s execution.

Almost every shell script or function shown thus far has had no flow control — they have just been lists of commands to be run! Yet the Korn shell, like the C and Bourne shells, has all the flow control abilities you would expect and more; we examine them in this chapter. We’ll use them to enhance the solutions to some of the programming tasks we saw in the last chapter and to solve tasks that we introduce here.

Although we have attempted to explain flow control so that nonprogrammers can understand it, we also sympathize with programmers who dread having to slog through yet another tabula rasa explanation. For this reason, some of our discussions relate the Korn shell’s flow-control mechanisms to those that programmers should know already. Therefore you will be in a better position ...

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.
Start your free trial

You might also like

Learning the Korn Shell

Learning the Korn Shell

Bill Rosenblatt
Unix Power Tools, 3rd Edition

Unix Power Tools, 3rd Edition

Jerry Peek, Shelley Powers, Tim O'Reilly, Mike Loukides

Publisher Resources

ISBN: 0596001959Supplemental ContentErrata Page