Re: pg_ctl start broken on windows

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: pg_ctl start broken on windows
Date: 2004-06-10 16:34:38
Message-ID: 200406101634.i5AGYcM28163@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32

Andrew Dunstan wrote:
> Bruce Momjian wrote:
>
> >Andrew Dunstan wrote:
> >
> >
> >>>>C:\msys\1.0\local\pgsql>bin\pg_ctl -D data -l logfile start
> >>>>'C:/msys/1.0/local/pgsql/bin/postmaster.exe" < nul >>"logfile' is not recognized as an internal or external command, operable program or batch file.
> >>>>
> >>>>
> >>I'll test to make sure, but I can tell you now it won't work. It will
> >>see the inner quotes and interpret them as part of the command. (I tried
> >>all these variants when I was testing initdb).
> >>
> >>
> >
> >Claudio reported it worked for pg_dumpall for single quotes:
> >
> > system(''cmd.exe' 'arg1' 'arg2'');
> >
> >What exactly is the logic of the stripping?
> >
> >In fact, pg_ctl is wrong because it is using double quotes instead of
> >the safer single quotes. Let me make that change.
> >
> >
>
> No. It chokes on forward slashes.
>
> and it tries to make a log file called 'logfile' (quotes included).
>
> I really don't see what the problem is with calling CreateProcess - it
> should only be a few lines of code unless I'm much mistaken, and would
> get us out of this setup that is really fragile at best.

I did a lot of poking around in MinGW and found some basic rules. First,
MinGW's system() can't use single quotes for the executable name or any
file used in redirection (as you showed above). Second, it gets
confused with multiple double-quoted strings. The fix is to add a
double-quote to the beginning and end of the system string, so a typical
system string becomes:

system("\"\"ls\" 'a' 'b c' > \"out\"\");

Single quotes are fine for arguments.

The applied patch makes this change and documents the behavior. Would
folks test these changes on Win32 please?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 4.7 KB

In response to

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Gary Doades 2004-06-10 21:35:38 Re: pg_ctl start broken on windows
Previous Message Andrew Dunstan 2004-06-10 14:45:49 Re: pg_ctl start broken on windows