[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
Re: Bug: make fails to execute .BAT files with space in the path, with SHELL=cmd.exe
Fri, 03 May 2013 11:56:38 +0300
> Date: Fri, 3 May 2013 10:22:40 +0200
> From: Erik Carstensen <address@hidden>
> Cc: address@hidden
> > Make on Windows cannot support escaping with backslash when the shell
> > is cmd.exe. And Make in general doesn't support file names with
> > whitespace too well, you need to introduce blanks via variables, for
> > it to work reliably. The only place where it works well is in the
> > command line itself, but not in variables and certainly not in
> > dependency lists.
> My findings:
> - Space in filenames does work very well in variables, as long as the
> variables are used exclusively in command lines.
> - You are right that it can be tricky to introduce a leading space, but not
> really a big problem. Most people tend to store the space in an
> intermediate variable (the space=$(empty) $(empty) trick)', but I found
> that it's sufficient to just write 'foo=$() xyz'
> - Dependency lists are not a big problem, you just have to escape spaces
> and backslashes properly. It is (fairly) easy to write a function that does
> this. Automatic variables like $@, $< and $^ will be un-escaped, so any
> uses need to be re-quoted or surrounded by double quotes. This is
> practically doable, if you have a limited set of directories that may
> contain space.
> - The only big remaining problem is that there is no way to add a path with
> spaces to VPATH. I have a poor workaround for this (copying needed
> directories to a space-free path before adding them to VPATH). We should
> probably be grateful that a VPATH path cannot contain spaces; e.g., it
> guarantees that %.c always expands to a space-free path.
I agree with all your findings, and they are identical to mine. But
that is exactly the meaning of "doesn't support file names with
whitespace too well": it sometimes works, sometimes doesn't, sometimes
you can work around the problems with a lot of trial-and-error,
sometimes you can't, no matter what. IOW, it's unreliable and is best
Re: Bug: make fails to execute .BAT files with space in the path, with SHELL=cmd.exe, Erik Carstensen, 2013/05/02