8 csh, pipes, and find Power Tools for Power Fools I have a natural revulsion to any operating system that shows so little planning as to have to named all of its commands after digestive noises (awk, grep, fsck, nroff). —Unknown The Unix “power tool” metaphor is a canard. It’s nothing more than a slo- gan behind which Unix hides its arcane patchwork of commands and ad hoc utilities. A real power tool amplifies the power of its user with little additional effort or instruction. Anyone capable of using screwdriver or drill can use a power screwdriver or power drill. The user needs no under- standing of electricity, motors, torquing, magnetism, heat dissipation, or maintenance. She just needs to plug it in, wear safety glasses, and pull the trigger. Most people even dispense with the safety glasses. It’s rare to find a power tool that is fatally flawed in the hardware store: most badly designed power tools either don’t make it to market or result in costly law- suits, removing them from the market and punishing their makers. Unix power tools don’t fit this mold. Unlike the modest goals of its designers to have tools that were simple and single-purposed, today’s Unix tools are over-featured, over-designed, and over-engineered. For example, ls, a program that once only listed files, now has more than 18 different
148 csh, pipes, and find options that control everything from sort order to the number of columns in which the printout appears—all functions that are better handled with other tools (and once were). The find command writes cpio-formatted output files in addition to finding files (something easily done by connecting the two commands with an infamous Unix pipe). Today, the Unix equivalent of a power drill would have 20 dials and switches, come with a nonstandard plug, require the user to hand-wind the motor coil, and not accept 3/8" or 7/8" drill bits (though this would be documented in the BUGS section of its instruction manual). Unlike the tools in the hardware store, most Unix power tools are flawed (sometimes fatally for files): for example, there is, tar, with its arbitrary 100-characters-in-a-pathname limit, or Unix debuggers, which overwrite your “core” files with their own “core” files when they crash. Unix’s “power tools” are more like power switchblades that slice off the operator’s fingers quickly and efficiently. The Shell Game The inventors of Unix had a great idea: make the command processor be just another user-level program. If users didn’t like the default command processor, they could write their own. More importantly, shells could evolve, presumably so that they could become more powerful, flexible, and easy to use. It was a great idea, but it backfired. The slow accretion of features caused a jumble. Because they weren’t designed, but evolved, the curse of all pro- gramming languages, an installed base of programs, hit them extra hard. As soon as a feature was added to a shell, someone wrote a shell script that depended on that feature, thereby ensuring its survival. Bad ideas and fea- tures don’t die out. The result is today’s plethora of incomplete, incompatible shells (descrip- tions of each shell are from their respective man pages): sh A command programming language that executes commands read from a terminal or a file. jsh Identical [to sh], but with csh-style job control enabled. csh A shell with C-like syntax.