Heikki Linnakangas <hlinnakangas@vmware.com> writes:
> 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.
Yuck.
> 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.
We might forget to use the wrapper function too, if it has a nonstandard
name, no? A better idea would be to redefine popen() and system() on
Windows. It looks like we're already using a #define to redefine popen().
This approach would let us get rid of nonstandard notation for this
problem, instead of adding more.
regards, tom lane