Using getopt to parse long options

From: Vikas Agnihotri (fornewsgroups_at_vikas.mailshell.com)
Date: 10/04/03


Date: Sat, 04 Oct 2003 00:10:12 -0400

Red Hat 9.0, getopt (enhanced) 1.1.2

I am trying to use getopt to validate/parse long command line options and
not getting anywhere.

I am doing something like

getopt -l a-long:,b-long: -- "--a-long a --b-long b"

I get

--
Why do I get -- as the output?
How to use this stuff? I am surprised that are so few examples of this to 
be found.
Thanks


Relevant Pages

  • A plan for handling command line options
    ... Getopt is meant to be used by calling it once for each command ... In each case the first argument is an option string and the ... provide an error handling interface that the user can access. ...
    (comp.programming)
  • Re: Start em early: font rage
    ... introducing a command option is a dash. ... The getopt subroutine returns the next flag letter specified on ... getopt recognizes two hyphens to delimit the end of the ...
    (alt.usage.english)
  • Re: A plan for handling command line options
    ... In the C programming world there is a common utility called getopt that is used for processing command line arguments. ... In each case the first argument is an option string and the second is the address of the place where a value will be placed. ... One approach to error handling is to set errno and abort - this is plausible since the program is still being initialized. ...
    (comp.programming)
  • RE: Solaris telnet vulnberability - how many on your network?
    ... I have now set up a virtual Solaris 8 box to test this with root access, and it appears you are correct. ... When run as root, "login -f root" presents a login prompt, just like login without arguments. ... For instance, it is sometimes convenient to replace another command by a symlink to /bin/true in order to test the effect of the command succeeding, in which case /bin/true might receive arbitrary command line arguments. ... My point is just that it's peculiar that -f should have been implemented so far as adding it to the getopt list and giving it some sort of effect without implementing the "right" semantics or documenting it. ...
    (Bugtraq)
  • Re: Command-line parameter parsing
    ... As it chances I am doing a command line processor so the issue is live ... Posix getopt uses the first; it is suitable for very simple grammars. ...
    (comp.programming)