pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
src/port/getopt_long.c lossy with arguments having no option characters
10+ messages / 5 participants
[nested] [flat]

* src/port/getopt_long.c lossy with arguments having no option characters
@ 2015-04-03 02:44 Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Michael Paquier @ 2015-04-03 02:44 UTC (permalink / raw)
  To: pgsql-bugs

Hi all,

The implementation of getopt_long in src/port has some limitations,
for example such commands do not work but they should:
$ createdb foobar3 -E win1252
createdb: too many command-line arguments (first is "win1252")
Try "createdb --help" for more information.
$ initdb pgdata --noclean
initdb: too many command-line arguments (first is "--noclean")
Try "initdb --help" for more information.

And those ones work:
createdb -E win1252 foobar3
initdb --noclean pgdata

I bumped into this problem when running the TAP tests on Windows, but
I guess that it easy to reproduce it with any builds of Postgres on
Windows as getopt_long is used unconditionally, on any version, for
all commands. Or on any platform that has not getopt_long, if any
exists.
Regards,
-- 
Michael


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
@ 2015-04-03 14:08 ` Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-03 19:47   ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 1 reply; 10+ messages in thread

From: Tom Lane @ 2015-04-03 14:08 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-bugs

Michael Paquier <michael.paquier@gmail.com> writes:
> The implementation of getopt_long in src/port has some limitations,
> for example such commands do not work but they should:

No, those should not work.  You're too used to versions that don't insist
on switches-before-non-switch-arguments.  Such behavior is an extension
that is not standard, is not documented in any Postgres documentation,
and tends to have bad corner-case behaviors.  I don't feel a need to make
our implementation replicate that.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-04-03 19:47   ` Peter Eisentraut <peter_e@gmx.net>
  2015-04-03 21:41     ` Re: src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 22:06     ` Re: src/port/getopt_long.c lossy with arguments having no option characters Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 2 replies; 10+ messages in thread

From: Peter Eisentraut @ 2015-04-03 19:47 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-bugs

On 4/3/15 10:08 AM, Tom Lane wrote:
> Michael Paquier <michael.paquier@gmail.com> writes:
>> The implementation of getopt_long in src/port has some limitations,
>> for example such commands do not work but they should:
> 
> No, those should not work.  You're too used to versions that don't insist
> on switches-before-non-switch-arguments.  Such behavior is an extension
> that is not standard,

It is true that options after non-option arguments are a GNU extension,
but long options are also a GNU extension.  So the behavior we provide
is neither pure POSIX nor pure GNU.  I can see how that would be confusing.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-03 19:47   ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
@ 2015-04-03 21:41     ` Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 21:47       ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 10+ messages in thread

From: Michael Paquier @ 2015-04-03 21:41 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

On Sat, Apr 4, 2015 at 4:47 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
> On 4/3/15 10:08 AM, Tom Lane wrote:
>> Michael Paquier <michael.paquier@gmail.com> writes:
>>> The implementation of getopt_long in src/port has some limitations,
>>> for example such commands do not work but they should:
>>
>> No, those should not work.  You're too used to versions that don't insist
>> on switches-before-non-switch-arguments.  Such behavior is an extension
>> that is not standard,
>
> It is true that options after non-option arguments are a GNU extension,
> but long options are also a GNU extension.  So the behavior we provide
> is neither pure POSIX nor pure GNU.  I can see how that would be confusing.

Well, OK. Then we had better update a bit the TAP tests of initdb and
createdb because they break on any platform which is not compliant
with that.
-- 
Michael


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-03 19:47   ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
  2015-04-03 21:41     ` Re: src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
@ 2015-04-03 21:47       ` Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-04 05:17         ` Re: src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Tom Lane @ 2015-04-03 21:47 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Peter Eisentraut <peter_e@gmx.net>; pgsql-bugs

Michael Paquier <michael.paquier@gmail.com> writes:
> On Sat, Apr 4, 2015 at 4:47 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
>> It is true that options after non-option arguments are a GNU extension,
>> but long options are also a GNU extension.  So the behavior we provide
>> is neither pure POSIX nor pure GNU.  I can see how that would be confusing.

> Well, OK. Then we had better update a bit the TAP tests of initdb and
> createdb because they break on any platform which is not compliant
> with that.

If those tests are dependent on behavior we don't document as allowed,
I think we should change the tests.  Want to send a patch?

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-03 19:47   ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
  2015-04-03 21:41     ` Re: src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 21:47       ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-04-04 05:17         ` Michael Paquier <michael.paquier@gmail.com>
  2015-04-04 17:34           ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Michael Paquier @ 2015-04-04 05:17 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Peter Eisentraut <peter_e@gmx.net>; pgsql-bugs

