getopt_long
Andreas Schwab
schwab@suse.de
Mon Dec 6 10:10:00 GMT 1999
Scott Bambrough <scottb@netwinder.org> writes:
|> The attached program experiments with getopt_long. It prints optarg for
|> each option, or (null) if optarg is NULL. If I attempt to use the -o
|> option I get the following results.
|>
|> $ ./getopt_test -o
|> optional argument: (null)
|>
|> $ ./getopt_test -o arg
|> optional argument: (null)
|> Non - option ARGV elements: arg
|>
|> This happens for me with glibc 2.1.2 on x86 and ARM.
|>
|> The -o option is supposed to take an optional argument. The
|> documentation leads me to believe that optarg will be set if an argument
|> for the option exists. Have I missed something or is this a bug?
It's not a but, it's a feature: you should write `./getop_test -oarg'.
Otherwise it would be ambiguous.
Andreas.
--
Andreas Schwab "And now for something
SuSE Labs completely different."
schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
More information about the Libc-hacker
mailing list