🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.sys5
Article #314

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

#314
From: Dan Bernstein
Date: Fri, 18 Jan 1991 11:54
33 lines
2222 bytes
In article <1991Jan16.175908.3338@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:
> In article <18946@rpp386.cactus.org> jfh@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
Technical Details
Message-ID: <1396:Jan1811:54:2091@kramden.acf.nyu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd
References: <1991Jan14.202053.20054@zoo.toronto.edu> <18946@rpp386.cactus.org> <1991Jan16.175908.3338@zoo.toronto.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd
From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein)
Newsgroups: comp.bugs.sys5
Subject: Re: Shell Scripts v. Command Options (was: Re: small bug in who(1) of SVR3)
Message-ID: <1396:Jan1811:54:2091@kramden.acf.nyu.edu>
Date: 18 Jan 91 11:54:20 GMT
References: <1991Jan14.202053.20054@zoo.toronto.edu> <18946@rpp386.cactus.org> <1991Jan16.175908.3338@zoo.toronto.edu>
Organization: IR
Lines: 33