From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Teach in-tree getopt_long() to move non-options to the end of ar
Date: Thu, 13 Jul 2023 03:35:28 +0000
Message-ID: <E1qJn72-00073v-1N@gemulon.postgresql.org> (raw)
Teach in-tree getopt_long() to move non-options to the end of argv.
Unlike the other implementations of getopt_long() I could find, the
in-tree implementation does not reorder non-options to the end of
argv. Instead, it returns -1 as soon as the first non-option is
found, even if there are other options listed afterwards. By
moving non-options to the end of argv, getopt_long() can parse all
specified options and return -1 when only non-options remain.
This quirk is periodically missed by hackers (e.g., 869aa40a27,
ffd398021c, and d9ddc50baf). This commit introduces the
aforementioned non-option reordering behavior to the in-tree
getopt_long() implementation.
Special thanks to Noah Misch for his help verifying behavior on
AIX.
Reviewed-by: Kyotaro Horiguchi, Michael Paquier
Discussion: https://postgr.es/m/20230609232257.GA121461%40nathanxps13
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/411b720343005597d042fc1736ce9a3a3ee8a1fe
Modified Files
--------------
src/bin/scripts/t/040_createuser.pl | 10 ++++---
src/port/getopt_long.c | 53 ++++++++++++++++++++++++++-----------
2 files changed, 44 insertions(+), 19 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Teach in-tree getopt_long() to move non-options to the end of ar
In-Reply-To: <E1qJn72-00073v-1N@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox