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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: psql: do/should we document that argument and option specification order doesn't matter?
Date: 2017-05-11 23:15:43
Message-ID: CAKFQuwYWdFnwa3eHRnrvGrbQszv=RuDOZ+B-atMsLgad9-egjw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

i.e., the following is valid:

psql [dbname] [option...] [# you can place username here but only if dbname
is specified...]

Ubuntu Bash; 9.5 tested.

I'm not sure how one would actually document the above in a syntax
specification without being overly verbose but there is no hint that I've
found pertaining to the true behavior. Haven't played with any other of
the supplied binaries; I stumbled across this because I was wrapping psql
in specialized functions and was surprised that where I placed the "$@"
and/or the "service=service-name" specification didn't seem to matter.

Is this some general Bash/Linux-ism that I've just never read about or
realized until now?

David J.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-05-11 23:39:07 Re: psql: do/should we document that argument and option specification order doesn't matter?
Previous Message Adrian Klaver 2017-05-11 22:47:57 Re: