[TUHS] Systematic approach to command-line interfaces

Clem Cole clemc at ccc.com
Sun Aug 1 02:41:04 AEST 2021

On Sat, Jul 31, 2021 at 8:36 AM Michael Siegel <msi at malbolge.net> wrote:

> Hello,
> I've recently started to implement a set of helper functions and
> procedures for parsing Unix-like command-line interfaces (i.e., POSIX +
> GNU-style long options, in this case)

As an old guy, I am amused to read these words .. because UNIX did not have
a command-line parsing standard., and I remember the wars.  If you came
from a system, where the program was exec's with the command line
parameters pre-parsed (like the DEC world, ITS, and some others); UNIX
seemed foreign and often consider 'bad' by folks.   The biggest argument
(which was reasonable) was Unix command, sometimes used 'keys' (like tp/tar
and the like) and others used switches (cp, ed).   Folks new to UNIX often
b*tched as it being 'inconsistent (read things like the 'UNIX Haters
Book').  I admit I was 'surprised' when I came there in the Fifth Edition
in the mid-70s from the PDP-10 world, but as a programmer, I ended up
really liking the fact that the command-line was not pre-parsed, other than
white space removal and I did not have figure out some strange syntax for
findnext() and other UUO/JSYS from my previous life.

So by the late 70's early 80's, a number of different UNIX parsing schemes
popped up.   Like the stuff from Columbia Richard pointed out.   TCL in
some ways end result, which had a life that was useful, but fell away too
eventually.   The whole getopt(3) thing appeared originally inside of BTL.
 The first version I was was from USB (Summit), but I'm not sure they were
the original authors.   One problem was that it was tied up with later AT&T
licenses [i.e. PWB or later] and was not in Research, the USENIX community
lacked it.  Thus when AT&T brought it to us to consider for POSIX.2, there
was balking.  The ISV's seemed to like it, but there was not a lot of
support elsewhere.  At some point, somebody in the USENIX community wrote a
version and posted it to comp.unix.sources and some people began to use
it.  Of course, GNU had to take it and pee on it, so we got the long file
name stuff.

All in all, it's what's you are used I suspect.

The AT&T whole getopt(3) thing works (I can deal with keys too BTW).  I
guess I just don't get excited about it, these days.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20210731/a3eb5ca1/attachment.htm>

More information about the TUHS mailing list