Re: add non-option reordering to in-tree getopt_long

Поиск
Список
Период
Сортировка
От Nathan Bossart
Тема Re: add non-option reordering to in-tree getopt_long
Дата
Msg-id 20230714043842.GB327716@nathanxps13
обсуждение исходный текст
Ответ на Re: add non-option reordering to in-tree getopt_long  (Michael Paquier <michael@paquier.xyz>)
Ответы Re: add non-option reordering to in-tree getopt_long
Список pgsql-hackers
On Fri, Jul 14, 2023 at 01:27:26PM +0900, Michael Paquier wrote:
> Indeed, it looks like I've fat-fingered a rebase here.  I am able to
> get a clean CI run when running this patch, sorry for the noise.
> 
> Anyway, this introduces a surprising behavior when specifying too many
> subcommands.  On HEAD:
> $ pg_ctl stop -D $PGDATA kill -t 20 start
> pg_ctl: too many command-line arguments (first is "stop")
> Try "pg_ctl --help" for more information.
> $ pg_ctl stop -D $PGDATA -t 20 start
> pg_ctl: too many command-line arguments (first is "stop")
> Try "pg_ctl --help" for more information.
> 
> With the patch:
> $ pg_ctl stop -D $PGDATA -t 20 start
> pg_ctl: too many command-line arguments (first is "start")
> Try "pg_ctl --help" for more information.
> $ pg_ctl stop -D $PGDATA kill -t 20 start
> pg_ctl: too many command-line arguments (first is "kill")
> Try "pg_ctl --help" for more information.
> 
> So the error message reported is incorrect now, referring to an
> incorrect first subcommand.

I did notice this, but I had the opposite reaction.  Take the following
examples of client programs that accept one non-option:

    ~$ 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.

    ~$ createuser a b c
    createuser: error: too many command-line arguments (first is "b")
    createuser: hint: Try "createuser --help" for more information.

    ~$ pgbench a b c
    pgbench: error: too many command-line arguments (first is "b")
    pgbench: hint: Try "pgbench --help" for more information.

    ~$ pg_restore a b c
    pg_restore: error: too many command-line arguments (first is "b")
    pg_restore: hint: Try "pg_restore --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?

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: add non-option reordering to in-tree getopt_long
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Autogenerate some wait events code and documentation