[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug: make fails to execute .BAT files with space in the path, with S

From: Eli Zaretskii
Subject: Re: Bug: make fails to execute .BAT files with space in the path, with SHELL=cmd.exe
Date: Sun, 28 Apr 2013 20:26:06 +0300

> Date: Sat, 27 Apr 2013 21:48:54 +0200
> From: Erik Carstensen <address@hidden>
> I have the following makefile:
> SHELL=cmd.exe
> default:
>         "a b.bat" xy
>         "a b.bat" "x y"
>         a\ b.bat xy
>         a\ b.bat x\ y
> I also have a file 'a b.bat', which contains a single line:
> echo a b
> Now when I run make, this happens:
> /tmp$ /cygdrive/c/mingw64-i686-20110207/bin/make.exe
> "a b.bat" xy
> a b
> "a b.bat" "x y"
> a b
> a\ b.bat xy
> C:\cygwin\tmp>echo a b
> a b
> a\ b.bat x\ y
> 'a' is not recognized as an internal or external command,
> operable program or batch file.
> make: *** [default] Error 1

Thanks for the report.  (Any real reason to use batch files whose
names include whitespace?)

> I think the problem is in the lpCommandLine parameter to CreateProcess,
> where argv[0] needs cmd.exe-style quoting of spaces if it is a .BAT file

I don't think so.  If you add --debug=j switch to the Make command
line, you will see that the quoting is perfectly correct.

So this looks like some quirk of CreateProcess, either with batch
files or with any command with embedded spaces.  Exactly how to format
the 1st and the 2nd arguments to CreateProcess when they include
whitespace is insufficiently documented, and CreateProcess invokes a
variety of heuristics that make the job of discovering its rules all
but impossible.  Note that it only fails if both the batch file name
and its argument are quoted and include whitespace; if any one of the
two does not have whitespace, the command works.

I will try to find a good solution to this when I have time.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]