Re: Some useful primitives: escape (and quoting variables), lastwords (for recursivity)… and files with spaces in them?

2018-05-21 Thread Paul Smith
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
found.

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.

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: Some useful primitives: escape (and quoting variables), lastwords (for recursivity)… and files with spaces in them?

2018-05-21 Thread Garreau, Alexandre
On 2018-05-21 at 11:16, Paul Smith wrote:
> On Mon, 2018-05-21 at 08:12 +0200, Garreau, Alexandre wrote:
>> Also I was wondering… would there be some possible mechanism so that
>> a filename with spaces in it might be appropriatedly treated by
>> implicit rules? or is it intrinsic to, say, automatic variables
>> splitting with spaces?
>
> 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?

> 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?

Also what I’d like in a standard escape function is that, being shared,
it would be more tested, and could be improved in case it’s incorrect so
that to fulfill the needed usecase (I only did try all the
non-alphabetical ascii characters to see if they were doing errors when
unescaped), and being that tested, and giving the impression it is
tested or going to be, maybe users would feel more confident of using
it, and quoting their variables: the problem here is not only of
filenames with spaces, but also of void filenames, for better error
detection.

Also I noticed recursivity isn’t that natural with make, not without
something such as car and cdr: my lastwords function play this role but
maybe I’m missing something and most people do it differently…  Would
you think something like it or that would allow the same things more
naturally could go inside make as a new text function?

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make