Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: Using getopt to parse multi-argument options
Message-ID: <1989Jan16.023712.29002@utzoo.uucp>
Organization: U of Toronto Zoology
References: <3652@phri.UUCP>
Date: Mon, 16 Jan 89 02:37:12 GMT

In article <3652@phri.UUCP> roy@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).

Nobody has ever pretended that getopt or the syntax standard could handle
all the old weird programs that hack their arguments in their own strange
ways.  From personal experience, I can testify that life is a lot better
when everything uses getopt, even if this means some aggravation over
backward compatibility.  Just having things consistent is a huge win.
-- 
"God willing, we will return." |     Henry Spencer at U of Toronto Zoology
-Eugene Cernan, the Moon, 1972 | uunet!attcan!utzoo!henry henry@zoo.toronto.edu
