Shell Scripts v. Command Options (was: Re: small bug in who(1) of SVR3)

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Fri Jan 18 22:54:20 AEST 1991


In article <1991Jan16.175908.3338 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
> In article <18946 at rpp386.cactus.org> jfh at rpp386.cactus.org (John F Haugh II) writes:
> >Studies have shown that the cost of maintaining code is largely independent
> >of the language and depends primarily on the amount of code.  A three line
> >change to a C file should be just as easy to maintain as a three line shell
> >script.
> (a) These are not three-line changes.

You're absolutely right: adding -q to my clone of who takes four lines.
One to declare a flag, one to snarf the option, one to test the flag,
and one to process the output properly. I don't think it's possible to
make the change in only three lines.

(I'm not saying this is the right way to go. There should be a library
routine for sweeping through utmp, and all these programs should take
at most ten lines of real code. Then separate programs for who, users,
who am i, etc. all make sense.)

> (b) Three lines of C *in the context of a much larger program* are a great
> 	deal harder to maintain than a three-line shell script which
> 	interacts with nothing but itself.

We are not talking about a much larger program.

> I don't advocate callous disregard for efficiency -- that way lies GNU
> Emacs and other excesses -- but 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.

---Dan



More information about the Comp.bugs.sys5 mailing list