command line options

Doug Gwyn gwyn at brl-smoke.ARPA
Mon Apr 25 04:03:37 AEST 1988


In article <283 at fxgrp.UUCP> ljz at fx.com (Lloyd Zusman) writes:
>Why is it that some of you are so fervently defending how '-?' is
>currently handled in getopt()?  Are you trying to imply that getopt()
>is perfect and nothing better can ever be invented, and that those who
>try to suggest that something better might be possible are worthy of
>nothing more than derision and scorn?  It sure seems that some of you
>feel this way.

Here's the situation as I see it.  Sure, any of a number of spiffy
argument parsing schemes can be designed.  I've seen several such
attempts, including one fairly good one contributed to a USENIX
tape several years ago by the company for which I worked at the time.
I don't think anybody has been arguing that getopt() could not be
improved upon.

When an effort was made in Bell Labs to consolidate the various
argument handling schemes, a study was made and the various
alternatives carefully considered.  It was decided at that time
that standardizing a la getopt() would be more widely useful than
any other alternative.  The command/option/argument syntax rules
were written, reviewed, and eventually adopted as an AT&T standard
(which several pre-existing UNIX utilities violated, of course).
The code necessary to implement this scheme was placed into the
public domain (the only instance I know of when this was done for
AT&T code), and the command syntax rules were incorporated into the
SVID.  Gradually, older utilities have been revised to follow the
new standard, which has several advantages over the ad hoc approach
typically seen in non-getopts()-using utilities.

The main advantage of getopt() is that it is HERE already, and it is
widely ACCEPTED.  I've been using it for years even though I could
invent a nominally superior technical solution.  The uniformity of
the option parsing rules has proven its value for me many times.

On the other hand, no "technically superior" design has received
widespread support.  You should feel free to try to change this,
but based on past experience I doubt that you will succeed.

As to "-?", I first raised that issue; it was intended to be an
observation that there is ALREADY a feature in many utilities
(those that use getopt() and have good usage messages) that can
exploited to get help.  I think it was misunderstood as an argument
that that would be the ideal way to get help in a totally different
design, which was never my contention.



More information about the Comp.unix.wizards mailing list