X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/4b0b27d0018f040bda6a2ec885fa54c666d9c083..680ee61d04e220e0b2eb4246c8f33773e0185852:/nt/cmdproxy.c diff --git a/nt/cmdproxy.c b/nt/cmdproxy.c index ce5815291d..16956288fe 100644 --- a/nt/cmdproxy.c +++ b/nt/cmdproxy.c @@ -243,6 +243,28 @@ get_next_token (char * buf, const char ** pSrc) return o - buf; } +/* Return TRUE if PROGNAME is a batch file. */ +BOOL +batch_file_p (const char *progname) +{ + const char *exts[] = {".bat", ".cmd"}; + int n_exts = sizeof (exts) / sizeof (char *); + int i; + + const char *ext = strrchr (progname, '.'); + + if (ext) + { + for (i = 0; i < n_exts; i++) + { + if (stricmp (ext, exts[i]) == 0) + return TRUE; + } + } + + return FALSE; +} + /* Search for EXEC file in DIR. If EXEC does not have an extension, DIR is searched for EXEC with the standard extensions appended. */ int @@ -524,6 +546,13 @@ spawn (const char *progname, char *cmdline, const char *dir, int *retcode) memset (&start, 0, sizeof (start)); start.cb = sizeof (start); + /* CreateProcess handles batch files as progname specially. This + special handling fails when both the batch file and arguments are + quoted. We pass NULL as progname to avoid the special + handling. */ + if (progname != NULL && cmdline[0] == '"' && batch_file_p (progname)) + progname = NULL; + if (CreateProcess (progname, cmdline, &sec_attrs, NULL, TRUE, 0, envblock, dir, &start, &child)) {