Shell Scripts v. Command Options (was: Re: small bug in who(1) of SVR3)
Dan Bernstein
brnstnd at kramden.acf.nyu.edu
Sun Jan 20 03:58:32 AEST 1991
In article <1991Jan18.162833.11061 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
> In article <1396:Jan1811:54:2091 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
> >> ... a sense of perspective is needed. Hacking
> >> C code to avoid writing a one-line shell script is a gross waste of time
> >> and money unless that program is truly critical to system performance.
> >That depends on your user community. In general, code that will be
> >distributed to thousands of sites should be written efficiently.
> Oh, I quite agree. Please note that I'm co-author of a major piece of
> code -- C News -- that is distributed to, and in use at, thousands of
> sites. It relies quite heavily on shell scripts. The customers are
> generally extremely pleased with its performance.
Well, yes, but that's because you make intelligent decisions about which
code to write in C so that the shell part isn't a bottleneck. Writing
Berkeley's utmp checkers in sh rather than C is pointless.
> People who claim that shell scripts can't be efficient don't know what
> they're talking about.
(Did I say shell scripts couldn't be efficient?)
Efficiency is relative. Now that I have a lot of practice and some good
libraries, I can convert shell code into C code at between 15 and 30
seconds per line, depending how sane the shell code is; I often get a
speedup between 5 and 50 times. This is well worth it for any program
that is often executed and rarely changed. ``who'' and ``users'' are
examples of such programs. I don't get the speedup when the shell script
simply invokes some long-running Cnews programs, but ``who'' is not my
idea of a long-running program.
---Dan
More information about the Comp.bugs.sys5
mailing list