Re: [patch] pg_test_timing does not prompt illegal option
От | Tom Lane |
---|---|
Тема | Re: [patch] pg_test_timing does not prompt illegal option |
Дата | |
Msg-id | 2671.1555518991@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: [patch] pg_test_timing does not prompt illegal option (Fabien COELHO <coelho@cri.ensmp.fr>) |
Ответы |
Re: [patch] pg_test_timing does not prompt illegal option
|
Список | pgsql-hackers |
Fabien COELHO <coelho@cri.ensmp.fr> writes: >> I think it might be an actively bad idea. There's a pretty >> widespread convention that "--" is a no-op switch indicating >> the end of switches. At least some of our tools appear to >> honor that behavior (probably because glibc's getopt_long >> does; I do not think we are implementing it ourselves). > "src/port/getopt_long.c" checks for "--" as the end of options. Ah. But I was checking this on a Linux build that's using glibc's implementation, not our own. It's pretty easy to prove that psql, for one, acts that way when using the glibc subroutine: $ psql -- -E psql: error: could not connect to server: FATAL: database "-E" does not exist We've generally felt that deferring to the behavior of the platform's getopt() or getopt_long() is a better idea than trying to enforce some lowest-common-denominator version of switch parsing, on the theory that users of a given platform will be used to whatever its getopt does. This does mean that we have undocumented behaviors on particular platforms. I'd say that accepting "--" is one of them. Another example is that glibc's getopt is willing to reorder the arguments, so that for example this works for me: $ psql template1 -E psql (12devel) Type "help" for help. template1=# \set ... ECHO_HIDDEN = 'on' ... On other platforms that would not work, so we don't document it. regards, tom lane
В списке pgsql-hackers по дате отправления: