fix in --help output

Started by Zdenek Kotalaover 18 years ago19 messagespatches
Jump to latest
#1Zdenek Kotala
Zdenek.Kotala@Sun.COM

I attach fix for --help output. I replaced --NAME... with -NAME and add some
example. getopt parse -- as a end of options and rest of line is not parsed.
This should be backported for 8.3 and 8.2 as well. PG8.1 does not have this options.

Thanks Zdenek

Attachments:

help.patchtext/x-patch; name=help.patchDownload+2-2
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Zdenek Kotala (#1)
Re: fix in --help output

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

I attach fix for --help output. I replaced --NAME... with -NAME and add some
example. getopt parse -- as a end of options and rest of line is not parsed.

Surely this is outright wrong. Or if you do have a getopt that acts
that way, the bug is that we are using it rather than one that acts
the way we want.

regards, tom lane

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Zdenek Kotala (#1)
Re: fix in --help output

Zdenek Kotala wrote:

I attach fix for --help output. I replaced --NAME... with -NAME

But that is wrong.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#4Zdenek Kotala
Zdenek.Kotala@Sun.COM
In reply to: Tom Lane (#2)
Re: fix in --help output

Tom Lane napsal(a):

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

I attach fix for --help output. I replaced --NAME... with -NAME and add some
example. getopt parse -- as a end of options and rest of line is not parsed.

Surely this is outright wrong. Or if you do have a getopt that acts
that way, the bug is that we are using it rather than one that acts
the way we want.

Ah, sorry it really does not work.

However, I get following error on Solaris:

bash-3.2$ /usr/postgres/8.2/bin/postgres -D /tmp/db --share_buffers=16000
/usr/postgres/8.2/bin/postgres: illegal option -- share_buffers=16000
Try "postgres --help" for more information.

but following command works fine:

/usr/postgres/8.2/bin/postgres -D /tmp/db -c shared_buffers=16000

By my opinion problem is in getopt which interprets -- as a end of
options list.

See
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02
Guideline 10

It maybe work on linux but I think it is not portable solution.

Zdenek

#5Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Zdenek Kotala (#4)
Re: fix in --help output

Zdenek Kotala wrote:

It maybe work on linux but I think it is not portable solution.

What we should do is avoid using Solaris' getopt_long and instead use
the copy we have in src/port/.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#6Zdenek Kotala
Zdenek.Kotala@Sun.COM
In reply to: Alvaro Herrera (#5)
Re: fix in --help output

Alvaro Herrera napsal(a):

Zdenek Kotala wrote:

It maybe work on linux but I think it is not portable solution.

What we should do is avoid using Solaris' getopt_long and instead use
the copy we have in src/port/.

If I looked correctly there is no getopt_long. There is only getopt with
- as a option. See PostmasterMain:

while ((opt = getopt(argc, argv,
"A:B:c:D:d:EeFf:h:ijk:lN:nOo:Pp:r:S:sTt:W:-:")) != -1)

If I understand correctly the POSIX standard "-" should not used in a
option list.

Zdenek

#7Andrew Dunstan
andrew@dunslane.net
In reply to: Zdenek Kotala (#4)
Re: fix in --help output

Zdenek Kotala wrote:

Tom Lane napsal(a):

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

I attach fix for --help output. I replaced --NAME... with -NAME and
add some example. getopt parse -- as a end of options and rest of
line is not parsed.

Surely this is outright wrong. Or if you do have a getopt that acts
that way, the bug is that we are using it rather than one that acts
the way we want.

Ah, sorry it really does not work.

However, I get following error on Solaris:

bash-3.2$ /usr/postgres/8.2/bin/postgres -D /tmp/db --share_buffers=16000
/usr/postgres/8.2/bin/postgres: illegal option -- share_buffers=16000
Try "postgres --help" for more information.

but following command works fine:

/usr/postgres/8.2/bin/postgres -D /tmp/db -c shared_buffers=16000

By my opinion problem is in getopt which interprets -- as a end of
options list.

See
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02

Guideline 10

It maybe work on linux but I think it is not portable solution.

-- on its own might indicate the end of arguments, but that's quite
different from --foo=bar. Guideline 10 of the above surely only refers
to -- as an entire argument, not to -- as the first two characters of an
argument. If your getopt treats *any* -- as the end of options then I
think it is broken (complain to your vendor ;-) ). And the answer is
known - use the one we have in src/port.

cheers

andrew

#8Zdenek Kotala
Zdenek.Kotala@Sun.COM
In reply to: Andrew Dunstan (#7)
Re: fix in --help output

Andrew Dunstan napsal(a):

Zdenek Kotala wrote:

Tom Lane napsal(a):

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

I attach fix for --help output. I replaced --NAME... with -NAME and
add some example. getopt parse -- as a end of options and rest of
line is not parsed.

Surely this is outright wrong. Or if you do have a getopt that acts
that way, the bug is that we are using it rather than one that acts
the way we want.

Ah, sorry it really does not work.

However, I get following error on Solaris:

bash-3.2$ /usr/postgres/8.2/bin/postgres -D /tmp/db --share_buffers=16000
/usr/postgres/8.2/bin/postgres: illegal option -- share_buffers=16000
Try "postgres --help" for more information.

but following command works fine:

/usr/postgres/8.2/bin/postgres -D /tmp/db -c shared_buffers=16000

By my opinion problem is in getopt which interprets -- as a end of
options list.

See
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02

Guideline 10

It maybe work on linux but I think it is not portable solution.

-- on its own might indicate the end of arguments, but that's quite
different from --foo=bar. Guideline 10 of the above surely only refers
to -- as an entire argument, not to -- as the first two characters of an
argument. If your getopt treats *any* -- as the end of options then I
think it is broken (complain to your vendor ;-) ). And the answer is
known - use the one we have in src/port.

You are not correct (I pointed to wrong Guidline). If you look to
Guidline 3 it specific only alphanumeric character. And you can read
"The implementation may accept other characters as an extension." in
http://www.opengroup.org/onlinepubs/009695399/functions/getopt.html

It means that Solaris implementation is OK. Linux uses some extensions
but it is not portable. If we want to use long options. We have
getop_long for it.

Zdenek

#9Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Zdenek Kotala (#6)
Re: fix in --help output

Zdenek Kotala wrote:

If I looked correctly there is no getopt_long. There is only getopt with
- as a option. See PostmasterMain:

while ((opt = getopt(argc, argv,
"A:B:c:D:d:EeFf:h:ijk:lN:nOo:Pp:r:S:sTt:W:-:")) != -1)

If I understand correctly the POSIX standard "-" should not used in a
option list.

Hmm, right. Our current parsing of --long-opts is quite a hack, it
seems :-( Having to list all GUC options in the getopt_long array would
be a mess. Any other ideas?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#10Peter Eisentraut
peter_e@gmx.net
In reply to: Zdenek Kotala (#4)
Re: fix in --help output

Zdenek Kotala wrote:

However, I get following error on Solaris:

bash-3.2$ /usr/postgres/8.2/bin/postgres -D /tmp/db --share_buffers=16000
/usr/postgres/8.2/bin/postgres: illegal option -- share_buffers=16000
Try "postgres --help" for more information.

but following command works fine:

/usr/postgres/8.2/bin/postgres -D /tmp/db -c shared_buffers=16000

share_buffers is not the same as shared_buffers.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#11Zdenek Kotala
Zdenek.Kotala@Sun.COM
In reply to: Peter Eisentraut (#10)
Re: fix in --help output

Peter Eisentraut napsal(a):

Zdenek Kotala wrote:

However, I get following error on Solaris:

bash-3.2$ /usr/postgres/8.2/bin/postgres -D /tmp/db --share_buffers=16000
/usr/postgres/8.2/bin/postgres: illegal option -- share_buffers=16000
Try "postgres --help" for more information.

but following command works fine:

/usr/postgres/8.2/bin/postgres -D /tmp/db -c shared_buffers=16000

share_buffers is not the same as shared_buffers.

Yeah, it was a typo but it does not work anyway.

Zdenek

#12Peter Eisentraut
peter_e@gmx.net
In reply to: Zdenek Kotala (#11)
Re: fix in --help output

Am Freitag, 22. Februar 2008 schrieb Zdenek Kotala:

Peter Eisentraut napsal(a):

Zdenek Kotala wrote:

However, I get following error on Solaris:

bash-3.2$ /usr/postgres/8.2/bin/postgres -D /tmp/db
--share_buffers=16000 /usr/postgres/8.2/bin/postgres: illegal option --
share_buffers=16000 Try "postgres --help" for more information.

but following command works fine:

/usr/postgres/8.2/bin/postgres -D /tmp/db -c shared_buffers=16000

share_buffers is not the same as shared_buffers.

Yeah, it was a typo but it does not work anyway.

Well, if it doesn't work you can use the -c option.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#13Zdenek Kotala
Zdenek.Kotala@Sun.COM
In reply to: Alvaro Herrera (#9)
Re: fix in --help output

Alvaro Herrera napsal(a):

Zdenek Kotala wrote:

If I looked correctly there is no getopt_long. There is only getopt with
- as a option. See PostmasterMain:

while ((opt = getopt(argc, argv,
"A:B:c:D:d:EeFf:h:ijk:lN:nOo:Pp:r:S:sTt:W:-:")) != -1)

If I understand correctly the POSIX standard "-" should not used in a
option list.

Hmm, right. Our current parsing of --long-opts is quite a hack, it
seems :-( Having to list all GUC options in the getopt_long array would
be a mess. Any other ideas?

I attached patch which replaces any "--..." occurrence with "-c..." on
command line.

Zdenek

Attachments:

getopt.patchtext/x-patch; name=getopt.patchDownload+23-19
#14Zdenek Kotala
Zdenek.Kotala@Sun.COM
In reply to: Peter Eisentraut (#12)
Re: fix in --help output

Peter Eisentraut napsal(a):

Am Freitag, 22. Februar 2008 schrieb Zdenek Kotala:

Peter Eisentraut napsal(a):

Zdenek Kotala wrote:

However, I get following error on Solaris:

bash-3.2$ /usr/postgres/8.2/bin/postgres -D /tmp/db
--share_buffers=16000 /usr/postgres/8.2/bin/postgres: illegal option --
share_buffers=16000 Try "postgres --help" for more information.

but following command works fine:

/usr/postgres/8.2/bin/postgres -D /tmp/db -c shared_buffers=16000

share_buffers is not the same as shared_buffers.

Yeah, it was a typo but it does not work anyway.

Well, if it doesn't work you can use the -c option.

Yes, but it is confusing. For example see following message:

postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the
PGDATA environment variable.

config-file is there mention as a hint, but it does not work and I think
there are more places where usage of "--.." is mentioned. It is
confusing for the user and there is no clue.

Zdenek

#15Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Zdenek Kotala (#13)
Re: fix in --help output

Zdenek Kotala wrote:

Alvaro Herrera napsal(a):

Hmm, right. Our current parsing of --long-opts is quite a hack, it
seems :-( Having to list all GUC options in the getopt_long array would
be a mess. Any other ideas?

I attached patch which replaces any "--..." occurrence with "-c..." on
command line.

Actually I meant a way to make our current hack work on your platform.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#16Tom Lane
tgl@sss.pgh.pa.us
In reply to: Zdenek Kotala (#13)
Re: fix in --help output

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

I attached patch which replaces any "--..." occurrence with "-c..." on
command line.

Please see whether forcibly using src/port/getopt.c fixes this,
instead. A saner patch would probably add something like this
to configure.in:

if test "$PORTNAME" = "solaris"; then
AC_LIBOBJ(getopt)
AC_LIBOBJ(getopt_long)
fi

regards, tom lane

#17Zdenek Kotala
Zdenek.Kotala@Sun.COM
In reply to: Tom Lane (#16)
Re: fix in --help output

Tom Lane napsal(a):

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

I attached patch which replaces any "--..." occurrence with "-c..." on
command line.

Please see whether forcibly using src/port/getopt.c fixes this,
instead. A saner patch would probably add something like this
to configure.in:

if test "$PORTNAME" = "solaris"; then
AC_LIBOBJ(getopt)
AC_LIBOBJ(getopt_long)
fi

Yeah, this is the best solution. I attach a patch. Is possible to
backport it back to 8.3, 8.2?

Just for completeness Solaris getopt function has a extension which
processes long option argument. This extension is called CLIP. This
implementation collides with unusual getopt usage for long option
processing in PostgreSQL.

More info are there:
http://docs.sun.com/app/docs/doc/819-2243/getopt-3c?l=en&amp;a=view
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/getopt.c
http://docs.sun.com/app/docs/doc/819-2239/6n4hsf6e5?l=en&amp;a=view

By the way old solaris getopt version is similary with postgres
implementation. :-)

http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libbc/libc/gen/common/getopt.c

Thanks for help
Zdenek

#18Zdenek Kotala
Zdenek.Kotala@Sun.COM
In reply to: Zdenek Kotala (#17)
Re: fix in --help output

Ups. Patch attached

Zdenek

Zdenek Kotala napsal(a):

Show quoted text

Tom Lane napsal(a):

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

I attached patch which replaces any "--..." occurrence with "-c..."
on command line.

Please see whether forcibly using src/port/getopt.c fixes this,
instead. A saner patch would probably add something like this
to configure.in:

if test "$PORTNAME" = "solaris"; then
AC_LIBOBJ(getopt)
AC_LIBOBJ(getopt_long)
fi

Yeah, this is the best solution. I attach a patch. Is possible to
backport it back to 8.3, 8.2?

Just for completeness Solaris getopt function has a extension which
processes long option argument. This extension is called CLIP. This
implementation collides with unusual getopt usage for long option
processing in PostgreSQL.

More info are there:
http://docs.sun.com/app/docs/doc/819-2243/getopt-3c?l=en&amp;a=view
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/getopt.c

http://docs.sun.com/app/docs/doc/819-2239/6n4hsf6e5?l=en&amp;a=view

By the way old solaris getopt version is similary with postgres
implementation. :-)

http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libbc/libc/gen/common/getopt.c

Thanks for help
Zdenek

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Attachments:

getopt.patchtext/x-patch; name=getopt.patchDownload+8-0
#19Bruce Momjian
bruce@momjian.us
In reply to: Zdenek Kotala (#18)
Re: fix in --help output

Zdenek Kotala wrote:

Ups. Patch attached

Tom has applied this patch to CVS HEAD and all relevant back-branches.

---------------------------------------------------------------------------

Zdenek

Zdenek Kotala napsal(a):

Tom Lane napsal(a):

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

I attached patch which replaces any "--..." occurrence with "-c..."
on command line.

Please see whether forcibly using src/port/getopt.c fixes this,
instead. A saner patch would probably add something like this
to configure.in:

if test "$PORTNAME" = "solaris"; then
AC_LIBOBJ(getopt)
AC_LIBOBJ(getopt_long)
fi

Yeah, this is the best solution. I attach a patch. Is possible to
backport it back to 8.3, 8.2?

Just for completeness Solaris getopt function has a extension which
processes long option argument. This extension is called CLIP. This
implementation collides with unusual getopt usage for long option
processing in PostgreSQL.

More info are there:
http://docs.sun.com/app/docs/doc/819-2243/getopt-3c?l=en&amp;a=view
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/getopt.c

http://docs.sun.com/app/docs/doc/819-2239/6n4hsf6e5?l=en&amp;a=view

By the way old solaris getopt version is similary with postgres
implementation. :-)

http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libbc/libc/gen/common/getopt.c

Thanks for help
Zdenek

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +