home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 46.10 A Portable echo Command Chapter 47 Next: 47.2 C Shell Programming Considered Harmful

47. C Shell Programming...NOT

47.1 Why Not?

We use the C shell for many of the interactive examples in this book. History, aliases, and so forth make it far superior to the original Bourne shell for interactive use. (The newer Korn Shell combines features from both. And bash adds even more.) However, csh has some major drawbacks when it comes to shell programming.

Tom Christiansen explains some of the reasons in his famous tract "C Shell Programming Considered Harmful," which we've included as article 47.2 . If you find yourself bristling at the tone of this article, remember that it was originally posted to Usenet ( 1.33 ) . It is an example of that art form known colloquially as a "flame." As flames go, this is actually fairly mild.

We agree with most of Tom's criticisms, and make no attempt to teach C shell programming in this book. We do however include a few quick-reference style articles on constructs that we use in articles about the C shell's setup files ( 2.2 ) , since they are in effect nothing but C shell programs read when the shell starts up. Specifically, we cover the syntax of if ( 47.3 ) and switch ( 47.6 ) statements. We explain how to set and use C shell arrays ( 47.5 ) - a nice C shell feature that, we admit :-) , the Bourne shell is missing. (The foreach ( 9.11 ) loop, covered in another chapter, could be put in this chapter, too.) C shell expressions ( 47.4 ) (like $?prompt ) can be used in if , switch , and foreach .

- TOR , JP

Previous: 46.10 A Portable echo Command UNIX Power Tools Next: 47.2 C Shell Programming Considered Harmful
46.10 A Portable echo Command Book Index 47.2 C Shell Programming Considered Harmful

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System