Re: Fix initdb for path with whitespace and at char - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Fix initdb for path with whitespace and at char
Date
Msg-id 535FFBC1.2020402@vmware.com
Whole thread Raw
In response to Fix initdb for path with whitespace and at char  (Nikhil Deshpande <nikhail@gmail.com>)
Responses Re: Fix initdb for path with whitespace and at char  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 04/29/2014 09:14 PM, Nikhil Deshpande wrote:
> On win32, initdb fails if it's path includes a space and at ('@')
> character. E.g.
>
> C:\>"C:\Program Files\user@company\Postgres\9.3\bin\initdb.exe" -D "c:\baz"
> 'C:\Program' is not recognized as an internal or external command,
> operable program or batch file.
>
> Here's a patch that fixes initdb by enclosing the command string in
> extra double quotes being passed to popen() (similar to system() call).

This looks correct to me. popen() requires SYSTEMQUOTEs on Windows, like 
system() does. We already use SYSTEMQUOTEs in some popen() calls, like 
in pg_ctl, but initdb is missing them. get_bin_version function in 
pg_upgrade is also missing it, as is the popen() call in COPY TO/FROM 
PROGRAM command.

Is there any situation where would *not* want to wrap the command in 
SYSTEMQUOTEs? If there isn't, ISTM it would be better to create a 
wrapper function, pgwin32_popen(), which adds the quotes instead of 
sprinkling them into all callers. Even if we go around and fix all of 
the callers now, we're bound to forget it again in the future.

- Heikki



pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Considerer Harmful Considered Harmful
Next
From: Jim Nasby
Date:
Subject: Re: Buildfarm "master-next" branch?