[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [LC++]getopt question



Carlo Wood wrote:
Don't call getopt on it.

You can either make it an argument of an option, ie
 --date 2002-11-17
Or you can decide to interpret it as a date because
the first character is not a '-' and then start
treating everything after it as non-options too.

On Mon, Nov 18, 2002 at 12:17:50AM -0500, Paul M Foster wrote:

I'm using getopt(3) to obtain command line parameters for a program I've
written. One of the parameters is in the form of a date, to wit:

2002-11-17

Apparently, getopt() sees those dashes and interprets them as more
options. It stops and waits for me to type in something. If I take out
this option, the program runs fine. I've tried quoting the string,
double-quoting the string, escaping the dashes with backslashes. Nothing
appears to work. Anyone have any experience with a way to get around
this?

Paul

Or put -- before it. ex -- 2002-11-18
The double - tells getopt not to treat the remaining command line parameters. This does mean you will have to add code to treat the remaining parameters yourself.

--
David Filion
Registerd (Slackware) linux user #195143

"Yes, it's manly, but let's face it, so is bungee-jumping with the
cord tied to your testicles." -- Linus Torvalds