[Bug argparse/23157] getopt fails when setting optind=1 under some circumstances
adhemerval.zanella at linaro dot org
sourceware-bugzilla@sourceware.org
Tue May 15 11:58:00 GMT 2018
https://sourceware.org/bugzilla/show_bug.cgi?id=23157
--- Comment #3 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
(In reply to Martin Sandiford from comment #2)
> (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.
Man-pages is the not the canonical glibc documentation, that's why I said
unfortunately this is not documented on the manual and I think we should make
it clear.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list