Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!zaphod.mps.ohio-state.edu!usc!snorkelwacker.mit.edu!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: <19259:Jan1916:58:3291@kramden.acf.nyu.edu> Date: 19 Jan 91 16:58:32 GMT References: <1991Jan16.175908.3338@zoo.toronto.edu> <1396:Jan1811:54:2091@kramden.acf.nyu.edu> <1991Jan18.162833.11061@zoo.toronto.edu> Organization: IR Lines: 31 In article <1991Jan18.162833.11061@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes: > In article <1396:Jan1811:54:2091@kramden.acf.nyu.edu> brnstnd@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