Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFJUc-009J7P-0E for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Dec 2023 19:41:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rFJUa-00CHr2-Er for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Dec 2023 19:41:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFJUa-00CHqu-5B for pgsql-hackers@lists.postgresql.org; Mon, 18 Dec 2023 19:41:32 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFJUU-00B39I-Er for pgsql-hackers@postgresql.org; Mon, 18 Dec 2023 19:41:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3BIJfM0U4007896; Mon, 18 Dec 2023 14:41:22 -0500 From: Tom Lane To: Michael Paquier cc: Nathan Bossart , Kyotaro Horiguchi , noah@leadboat.com, pgsql-hackers@postgresql.org Subject: Re: add non-option reordering to in-tree getopt_long In-reply-to: References: <20230710.165711.1906730109995973216.horikyota.ntt@gmail.com> <20230710181237.GD257945@nathanxps13> <20230710200658.GA362078@nathanxps13> <20230711.161609.1881651378858129172.horikyota.ntt@gmail.com> <20230711163232.GA616878@nathanxps13> <20230713034903.GA991765@nathanxps13> <20230713145712.GA1049722@nathanxps13> <20230714043842.GB327716@nathanxps13> Comments: In-reply-to Michael Paquier message dated "Fri, 14 Jul 2023 14:02:28 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4007894.1702928482.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 18 Dec 2023 14:41:22 -0500 Message-ID: <4007895.1702928482@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Thu, Jul 13, 2023 at 09:38:42PM -0700, Nathan Bossart wrote: >> Take the following examples of client programs that accept one non-opti= on: >> = >> ~$ pg_resetwal a b c >> pg_resetwal: error: too many command-line arguments (first is "b") >> pg_resetwal: hint: Try "pg_resetwal --help" for more information. >> = >> Yet pg_ctl gives: >> = >> ~$ pg_ctl start a b c >> pg_ctl: too many command-line arguments (first is "start") >> Try "pg_ctl --help" for more information. >> = >> In this example, isn't "a" the first extra non-option that should be >> reported? > Good point. This is interpreting "first" as being the first option > that's invalid. Here my first impression was that pg_ctl got that > right, where "first" refers to the first subcommand that would be > valid. Objection withdrawn. We just had a user complaint that seems to trace to exactly this bogus reporting in pg_ctl [1]. Although I was originally not very pleased with changing our getopt_long to do switch reordering, I'm now wondering if we should back-patch these changes as bug fixes. It's probably not worth the risk, but ... regards, tom lane [1] https://www.postgresql.org/message-id/flat/CANzqJaDCagH5wNkPQ42%3DFx3m= JPR-YnB3PWFdCAYAVdb9%3DQ%2Bt-A%40mail.gmail.com