getopt Parses Option as Argument

Trouble_at_Mill
Date: 11/13/03


Date: Wed, 12 Nov 2003 20:21:13 -0800

Hi,

I'm trying to use getopt to parse the command line arguments.
However, I can't seem to get it to work 'as designed'.

My *optstring is set to "d:s:C:h". If I call the program with the
following arguments:

-d 0 -s -C01

Note, the missing argument for -s. Then, the -C01 is taken as the
argument for -s, whereas the documentation implies that I should get
notification of the missing item.

If I try:

-d 0 -C01 -s

Then I get, correctly, the message "option requires an argument".

How can I get the former example to 'behave'.

Cheers,
Eddie



Relevant Pages

  • Re: getopt and Optional Arguments in C
    ... >> missing, getopt only recognizes that it is missing if it is the last ... >> second option, that option is returned in optarg, as the argument. ... It was my interpretation of "argv-element" that caused the confusion. ...
    (comp.os.linux.development.apps)
  • getopt and Optional Arguments in C
    ... I seem to have a problem getting 'getopt' to properly parse command ... missing, getopt only recognizes that it is missing if it is the last ... getopt still does NOT set optarg and it then ...
    (comp.os.linux.development.apps)
  • Re: getopt and Optional Arguments in C
    ... > I seem to have a problem getting 'getopt' to properly parse command ... > missing, getopt only recognizes that it is missing if it is the last ... > second option, that option is returned in optarg, as the argument. ... getopt still does NOT set optarg and it then ...
    (comp.os.linux.development.apps)
  • Re: Where/what is getopt.h?
    ... > about missing getopt.h. ... to use getopt(). ... /usr/include/unistd.h under Solaris includes the declaration ... Dr. Andreas F. Borchert, SAI, Universitaet Ulm | One should make everything ...
    (comp.unix.solaris)
  • ld.so.1: fatal ImportError: ld.so.1 No such file or directory
    ... you've GOT to finnd the missing file! ... This command above should go in your rc file, eg, ~/.tcshrc, ~/.cshrc, ... If you are still having trouble, ... try section-3 below, but then you're on your own. ...
    (comp.lang.python)