summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2019-10-28 18:15:03 +0000
committerTom Lane2019-10-28 18:15:03 +0000
commitf88544904e4b57b1a8e969a5d594288554417c88 (patch)
tree5503dafca6829885f5b84a6bbbf95660bf7c8b91 /src/test
parentbd1ef5799b04168d8a869197dd9b85935d5d5da9 (diff)
On Windows, use COMSPEC to find the location of cmd.exe.
Historically, psql consulted COMSPEC to spawn a shell in its \! command, but we just invoked "cmd" when spawning shells in pg_ctl and pg_regress. It seems better to rely on the environment variable, if it's set, in all cases. It's debatable whether this is a bug fix or just a behavioral change, so no back-patch. Juan José Santamaría Flecha Discussion: https://postgr.es/m/16080-5d7f03222469f717@postgresql.org
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/pg_regress.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 6554ce214b..297b8fbd6f 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -1193,9 +1193,15 @@ spawn_process(const char *cmdline)
PROCESS_INFORMATION pi;
char *cmdline2;
HANDLE restrictedToken;
+ const char *comspec;
+
+ /* Find CMD.EXE location using COMSPEC, if it's set */
+ comspec = getenv("COMSPEC");
+ if (comspec == NULL)
+ comspec = "CMD";
memset(&pi, 0, sizeof(pi));
- cmdline2 = psprintf("cmd /c \"%s\"", cmdline);
+ cmdline2 = psprintf("\"%s\" /c \"%s\"", comspec, cmdline);
if ((restrictedToken =
CreateRestrictedProcess(cmdline2, &pi)) == 0)