This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: getopt_long


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]