standards, tools, history: options=? (-foo vs. foo=yes)

Guy Harris guy at rlgvax.UUCP
Sun Mar 25 10:22:38 AEST 1984


> 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



More information about the Comp.unix.wizards mailing list