On Tue, Mar 29, 2022 at 2:17 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
> > On Tue, Mar 29, 2022 at 1:53 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> That test script is expecting glibc-like laxness of switch
> >> parsing. Put the switches before the non-switch arguments.
>
> > I just did that. :-)
>
> Yup, you pushed while I was typing.
>
> FWIW, I don't think it's "Windows" enforcing this, it's our own
> src/port/getopt[_long].c. If there were a well-defined spec
> for what glibc does with such cases, it might be interesting to
> try to make our version bug-compatible with theirs. But AFAIK
> it's some random algorithm that they probably feel at liberty
> to change.
I guess that characterization surprises me. The man page for
getopt_long() says this, and has for a long time at least on systems
I've used:
ENVIRONMENT
POSIXLY_CORRECT If set, option processing stops when the first non-
option is found and a leading `-' or `+' in the
optstring is ignored.
And also this:
BUGS
The argv argument is not really const as its elements may be permuted
(unless POSIXLY_CORRECT is set).
Doesn't that make it pretty clear what the GNU version is doing?
--
Robert Haas
EDB: http://www.enterprisedb.com