Re: src/port/getopt_long.c lossy with arguments having no option characters - Mailing list pgsql-bugs

From Andres Freund
Subject Re: src/port/getopt_long.c lossy with arguments having no option characters
Date
Msg-id 20150403224544.GI17586@awork2.anarazel.de
Whole thread Raw
In response to Re: src/port/getopt_long.c lossy with arguments having no option characters  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: src/port/getopt_long.c lossy with arguments having no option characters
List 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

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: src/port/getopt_long.c lossy with arguments having no option characters
Next
From: Venkata Balaji N
Date:
Subject: Re: Postgresql 9.4.1 stuck all queries when making multi updates