Обсуждение: Re: [PATCH] Bug fix in initdb output

Поиск
Список
Период
Сортировка

Re: [PATCH] Bug fix in initdb output

От
Andrew Dunstan
Дата:
On 3/2/21 9:32 AM, Alvaro Herrera wrote:
> On 2021-Mar-02, Nitin Jadhav wrote:
>
>>> FWIW, I don't think that it is a good idea to come back to this
>>> decision for *nix platforms, so I would let it as-is, and use
>>> relative paths if initdb is called using a relative path.
>> The command to be displayed either in absolute path or relative path
>> depends on the way the user is calling initdb. I agree with the above
>> comment to keep this behaviour as-is, that is if the initdb is called
>> using relative path, then it displays relative path otherwise absolute
>> path.
> Yeah.
>
>>> However, if you can write something that makes the path printed
>>> compatible for a WIN32 terminal while keeping the behavior
>>> consistent with other platforms, people would have no objections to
>>> that.
>> I feel the patch attached above handles this scenario.
> Agreed.  I'll push the original patch then.  Thanks everybody for the
> discussion.
>


I'm late to the party on this which is my fault, I had my head down on
other stuff. But I just noticed this commit. Unfortunately the commit
message and this thread contain suggestions that aren't true. How do I
know? Because the buildfarm has for years called pg_ctl via cmd.exe with
a relative path with forward slashes. here's the relevant perl code that
runs on all platforms:


        chdir($installdir);
        my $cmd =
          qq{"bin/pg_ctl" -D data-$locale -l logfile -w start >startlog
2>&1};
        system($cmd);


Note that the pg_ctl path is quoted, and those quotes are passed through
to cmd.exe. That's what makes it work. It's possibly not worth changing
it now, but if anything that's the change that should have been made here.


Just wanted that on the record in case people got this wrong idea that
you can't use forward slashes when calling a program in cmd.exe.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com




Re: [PATCH] Bug fix in initdb output

От
Juan José Santamaría Flecha
Дата:

On Sun, Mar 21, 2021 at 10:28 PM Andrew Dunstan <andrew@dunslane.net> wrote:

Note that the pg_ctl path is quoted, and those quotes are passed through
to cmd.exe. That's what makes it work. It's possibly not worth changing
it now, but if anything that's the change that should have been made here.

The OP claimed that the printed command was not working 'as-is', which is a valid complaint.

Quoting the command seems like a complete answer for this, as it will solve problems with spaces and such for both Windows and Unix-like systems.

Regards,

Juan José Santamaría Flecha
 

Re: [PATCH] Bug fix in initdb output

От
Andrew Dunstan
Дата:
On 3/22/21 4:36 AM, Juan José Santamaría Flecha wrote:
>
> On Sun, Mar 21, 2021 at 10:28 PM Andrew Dunstan <andrew@dunslane.net
> <mailto:andrew@dunslane.net>> wrote:
>
>
>     Note that the pg_ctl path is quoted, and those quotes are passed
>     through
>     to cmd.exe. That's what makes it work. It's possibly not worth
>     changing
>     it now, but if anything that's the change that should have been
>     made here.
>
> The OP claimed that the printed command was not working 'as-is', which
> is a valid complaint.
>
> Quoting the command seems like a complete answer for this, as it will
> solve problems with spaces and such for both Windows and Unix-like
> systems.
>
>

Looking into this more closely, we are calling appendShellString() which
is designed to ensure that we call commands via system() cleanly and
securely. But we're not calling system() here. All we're doing is to
print a message. The caret-escaped message is horribly ugly IMNSHO. Can
we see if we can get something less ugly than this?:

    Success. You can now start the database server using:

        ^"bin^\\pg^_ctl^" -D data-C -l logfile start

cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com