/* Proxy shell designed for use with Emacs on Windows 95 and NT.
- Copyright (C) 1997, 2001-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2001-2016 Free Software Foundation, Inc.
Accepts subset of Unix sh(1) command-line options, for compatibility
with elisp code written for Unix. When possible, executes external
{
/* Output literal backslashes. Note that we don't
treat a backslash as an escape character here,
- since it doesn't preceed a quote. */
+ since it doesn't precede a quote. */
for ( ; escape_char_run > 0; escape_char_run--)
*o++ = escape_char;
}
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
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))
{