On Sat, Apr 4, 2015 at 6:47 AM, Tom Lane wrote:
> If those tests are dependent on behavior we don't document as allowed,
> I think we should change the tests.  Want to send a patch?

Attached are patches for HEAD and 9.4. There are problematic tests in
the ones of initdb, clusterdb, reindexdb and createdb.
-- 
Michael

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments: download all (2 files, .tar.gz)

20150404_tap_getopt_fixes.patch (text/x-diff, 3.4K) download diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index 149b3d1..d12be84 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -20,7 +20,7 @@ command_ok([ 'initdb', "$tempdir/data4" ], 'existing empty data directory'); system_or_bail "rm -rf '$tempdir'/*"; -command_ok([ 'initdb', "$tempdir/data", '-X', "$tempdir/pgxlog" ], +command_ok([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'separate xlog directory'); system_or_bail "rm -rf '$tempdir'/*"; @@ -30,15 +30,15 @@ command_fails( system_or_bail "rm -rf '$tempdir'/*"; mkdir "$tempdir/pgxlog"; -command_ok([ 'initdb', "$tempdir/data", '-X', "$tempdir/pgxlog" ], +command_ok([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'existing empty xlog directory'); system_or_bail "rm -rf '$tempdir'/*"; mkdir "$tempdir/pgxlog"; mkdir "$tempdir/pgxlog/lost+found"; -command_fails([ 'initdb', "$tempdir/data", '-X', "$tempdir/pgxlog" ], +command_fails([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'existing nonempty xlog directory'); system_or_bail "rm -rf '$tempdir'/*"; -command_ok([ 'initdb', "$tempdir/data", '-T', 'german' ], +command_ok([ 'initdb', '-T', 'german', "$tempdir/data" ], 'select default dictionary'); diff --git a/src/bin/scripts/t/010_clusterdb.pl b/src/bin/scripts/t/010_clusterdb.pl index cb9d04b..dc0d78a 100644 --- a/src/bin/scripts/t/010_clusterdb.pl +++ b/src/bin/scripts/t/010_clusterdb.pl @@ -21,6 +21,6 @@ command_fails([ 'clusterdb', '-t', 'nonexistent', 'postgres' ], psql 'postgres', 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x'; issues_sql_like( - [ 'clusterdb', 'postgres', '-t', 'test1' ], + [ 'clusterdb', '-t', 'test1', 'postgres' ], qr/statement: CLUSTER test1;/, 'cluster specific table'); diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl index 40fbc92..a44283c 100644 --- a/src/bin/scripts/t/020_createdb.pl +++ b/src/bin/scripts/t/020_createdb.pl @@ -15,7 +15,7 @@ issues_sql_like( qr/statement: CREATE DATABASE foobar1/, 'SQL CREATE DATABASE run'); issues_sql_like( - [ 'createdb', 'foobar2', '-l', 'C', '-E', 'LATIN1', '-T', 'template0' ], + [ 'createdb', '-l', 'C', '-E', 'LATIN1', '-T', 'template0', 'foobar2' ], qr/statement: CREATE DATABASE foobar2 ENCODING 'LATIN1'/, 'create database with encoding'); diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl index d24088e..d5bce43 100644 --- a/src/bin/scripts/t/090_reindexdb.pl +++ b/src/bin/scripts/t/090_reindexdb.pl @@ -20,18 +20,18 @@ issues_sql_like( psql 'postgres', 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a);'; issues_sql_like( - [ 'reindexdb', 'postgres', '-t', 'test1' ], + [ 'reindexdb', '-t', 'test1', 'postgres' ], qr/statement: REINDEX TABLE test1;/, 'reindex specific table'); issues_sql_like( - [ 'reindexdb', 'postgres', '-i', 'test1x' ], + [ 'reindexdb', '-i', 'test1x', 'postgres' ], qr/statement: REINDEX INDEX test1x;/, 'reindex specific index'); issues_sql_like( - [ 'reindexdb', 'postgres', '-S', 'pg_catalog' ], + [ 'reindexdb', '-S', 'pg_catalog', 'postgres' ], qr/statement: REINDEX SCHEMA pg_catalog;/, 'reindex specific schema'); issues_sql_like( - [ 'reindexdb', 'postgres', '-s' ], + [ 'reindexdb', '-s', 'postgres' ], qr/statement: REINDEX SYSTEM postgres;/, 'reindex system tables');
20150404_tap_getopt_fixes_94.patch (text/x-diff, 3.2K) download diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index 149b3d1..d12be84 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -20,7 +20,7 @@ command_ok([ 'initdb', "$tempdir/data4" ], 'existing empty data directory'); system_or_bail "rm -rf '$tempdir'/*"; -command_ok([ 'initdb', "$tempdir/data", '-X', "$tempdir/pgxlog" ], +command_ok([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'separate xlog directory'); system_or_bail "rm -rf '$tempdir'/*"; @@ -30,15 +30,15 @@ command_fails( system_or_bail "rm -rf '$tempdir'/*"; mkdir "$tempdir/pgxlog"; -command_ok([ 'initdb', "$tempdir/data", '-X', "$tempdir/pgxlog" ], +command_ok([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'existing empty xlog directory'); system_or_bail "rm -rf '$tempdir'/*"; mkdir "$tempdir/pgxlog"; mkdir "$tempdir/pgxlog/lost+found"; -command_fails([ 'initdb', "$tempdir/data", '-X', "$tempdir/pgxlog" ], +command_fails([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'existing nonempty xlog directory'); system_or_bail "rm -rf '$tempdir'/*"; -command_ok([ 'initdb', "$tempdir/data", '-T', 'german' ], +command_ok([ 'initdb', '-T', 'german', "$tempdir/data" ], 'select default dictionary'); diff --git a/src/bin/scripts/t/010_clusterdb.pl b/src/bin/scripts/t/010_clusterdb.pl index cb9d04b..dc0d78a 100644 --- a/src/bin/scripts/t/010_clusterdb.pl +++ b/src/bin/scripts/t/010_clusterdb.pl @@ -21,6 +21,6 @@ command_fails([ 'clusterdb', '-t', 'nonexistent', 'postgres' ], psql 'postgres', 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x'; issues_sql_like( - [ 'clusterdb', 'postgres', '-t', 'test1' ], + [ 'clusterdb', '-t', 'test1', 'postgres' ], qr/statement: CLUSTER test1;/, 'cluster specific table'); diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl index 40fbc92..a44283c 100644 --- a/src/bin/scripts/t/020_createdb.pl +++ b/src/bin/scripts/t/020_createdb.pl @@ -15,7 +15,7 @@ issues_sql_like( qr/statement: CREATE DATABASE foobar1/, 'SQL CREATE DATABASE run'); issues_sql_like( - [ 'createdb', 'foobar2', '-l', 'C', '-E', 'LATIN1', '-T', 'template0' ], + [ 'createdb', '-l', 'C', '-E', 'LATIN1', '-T', 'template0', 'foobar2' ], qr/statement: CREATE DATABASE foobar2 ENCODING 'LATIN1'/, 'create database with encoding'); diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl index d5b42de..bba1667 100644 --- a/src/bin/scripts/t/090_reindexdb.pl +++ b/src/bin/scripts/t/090_reindexdb.pl @@ -20,15 +20,14 @@ issues_sql_like( psql 'postgres', 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a);'; issues_sql_like( - [ 'reindexdb', 'postgres', '-t', 'test1' ], + [ 'reindexdb', '-t', 'test1', 'postgres' ], qr/statement: REINDEX TABLE test1;/, 'reindex specific table'); issues_sql_like( - [ 'reindexdb', 'postgres', '-i', 'test1x' ], + [ 'reindexdb', '-i', 'test1x', 'postgres' ], qr/statement: REINDEX INDEX test1x;/, 'reindex specific index'); - issues_sql_like( - [ 'reindexdb', 'postgres', '-s' ], + [ 'reindexdb', '-s', 'postgres' ], qr/statement: REINDEX SYSTEM postgres;/, 'reindex system tables');
^ permalink raw reply [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-03 19:47   ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
  2015-04-03 21:41     ` Re: src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 21:47       ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-04 05:17         ` Re: src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
@ 2015-04-04 17:34           ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 10+ messages in thread

From: Tom Lane @ 2015-04-04 17:34 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: Peter Eisentraut <peter_e@gmx.net>; pgsql-bugs

Michael Paquier <michael.paquier@gmail.com> writes:
> On Sat, Apr 4, 2015 at 6:47 AM, Tom Lane wrote:
>> If those tests are dependent on behavior we don't document as allowed,
>> I think we should change the tests.  Want to send a patch?

> Attached are patches for HEAD and 9.4. There are problematic tests in
> the ones of initdb, clusterdb, reindexdb and createdb.

Pushed, thanks.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-03 19:47   ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
@ 2015-04-03 22:06     ` Alvaro Herrera <alvherre@2ndquadrant.com>
  2015-04-03 22:45       ` Re: src/port/getopt_long.c lossy with arguments having no option characters Andres Freund <andres@anarazel.de>
  1 sibling, 1 reply; 10+ messages in thread

From: Alvaro Herrera @ 2015-04-03 22:06 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs

Peter Eisentraut wrote:
> On 4/3/15 10:08 AM, Tom Lane wrote:
> > Michael Paquier <michael.paquier@gmail.com> writes:
> >> The implementation of getopt_long in src/port has some limitations,
> >> for example such commands do not work but they should:
> > 
> > No, those should not work.  You're too used to versions that don't insist
> > on switches-before-non-switch-arguments.  Such behavior is an extension
> > that is not standard,
> 
> It is true that options after non-option arguments are a GNU extension,
> but long options are also a GNU extension.  So the behavior we provide
> is neither pure POSIX nor pure GNU.  I can see how that would be confusing.

The thing I hate the most about this issue is how some commands fail
with "--help: unrecognized option" or some such, when called as

command --foo=bar --baz --help

I am used to such calls to emit the help, then exit, and the command is
kept in history; that way, it's easy to adjust for the info found in the
help and edit later.  As is, I tend to esc-# to save the commented-out
command in history, then call with only --help, then recall the
commented-out version.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-03 19:47   ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
  2015-04-03 22:06     ` Re: src/port/getopt_long.c lossy with arguments having no option characters Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-04-03 22:45       ` Andres Freund <andres@anarazel.de>
  2015-04-06 19:59         ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 1 reply; 10+ messages in thread

From: Andres Freund @ 2015-04-03 22:45 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Peter Eisentraut <peter_e@gmx.net>; Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs

On 2015-04-03 19:06:38 -0300, Alvaro Herrera wrote:
> The thing I hate the most about this issue is how some commands fail
> with "--help: unrecognized option" or some such, when called as
> 
> command --foo=bar --baz --help

I think that's primarily a different issue though. For some reason I
have yet to figure out --help is usually treated explicitly. E.g.:
	if (argc > 1)
	{
		if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
		{
			usage();
			exit(0);
		}
		else if (strcmp(argv[1], "-V") == 0
				 || strcmp(argv[1], "--version") == 0)
		{
			puts("pg_basebackup (PostgreSQL) " PG_VERSION);
			exit(0);
		}
	}

	while ((c = getopt_long(argc, argv, "D:F:r:RT:xX:l:zZ:d:c:h:p:U:s:wWvP",
							long_options, &option_index)) != -1)

Some tools then copy the --help/-? handling to the normal option parsing
(like IIRC psql) but others don't (like pg_basebackup).

Greetings,

Andres Freund


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: src/port/getopt_long.c lossy with arguments having no option characters
  2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
  2015-04-03 14:08 ` Re: src/port/getopt_long.c lossy with arguments having no option characters Tom Lane <tgl@sss.pgh.pa.us>
  2015-04-03 19:47   ` Re: src/port/getopt_long.c lossy with arguments having no option characters Peter Eisentraut <peter_e@gmx.net>
  2015-04-03 22:06     ` Re: src/port/getopt_long.c lossy with arguments having no option characters Alvaro Herrera <alvherre@2ndquadrant.com>
  2015-04-03 22:45       ` Re: src/port/getopt_long.c lossy with arguments having no option characters Andres Freund <andres@anarazel.de>
@ 2015-04-06 19:59         ` Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 0 replies; 10+ messages in thread

From: Peter Eisentraut @ 2015-04-06 19:59 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Michael Paquier <michael.paquier@gmail.com>; pgsql-bugs

On 4/3/15 6:45 PM, Andres Freund wrote:
> I think that's primarily a different issue though. For some reason I
> have yet to figure out --help is usually treated explicitly.

Because at one point we did not have our own copy of getopt_long.c, so
long options might not have been available.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2015-04-06 19:59 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-04-03 02:44 src/port/getopt_long.c lossy with arguments having no option characters Michael Paquier <michael.paquier@gmail.com>
2015-04-03 14:08 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-04-03 19:47   ` Peter Eisentraut <peter_e@gmx.net>
2015-04-03 21:41     ` Michael Paquier <michael.paquier@gmail.com>
2015-04-03 21:47       ` Tom Lane <tgl@sss.pgh.pa.us>
2015-04-04 05:17         ` Michael Paquier <michael.paquier@gmail.com>
2015-04-04 17:34           ` Tom Lane <tgl@sss.pgh.pa.us>
2015-04-03 22:06     ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-04-03 22:45       ` Andres Freund <andres@anarazel.de>
2015-04-06 19:59         ` Peter Eisentraut <peter_e@gmx.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox