[net.unix] standards, tools, history: options=?

guy@rlgvax.UUCP (Guy Harris) (03/25/84)

> Getopt, the parser referred to by several people was a first attempt at
> this, but it was never released.

Gee, our System III and System V manuals have pages GETOPT(3C) which
describes that resembles the proposed AT&T standard an *awful* lot, and
they also have a manual page GETOPT(1) for a command which lets shell
files use this - hey, we even got the *source* to them on our S3 and S5
distributions!

In other words, a parser that implements 90% of the standard is available
to anyone with a license for S3 or any later release - it's on your tape.
It implements the following rules of the standard:

- rule 3 (one-letter option names, which is a historical crock - note "f77"'s
	"onetrip" option (which is in itself a historical crock forced on us
	by implementors of pre-F77 Fortran compilers, but we won't get into
	that))

- rule 4 (options must be delimited by "-")

- rule 5 (options with no arguments may be grouped behind one delimiter - this
	is the history that forces rule 3)

- rule 7 (option arguments cannot be optional)

- rule 8, partially (groups of option-arguments following an option must
	be separated by commas or separated by white space and quoted)

- rule 9 (all options precede operands on the command line)

- rule 10 ("--" may be used to delimit the end of the options)

Rule 6 (the first option-argument following an option must be preceded by
white space) is not supported by "getopt"; it permits "foo -ofrobozz" or
"foo -o frobozz".  It supports Rule 8 to the extent that the option-argument
must be recognized by the shell's lexical analyzer as one token.  All other
rules are supported by the code that uses "getopt".

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

henry@utzoo.UUCP (Henry Spencer) (03/27/84)

> Getopt, the parser referred to by several people was a first attempt at
> this, but it was never released.

Not only was getopt released with System N, as Guy Harris says, but there
is a public-domain re-implementation of it that was published in net.sources
quite some while ago.  If you want it and don't have it, either talk to
somebody who has news archives or send me mail.  (I wrote it.)  So stop
complaining that you can't get it; you can, you should, and you should
have done so quite some time ago!

(If I get enough "I'm interested" mail, I will re-post the thing.  It's
not large.)

Incidentally, another thing to scream at Berkeley about:  the public-domain
getopt was around in plenty of time to get onto 4.2BSD, but for some
reason the twits didn't include it.  I know it got to Berkeley.

So, there is *no* *excuse* for not using getopt, if your argument syntax
is anything like the normal Unix pattern.  Hereabouts, any time we work
on any existing program we fix it to use getopt.  And of course all our
new stuff uses it.  It's a huge relief to have everything accept the
same consistent syntax.  Just the uniformity is a large win.

This, incidentally, sums up my views on the proposed syntax standard.
Just the uniformity alone is a large win, well worth the trouble.  One
may argue that it is an inferior syntax, but it is *still* highly worth-
while to clean it up and make it uniform.  If for no other reason than
because a conversion to a new syntax will be a much lengthier process.

(The paper that gives details of the reasoning behind the standard is
quite interesting, by the way.  One of the things it says is that the
idea of a new and radically different, but perhaps superior, syntax was
explicitly rejected.  Why?  Because it was tried before, and nobody
paid any attention to it.  A standard that nobody follows is useless.)

I have promised, in front of a lot of witnesses, to keep the public-
domain implementation of getopt in step with whatever AT+T does in the
way of parsing software for the new standard.  The folks who did the
standard promised to keep me informed about this; nothing yet.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry

henry@utzoo.UUCP (Henry Spencer) (04/01/84)

Since my posting a few days ago, there has been a deluge of letters
asking for my public-domain implementation of the getopt(3) argument
parser.  I will re-post it to net.sources shortly, and will mail copies
to those persons who've indicated they don't get net.sources.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry