This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] manual: Document optind zero set behaviour (BZ#23157)
On 05/29/2018 02:44 PM, Adhemerval Zanella wrote:
> Now I am not sure if program is abusing of getopt semantic, or glibc is tying
> with information it should (the input argument), or if it just undefined
> behaviour.
We have no test cases that use optind setting to zero. That isn't proof conclusive
that the feature is not supported.
We have only a manual page with a note about resetting optind to 0 to allow the
reset to happen. That's not canonical.
We have a BSD implementation that does something similar but with a distinct
variable.
My suggestion:
* Review other implementations of GNU getopt and see what they support for
optind setting to 0, e.g. https://github.com/agriffis/pure-getopt
If they don't support setting optind to 0, then that's better proof that
we should not support this.
* Consider copying BSD's non-standard optreset. I like the idea of a distinct
variable for use in the reset.
* Consider sending a patch to the linux man pages project to remove the
note regarding glibc's undocumented method for rescanning.
Cheers,
Carlos.