Our getopt_long() doesn't do abbreviations or NLS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Our getopt_long() doesn't do abbreviations or NLS
Date: 2005-01-31 22:16:30
Message-ID: 4875.1107209790@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I just noticed that our port/getopt_long.c substitute implementation
does not accept abbreviated names for long options:

$ pg_dump --username tgl regression
... works ...
$ pg_dump --user tgl regression
pg_dump: illegal option -- user
Try "pg_dump --help" for more information.
$

The GNU implementation of getopt_long is documented to allow this:

The getopt_long() function works like getopt() except that it also
accepts long options, started out by two dashes. Long option names
may be abbreviated if the abbreviation is unique or is an exact match
for some defined option. A long option may take a parameter, of the
form --arg=param or --arg param.

and experimentation confirms it works.

Barring objections, I'm going to modify our version to allow unique
abbreviations too.

I also notice that our version isn't i18n-ready:

if (opterr && optstring[0] != ':')
fprintf(stderr,
"%s: illegal option -- %s\n", argv[0], place);

Should it be gettext'ified?

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-01-31 22:24:26 Re: 7.2.7 -> 8.0.1 Bundles Ready ...
Previous Message Dave Page 2005-01-31 21:30:35 Re: 7.2.7 -> 8.0.1 Bundles Ready ...