Re: pgsql: Add new psql help topics, accessible to both --help and \?.

From: Andres Freund <andres(at)anarazel(dot)de>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Add new psql help topics, accessible to both --help and \?.
Date: 2014-09-10 15:06:46
Message-ID: 20140910150646.GS24649@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On 2014-09-10 20:15:31 +0900, Michael Paquier wrote:
> On Wed, Sep 10, 2014 at 10:04 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > The best plan after that seems to be to add optional_argument support to
> > getopt_long.c - looks easy enough. Do we need a configure test for
> > optional_argument? I don't think so, but I could see somebody arguing
> > the other way round.
> Adding support for optional_argument in src/port would be the best
> solution for long-term purposes. So +1 for it or we'll be limited in
> the future as well. Here is for example attached a proof-of-concept
> patch that it is not that complicated to add support for optional
> arguments... Interestingly, the current implementation dates of 2003
> in 939a59f and has not been majorly touched since. The patch has been
> tested with MSVC.

I've attached a edited verion of that patch. Besides cosmetic stuff I
made one imo important change. Your version looked to the next argument
for optional arguments: When --help is an optional argument and e.g. the
commandline is "--help --host" we can't accept --host as --help's value.
So there's now a check for required_arg for that behaviour - which is in
line with all the getopt_long() behaviours I could find docs (or code in
case of netbsd) for.

I'd not mind a review, but I'll push this soon. Doesn't seem worth
reverting the entire psql patch when the fix is as localized as this. We
might conceivably want to change the behaviour of optional_argument, but
as there's only one caller at this point.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
0001-Add-support-for-optional_argument-to-our-own-getopt_.patch text/x-patch 2.4 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2014-09-10 15:26:30 pgsql: Add support for optional_argument to our own getopt_long() imple
Previous Message Andres Freund 2014-09-10 14:05:24 Re: pgsql: Add new psql help topics, accessible to both --help and \?.