From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | |
Cc: | PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgresql(dot)org>, "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: initdb in C |
Date: | 2003-11-08 19:00:29 |
Message-ID: | 3FAD3D4D.7030000@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-hackers-win32 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
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2003-11-08 19:20:07 | Re: initdb in C |
Previous Message | Tom Lane | 2003-11-08 18:44:42 | Re: Making PostgreSQL 7.4 (CVS) work properly on OS X 10.3 (7B85) |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2003-11-08 19:20:07 | Re: initdb in C |
Previous Message | Andrew Dunstan | 2003-11-08 18:00:56 | Re: [PATCHES] initdb in C |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2003-11-08 19:20:07 | Re: initdb in C |
Previous Message | Andrew Dunstan | 2003-11-08 18:00:56 | Re: [PATCHES] initdb in C |