Subject: Re: bug#18745: 24.3; MS Windows, `call-process-shell-command' fails on `shell-quote-argument'ed bat file with quoted args

From: Eli Zaretskii <[email-masked]>
Date: Thu, 16 Oct 2014 20:06:29 +0300

> Date: Thu, 16 Oct 2014 12:28:58 -0400
> From: Noam Postavsky <[email-masked]>
> Cc: [email-masked]
> 
> On Thu, Oct 16, 2014 at 2:50 AM, Eli Zaretskii <[email-masked]> wrote:
> > This is a Windows misfeature, not an Emacs bug: the CreateProcess
> > primitive fails like that when passed a command that is a batch file.
> 
> So there is no way for Emacs to paper over the Windows ugliness?

I don't know.  In fact, I don't even know the exact nature of the
"ugliness", as these intimate details of the CreateProcess API are not
documented anywhere, AFAIK, at least not officially.  I just know
about this because I bumped into it in the past.

This is exacerbated in Emacs by the fact that the shell command is
processed twice: once by Emacs, and then again by cmdproxy.

GNU Make overcomes this by detecting these cases, and invoking
CreateProcess in a special way (NULL as the first argument), see the
function process_begin there, around line 710 of sub_proc.c in the GNU
Make sources.  If you can come up with a way to do the same in Emacs,
by some suitable patch to cmdproxy.c, such a patch will be welcome
(assuming either the patch is small, or you will agree to sign legal
papers necessary for submitting substantial patches to FSF projects).

Failing that, I can suggest a workaround: use the short 8+3 alias of
the file name with whitespace.  You can obtain the short alias of any
existing file's name by calling w32-short-filename.  Then you won't
need to quote the batch file name.