[Top][All Lists]

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

Re: Some useful primitives: escape (and quoting variables), lastwords (f

From: Paul Smith
Subject: Re: Some useful primitives: escape (and quoting variables), lastwords (for recursivity)… and files with spaces in them?
Date: Mon, 21 May 2018 15:03:31 -0400

On Mon, 2018-05-21 at 18:13 +0200, Garreau, Alexandre wrote:
> > There was a long discussion here a few years ago about a new
> > capability for handling special characters in filenames possible,
> > and I have a partial implementation that was not completed, of a
> > possible way to do this.
> Really? What possible way? IFS like shell? hardcoded list data
> structure on which primitives would operate?

The idea was to introduce a new quoting facility that would allow make
to store strings internally in such a way that whitespace (and other
special characters) wouldn't be considered word separators.

Then just before the recipe was sent to the shell, these strings would
be re-converted into standard format.  It would be the responsibility
of recipe writers to ensure that quoting worked properly.  The solution
only intended to allow make rules and functions to behave properly.

> > Until something drastic changes in GNU make it's simply not
> > feasible to work with whitespace-containing pathnames.  It's best
> > to simply avoid them, rather than spending huge amounts of effort
> > to try to make them work.
> Mmmh, is it so radical? I mean, okay I’d see how, for instance, NUL
> couldn’t be used if it’s like bash and still used as a string
> terminator instead of some length attribute, and I understand you
> can’t splice properly automatic variables values that contain several
> files, or wildcards make functions, etc… but can’t you manage to use
> the shell to quote the file names you get, and quote individual file
> names as I proposed with my functions?

There are a few major issues.  First is, as you say, you can't use any
make functions or most automatic variables or variations such as $(^D)
$(^F) etc.

That by itself is enough to make it a non-starter for pretty much every
makefile out there.

But, in addition how do you create targets or prerequisites with spaces
in the name?  You can't use magical shell quoting on them, because make
looks them up on the filesystem and if you add quoting they won't be

Also, remember that users can set the make SHELL variable to anything
they like: it doesn't have to be a POSIX-y shell.  So, we can't
automatically assume shell-style quoting rules.  We have to leave it up
to the user, or at least allow it to be left up to the user.

reply via email to

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