Re: pg_dump, pg_basebackup don't error out with wrong option for "--format" - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: pg_dump, pg_basebackup don't error out with wrong option for "--format"
Date
Msg-id YaCEz0+caqFtMeVM@paquier.xyz
Whole thread Raw
In response to Re: pg_dump, pg_basebackup don't error out with wrong option for "--format"  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
List pgsql-hackers
On Thu, Nov 25, 2021 at 11:22:11AM +0530, Bharath Rupireddy wrote:
> On Thu, Nov 25, 2021 at 11:02 AM Dilip Kumar <dilipbalaut@gmail.com> wrote:
>> I think for parsing we use getopt_long(), as per that if you use the
>> prefix of the string and that is not conflicting with any other option
>> then that is allowed.  So --fo, --for all are accepted, --f will not
>> be accepted because --file and --format will conflict, --foo is also
>> not allowed because it is not a valid prefix string of any valid
>> option string.
>
> Yeah, that makes sense. Thanks.

It is worth noting that getopt_long() is a GNU extension and not
directly something defined in POSIX, but it is so popular that it
expanded everywhere.  This option anme handling is quite common across
everything that uses getopt_long(), actually, and erroring on
non-exact option names would break a bunch of existing use cases as it
is possible to save some characters if getopt_long() is sure of the
uniqueness of the option found.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Deduplicate code updating ControleFile's DBState.
Next
From: Ken Kato
Date:
Subject: Re: [PATCH] ALTER tab completion