bug-make
[Top][All Lists]
Advanced

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

Re: mention how to quote a comma in "call"


From: Sam Ravnborg
Subject: Re: mention how to quote a comma in "call"
Date: Sat, 2 Jun 2007 06:25:22 +0200
User-agent: Mutt/1.4.2.1i

On Sat, Jun 02, 2007 at 05:25:50AM +0800, address@hidden wrote:
> Your
>   reverse = $(2) $(1)
> example in the manual is great, however if one day your users happen
> to want to quote a comma,
> OK:;echo $(call reverse,a,b)
> SORRY1:;echo $(call reverse,a\,b,c)
> SORRY2:;echo $(call reverse,"a,b",c)
> then they are S.O.L. unless you mention how.
> 
> One apparently needs to do
> EE=a,b
> OK2:;echo $(call reverse,$(EE),c)
> 
> Mention that it is the only(?) way.
> 
> Wait,
> OK3:;s=,;echo $(call reverse,a$${s}b,c)

>From info make:

   Commas and unmatched parentheses or braces cannot appear in the text
 of an argument as written; leading spaces cannot appear in the text of
 the first argument as written.  These characters can be put into the
 argument value by variable substitution.  First define variables
 `comma' and `space' whose values are isolated comma and space
 characters, then substitute these variables where such characters are
 wanted, like this:
 
      comma:= ,
      empty:=
      space:= $(empty) $(empty)
      foo:= a b c
      bar:= $(subst $(space),$(comma),$(foo))
      # bar is now `a,b,c'.
 
 Here the `subst' function replaces each space with a comma, through the
 value of `foo', and substitutes the result.


Available online here: 
http://uw713doc.sco.com/cgi-bin/info2html?(make.info)Syntax%2520of%2520Functions&lang=en

That should cover it.

        Sam




reply via email to

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