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: Wed, 22 Oct 2014 20:12:18 +0300

> Date: Tue, 21 Oct 2014 21:12:27 -0400
> From: Noam Postavsky <[email-masked]>
> Cc: [email-masked]
> 
> Patching cmdproxy.c fixes the call-process-shell-command case:
> 
>   (call-process-shell-command
>    "\"c:/path with space/foo-bar.bat\" \"x &y\"" nil '(t t) t)
> 
> To fix the call-process case:
> 
>   (call-process
>    "c:/path with space/foo-bar.bat" nil '(t t) t "x &y")
> 
> required a patch to w32proc.c. This is my first patch to Emacs proper;
> hopefully I got everything in the right format.

Thanks, the changes look reasonable.  If you didn't already, please
run the test suite and make sure there are no regressions due to these
changes.  Bonus points for adding specialized tests to test this
specific issue.

> 	* nt/cmdproxy.c (batch_file_p): new function.
> 	(spawn): if calling a quoted batch file pass NULL for progname.
> 	* src/w32proc.c (create_child): if calling a quoted batch file
> 	pass NULL for exe.

In the future, please begin each ChangeLog entry with a capital
letter.

> +  /* 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. */

Please in the future leave 2 spaces between sentences, per the US
English convention we use in Emacs.

> +  if (progname != NULL && cmdline[0] == '"' && batch_file_p(progname))
> +      progname = NULL;

Our coding style is to leave one space between the function name and
the opening parenthesis that follows it.

If there are no more comments or objections, I will commit in a few
days.

Thanks again for working on this.