Using getopt to parse multi-argument options
Alan Fargusson @ peace with the world
alanf%smile at Sun.COM
Wed Jan 18 07:57:44 AEST 1989
In article <1989Jan16.023712.29002 at utzoo.uucp>, henry at utzoo.uucp (Henry Spencer) writes:
> In article <3652 at phri.UUCP> roy at phri.UUCP (Roy Smith) writes:
> > I'm writing a program which will take an optional range, in the
> >style of graph(1)'s "-x xmin xmax". How do I tell getopt to parse
> >something like that? ...
>
> You can't. The only getopt-compatible way is to require the user to
> say "-x 'xmin xmax'" instead, and have your code pull the single argument
> apart. This is what the AT&T syntax standard mandates (with the further
> flourish that tabs and commas must work as separators, not just spaces,
> as I recall).
>
I think the best way to do this would be to have the user type "-x xmin,xmax",
and parse the 'xmin,xmax' yourself. This is what some AT&T software does.
- - - - - - - - - - - - - - - - - - - - -
Alan Fargusson Sun Microsystems
alanf at sun.com ..!sun!alanf
More information about the Comp.lang.c
mailing list