This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug argparse/23157] getopt fails when setting optind=1 under some circumstances


https://sourceware.org/bugzilla/show_bug.cgi?id=23157

--- Comment #2 from Martin Sandiford <ms at mcdev dot com.au> ---
(In reply to Adhemerval Zanella from comment #1)
> So if you set 'optint' to 0 in the example provided it will pass on GLIBC. 
> Unfortunately this is not documented on the manual, only on man-pages [3]
> (on NOTES).

Sure, that's understood.

However, the NOTES section from the referenced Linux man page states:

> NOTES
>   A program that scans multiple argument vectors, or rescans the same
>   vector more than once, and wants to make use of GNU extensions such
>   as '+' and '-' at the start of optstring, or changes the value of
>   POSIXLY_CORRECT between scans, must reinitialize getopt() by
>   resetting optind to 0, rather than the traditional value of 1.
>   (Resetting to 0 forces the invocation of an internal initialization
>   routine that rechecks POSIXLY_CORRECT and checks for GNU extensions
>   in optstring.)

Which suggests that setting optind to 1 should operate "correctly" when a
program neither uses GNU extensions nor changes POSIXLY_CORRECT.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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