Re: psql: do/should we document that argument and option specification order doesn't matter?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: psql: do/should we document that argument and option specification order doesn't matter?
Date: 2017-05-11 23:39:07
Message-ID: 15115.1494545947@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> I don't know if this applies anywhere else but I just stumbled across the
> fact that our psql documentation is imprecise:

> https://www.postgresql.org/docs/current/static/app-psql.html

> psql [option...] [dbname [username]]

> It does matter that "dbname" precede username; and that it be present if
> username is specified. But otherwise the first one or two non-option words
> on the command line are taken to be those regardless of position, and any
> extra non-option words are ignored. Options can thus be specified before,
> after, or in between the dbname and username.

This is, unfortunately, platform-specific. glibc's version of
getopt_long() takes it upon itself to physically rearrange the argv
list to make such cases work. On platforms where getopt_long() does
not so blatantly exceed its authority, only the documented argument
order will work.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message George Neuner 2017-05-12 00:23:49 Re: Top posting....
Previous Message David G. Johnston 2017-05-11 23:15:43 psql: do/should we document that argument and option specification order doesn't matter?