command line options

Michael Gold gold at trane.UUCP
Fri Apr 1 11:20:04 AEST 1988


>From article <2517 at geac.UUCP>, by daveb at geac.UUCP (David Collier-Brown):
>   I did a parser with static control tables, and admit I like the
> scanf-style ones better.  Feel free to post...

I agree that the 'scanf' paradigm is neater, assuming a fairly small
set of options.  For programs with more complex command lines, where the
format string would overflow a line of source code and be otherwise
unwieldy, I prefer the static data structure.  The ideal solution would
be a package that accepts either interface at the user's preference.
I cite the various flavors of 'exec*(2)' as precedent.  Or does that
raise red flags on account of unnecessary multiplicity??

Anyway, I'd propose three more requirements for this package:

1)	Capability of handling multi-character flags,

2)	Acceptance of arguments to flags that may or may not be
	appended to the flag, as in the -I and -o flags of most 'cc's
	respectively, and

3)	Positional independence of the tokens, except for arguments bound
	to particular flags.

I sense from the volume and quality of this discussion that improving
getopt() is both desirable and non-trivial.  Let's keep at it.

--------
Michael Gold / (415) 780-4903 / {ihnp4,ames,sun,pyramid,...}!pacbell!trane!gold



More information about the Comp.lang.c mailing list