ugh.book

(singke) #1
The Shell Game 149

Hardware stores contain screwdrivers or saws made by three or four differ-
ent companies that all operate similarly. A typical Unix /bin or /usr/bin
directory contains a hundred different kinds of programs, written by dozens
of egotistical programmers, each with its own syntax, operating paradigm,
rules of use (this one works as a filter, this one works on temporary files,
etc.), different strategies for specifying options, and different sets of con-
straints. Consider the program grep, with its cousins fgrep and egrep.
Which one is fastest?^1 Why do these three programs take different options
and implement slightly different semantics for the phrase “regular expres-
sions”? Why isn’t there just one program that combines the functionality of
all three? Who is in charge here?


After mastering the dissimilarities between the different commands, and
committing the arcane to long-term memory, you’ll still frequently find
yourself startled and surprised.


A few examples might be in order.


Shell crash


The following message was posted to an electronic bulletin board of a
compiler class at Columbia University.^2


Subject: Relevant Unix bug
October 11, 1991

Fellow W4115x students—
While we’re on the subject of activation records, argu-
ment passing, and calling conventions, did you know that typing:

!xxx%s%s%s%s%s%s%s%s

tcsh Csh with emacs-style editing.
ksh KornShell, another command and programming lan-
guage.
zsh The Z Shell.
bash The GNU Bourne-Again SHell.

(^1) Ironically, egrep can be up to 50% faster than fgrep, even though fgrep only uses
fixed-length strings that allegedly make the search “fast and compact.” Go figure.
(^2) Forwarded to Gumby by John Hinsdale, who sent it onward to UNIX-HATERS.

Free download pdf