[GENERAL] psql: do/should we document that argument and option specificationorder doesn't matter? - Mailing list pgsql-general

From David G. Johnston
Subject [GENERAL] psql: do/should we document that argument and option specificationorder doesn't matter?
Date
Msg-id CAKFQuwYWdFnwa3eHRnrvGrbQszv=RuDOZ+B-atMsLgad9-egjw@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] psql: do/should we document that argument and option specification order doesn't matter?
List pgsql-general
I don't know if this applies anywhere else but I just stumbled across the fact that our psql documentation is imprecise:


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.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: [GENERAL]
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] psql: do/should we document that argument and option specification order doesn't matter?