Re: Shouldn't getopt_long() return ':' for options requiring an argument?

From: Eric Lilja (mindcooler_thisshouldberemoved_at_gmail.com)
Date: 04/24/05


Date: Sun, 24 Apr 2005 22:06:06 +0200


"Måns Rullgård" <mru@inprovide.com> wrote:
> "Eric Lilja" <mindcooler_thisshouldberemoved@gmail.com> writes:
>
>> Hello, consider this C program and its accompanying test script:
>
> [...]
>
>> As you can see, getopt_long() returns '?' for the case where the option
>> requires arguments and none was supplied, I was under the impression that
>> it
>> should return ':' for that case and '?' for unknown options (it prints
>> the
>> correct diagnostic, though). Is this a bug in the implementation of
>> getopt_long() on my system or are there simply different valid variants
>> of
>> the implementation?
>
> man 3 getopt:
>
> If the first character (following any optional '+'or '-'
> described
> above) of optstring is a colon (':'), then getopt() returns ':'
> instead
> of '?' to indicate a missing option argument.
>

Hmm, I must be daft or something, but does that mean that getopt_long() only
returns ':' if the user had supplied --:option_with_argument on the command
line?

> --
> Måns Rullgård
> mru@inprovide.com

/ E



Relevant Pages

  • Re: Shouldnt getopt_long() return : for options requiring an argument?
    ... > requires arguments and none was supplied, I was under the impression that it ... Is this a bug in the implementation of ... man 3 getopt: ... Måns Rullgård ...
    (comp.unix.programmer)
  • Re: Vladimir Bondarenko and Maplesoft
    ... You given the wrong impression. ... Do you think if you found the name of someone in IBM, Intel, Texas Instruments etc etc. and sent them in the post your latest bug several times per day, that they might just get a bit fed up with it? ... I'm not sure it is a particularly fundamental question. ... Dave K MCSE. ...
    (sci.math.symbolic)
  • Re: The slow and the curious
    ... >>>I was under the impression they weren't brought into Canada. ... I had sat in 3 different seats in his car under duress. ... Maybe the market is ready for another Volkswagen bug. ... >> Jane, ugly, no frills but practical transportation. ...
    (rec.motorcycles)
  • Test-driven development and code size (was: What is a good way of having several versions of a p
    ... My impression is that failing to have reliable code adds a lot of time ... Instead, in code that has unit tests, a bug found means another unit ... With test-driven development I get much closer to the "sooner" end of ...
    (comp.lang.python)
  • Re: strange effect with [:lower:] in perl
    ... On Tue, 28 Oct 2003, Ben Morrow wrote: ... >> That would surely have to be categorised as a bug? ... for quite some months now you'll maybe get the impression that I was ... POSIX regex constructs in versions of Perl before 5.6, ...
    (comp.lang.perl.misc)