Re: src/port/getopt_long.c lossy with arguments having no option characters

From: Andres Freund <andres(at)anarazel(dot)de>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: src/port/getopt_long.c lossy with arguments having no option characters
Date: 2015-04-03 22:45:44
Message-ID: 20150403224544.GI17586@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2015-04-03 19:06:38 -0300, Alvaro Herrera wrote:
> The thing I hate the most about this issue is how some commands fail
> with "--help: unrecognized option" or some such, when called as
>
> command --foo=bar --baz --help

I think that's primarily a different issue though. For some reason I
have yet to figure out --help is usually treated explicitly. E.g.:
if (argc > 1)
{
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
{
usage();
exit(0);
}
else if (strcmp(argv[1], "-V") == 0
|| strcmp(argv[1], "--version") == 0)
{
puts("pg_basebackup (PostgreSQL) " PG_VERSION);
exit(0);
}
}

while ((c = getopt_long(argc, argv, "D:F:r:RT:xX:l:zZ:d:c:h:p:U:s:wWvP",
long_options, &option_index)) != -1)

Some tools then copy the --help/-? handling to the normal option parsing
(like IIRC psql) but others don't (like pg_basebackup).

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Venkata Balaji N 2015-04-04 00:10:36 Re: Postgresql 9.4.1 stuck all queries when making multi updates
Previous Message Alvaro Herrera 2015-04-03 22:06:38 Re: src/port/getopt_long.c lossy with arguments having no option characters