Re: [pgsql-hackers-win32] initdb in C

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: [pgsql-hackers-win32] initdb in C
Дата
Msg-id 3FAD3D4D.7030000@dunslane.net
обсуждение исходный текст
Ответ на Re: [pgsql-hackers-win32] initdb in C  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: [pgsql-hackers-win32] initdb in C  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-patches

Bruce Momjian wrote:

>
>
>I ran some tests using XP "CMD" and found:
>
>    "C:\test"
>and
>    "\test"
>
>works but:
>
>    "test"
>
>does not work.  Since I see that the output always has a leading path,
>

On Windows, pgpath is guaranteed to be a full path (see call to
expanded_path() ) exactly so it works inside quotes using the Windows
command processor.

> I
>have modified the code to do:
>
>    printf("\nSuccess. You can now start the database server using:\n\n"
>           "    %s%s%s/postmaster -D %s%s%s\n"
>           "or\n"
>           "    %s%s%s/pg_ctl -D %s%s%s -l logfile start\n\n",
>            QUOTE_PATH, pgpath, QUOTE_PATH, QUOTE_PATH, pg_data, QUOTE_PATH,
>            QUOTE_PATH, pgpath, QUOTE_PATH, QUOTE_PATH, pg_data, QUOTE_PATH);
>
>I am attaching the updated initdb.c file.
>
>
>

The problem with this is that you now have 2 quoted strings. This is
exactly the problem that I solved inside initdb by passing pg_data via
the environment rather than on the command line. "help cmd" on XP gives
you this info:

If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:

    1.  If all of the following conditions are met, then quote characters
        on the command line are preserved:

        - no /S switch
        - exactly two quote characters
        - no special characters between the two quote characters,
          where special is one of: &<>()@^|
        - there are one or more whitespace characters between the
          the two quote characters
        - the string between the two quote characters is the name
          of an executable file.

    2.  Otherwise, old behavior is to see if the first character is
        a quote character and if so, strip the leading character and
        remove the last quote character on the command line, preserving
        any text after the last quote character.

It is amazingly brain dead and cost me hours and hours of grief trying
to work out WTF was going on.

Offhand I can't think of a simple guaranteed to work command line for
the Windows message.

In the last resort we might need to look at having initdb create a .bat
file or two for us.

:-(((

cheers

andrew


В списке pgsql-patches по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: initdb in C
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: [pgsql-hackers-win32] initdb in C