Re: BUG #19042: Option --help not recognized at the end of command line in pg_restore
Daniel Gustafsson <daniel@yesql.se>
From: Daniel Gustafsson <daniel@yesql.se>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, Matthias Hörmann <matthias.hoermann@saltation.com>, pgsql-bugs@lists.postgresql.org
Date: 2025-10-24T22:26:01Z
Lists: pgsql-bugs
Attachments
- v1-0001-Handle-help-and-version-as-normal-commandline-par.patch (application/octet-stream) patch v1-0001
- v1-0002-Consistently-use-exit-code-1-for-invalid-argument.patch (application/octet-stream) patch v1-0002
> On 22 Oct 2025, at 23:23, Nathan Bossart <nathandbossart@gmail.com> wrote: > > On Wed, Sep 10, 2025 at 11:24:36AM +0200, Daniel Gustafsson wrote: >> I am writing up a patch to move it into long option processing to see >> what it would look like, will share soon. > > Are you still planning to work on this one? Attached is a v1 which converts all the apps in the tree to allow version and help arguments at any position. There was quite the variety of how the help/version arguments were handled, some apps had partial support in the longopts, some had full support and some had none. The idea was to make handling consistent across the binaries without introducing any dependencies or build time changes. While hacking on this it seemed like a good idea to move to using progname consistently, and reduce scope in some places from global variables, but looking at it now I'm less convinced. At the very least it should be ripped out into its own patch but for now those changes are left in there. It's far from an exciting patchset but it would be nice to get it done once and for all. 0002 is a small change to make sure all apps exit with the same code, I was unable to find a documented rationale for exit(2) so I think it's an oversight. -- Daniel Gustafsson