getopt_long

Tim Waugh twaugh@redhat.com
Mon Dec 6 10:05:00 GMT 1999


On Mon, 6 Dec 1999, Scott Bambrough wrote:

> 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 

./getopt_test -oarg produces the result you want.  This behaviour is
documented in the man-page.  It boils down to the fact that libc can't
know if 'arg' is supposed to be associated with -o if it's in a separate
word.

Tim.
*/




More information about the Libc-hacker mailing list