Ron Johnson <ronljohnsonjr@gmail.com> writes:
> On Mon, Dec 18, 2023 at 10:41 AM David G. Johnston <
> david.g.johnston@gmail.com> wrote:
>> I'm thinking that the forced ordering being different than what is
>> documented is a shell-specific issue. As for why only one of restart,
>> stop, start, etc... can be specified for any given invocation of pg_ctl,
>> that seems like an entirely realistic limitation and typo-preventing
>> feature.
> The error message is "pg_ctl: *too many command-line arguments*". It's
> manifestly obvious that the command failed when I added a "-" option, not a
> "start", "stop" command. and yet pg_ctl complained about command-line
> arguments.
The program's coding expects that optional switches will appear before
the action specifier. You can get away with writing the action first
only if the version of getopt_long() that's in use will permute the
argument array to move non-options to the end. That's always true on
glibc-based platforms, but otherwise usually not, at least in PG v14.
(Yes, I'm aware that pg_ctl's --help message claims this works
everywhere. It's lying.)
Having said that, the most obvious way to explain the results you
seem to be getting is that you're using a version of getopt_long()
that tries to permute the arguments and is getting it wrong.
So, what's the platform? And are you quite sure your psql is v14?
regards, tom lane