Learning the Bash Shell, 2nd Ed.
Authors: Cameron Newham and Bill Rosenblatt
Publisher: O'Reilly & Associates, Inc.
Price: US $29.95 (Softbound)
Reviewer: Bob van der Poel
The user shell is the most seen and used program on any UNIX system. Though the shell the user can type commands for file maintenance, launch various application programs, and automate tedious day-to-day system administration. Of course, we should mention that some computer systems (like Windows 95) don't even come with a shell; but, you being a Linux user are blessed with a multitude of various shells. Most systems come with csh, sh, tcsh, ksh and bash pre-installed. Of these, it appears that bash has become the standard shell for Linux.
Bash, an acronym for the "Bourne again shell", is a large, complicated, and powerful program. It has been developed over a period of many years and is intended as the standard shell for GNU systems. The GNU distributions of bash come with a manual page and info-style documentation—and if you are familiar with UNIX shell programming then that is probably all you'll need to get bash doing what you want. On the other hand, if you've read the man pages a few times and are still scratching your head, you may need more help.
"Learning the Bash Shell", as the authors summerize in their preface, "is designed to address casual UNIX and Linux users who are just above the 'raw beginner' level. You should be familiar with the process of logging in, entering commands, and doing some simple things with files". After reading the book a few times I agree. But the utility of this book extends beyond a "beginner's tutorial". If you haven't quite earned all the stars on your UNIX-wizard cap you will find it a often used reference.
"Learning the Bash Shell" is a 320 page book divided into eleven chapters, five appendices and an index. It is written in an easy-to-follow style which avoids, as much as possible, the terse style of man pages and jargon. The layout and typesetting make it easy to navigate though the various explanations and examples.
The first three chapters give the reader an overview of the functions of a shell, how to use the extensive command-line editing capabilities of bash, and the setting up a customized environment. The section on command-line editing is one I'm going to read a few more times—the more I understand and begin to use more of bash's power the less typing I do (and considering the state of my typing ability, this is a Good Thing).
The next five chapters are certainly the most valuable—they deal with actually programming bash. All the command words, variables and builtin functions are covered. For a large part this is a repetition of the material in the man/info documentation, but the authors have added in comments on when you might want to use a particular command, the history of others, and even the suggestion that you will never have an opportunity to use yet others. Further, most of the explanations are accompanied by examples showing exactly how and when to use the commands and variables. In good pedagogical style, the authors present a simple example. Then, as the reader learns more features, the examples are revisited and expanded until one has a useful and solid solid shell program. There are also suggested exercises for the reader to work on to expand her programming skills.
If you've ever done any programming you know all about the tedious chore of tracking down bugs in your programs. Writing scripts in bash is no different—you will have bugs and they will be hard to find. Actually, with the sometimes arcane syntax of shell scripts, they may be very hard to find. So, chapter nine will be help. Not only are the standard debugging methods (lots and lots of print statements) covered, the authors also present a extensive debugger. The most interesting part of the debugger is that it is actually a bash script. Neat.
The final two chapters deal with the rather mundane topics of installing bash as your user shell, some security issues, and obtaining and installing bash on your own system. Fortunately, since bash comes preinstalled as the standard shell on most Linux systems we can mostly skim-read this section.
The five appendices contain the expected reference lists, BNF syntax, etc. Good, useful information. Finally the 14 page index makes using this book as a standard desktop reference an easy task.
"Learning the Bash Shell" has been written for the 2.x version of bash; however, any features which are were not supported by earlier versions of bash are so noted.
Programming in a shell language like bash is quite different than using a high-level language like C. To me, it seems that that language has been kludged together by a large number of individuals who added features as they were needed and merged the syntax of whatever they were used to into the shell language. The result is that the bash language can get rather convoluted if not downright arcane. It's easy for a beginner to get bogged down in details. For this reason alone, "Learning the Bash Shell" is an important tool. Beware that fooling around with shell scripts, especially if you have root permissions, can be dangerous to the health of your system. Fortunately, the authors warn you when their examples can compromise your system's integrity or security.
The examples in the book are short enough for the user to type in, but they are also available from O'Reilly's ftp site. Well, so the book states. I followed the instructions in the book and downloaded the source file. Unfortunately the file is for the first edition of the book and misses the entire debug script. I contacted O'Reilly by email and received a courteous and timely reply advising me that they would contact the book editor to track down the source. Hopefully, by the time this review is in print the correct source will be available.
We have learned to expect professional, well-written, technically-correct books from O'Reilly, and "Learning The Bash Shell" is no exception. Writing technical reference books is always a difficult task. It is even more trying when the knowledge base of the intended audience is as varied as the readers of this book are. I think the the authors have succeeded in making their book both a introductory primer for new users and a valuable reference for the more experienced. I highly recommend this book to anyone who wants to become more productive using bash, as well as those who wish to learn to write moderately complex shell scripts.
NOTE: This review originally appeared in "The Linux Journal", December 1998.
All rights are retained and reserved by the author, Bob van der Poel
|This page "bash-review.html" was last modified on Tue Apr 10 09:55:10 2018|