Re: Output quoting (was: Re: Possible solution for special characters in makefile paths)

Frank Heckenbach <[email protected]> Thu, 10 Apr 2014 22:55:34 +0200
Newsgroups gmane.comp.gnu.make.devel
Message-ID <[email protected]>
Eli Zaretskii wrote:

> > I didn't say there was a contradiction. The only one, kind of, is
> > that I think the quoting should be done automatically by default
> > (e.g. by having SHELL_QUOTE set by default and used automatically).
> 
> Can you give an example, so I'm sure I'm on the same page as you are?

I gave a possible SHELL_QUOTE definition for sh-style quoting in
previous mails.

If make would define this by default and apply it automatically when
substituting a variable in a recipe, the recipe could simply look
like this, without any explicit quoting:

%.x: %.y
	process $< -o $@

Which make internally would turn into:

	process $(call SHELL_QUOTE,$<) -o $(call SHELL_QUOTE,$@)

So when calling make "a b'c<d.x", make would e.g. call:

	process 'a b'\''c<d'.y -o 'a b'\''c<d'.x

> > will not continue to work if $</$@ contain special characters (which
> > I think is not so bad because they already don't work if $</$@
> > contain a certain special character, i.e. ').
> 
> So how would you suggest to handle the built-in rules such that they
> will still work with file names that have embedded spaces?

If SHELL_QUOTE is applied automatically, the built-in rules need no
modification because they don't contain explicit quoting either.

Now, if you want to use another interpreter with different quoting
rules, you can do:

SHELL = /bin/frob
SHELL_QUOTE = $(subst or whatever ...)