help-make
[Top][All Lists]
Advanced

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

Re: Tricky problem filtering out commas from a string.


From: Danny Boelens
Subject: Re: Tricky problem filtering out commas from a string.
Date: Thu, 19 Apr 2007 14:37:59 +0200

----- Original Message ----- 
From: "Dave Korn" <address@hidden>
To: <address@hidden>
Sent: Thursday, April 19, 2007 2:15 PM
Subject: Tricky problem filtering out commas from a string.


> --------------------begin comma.mk--------------------
> LIST_WITH_COMMAS:= foo, bar, baz, quux
> LIST_WITHOUT_COMMAS:=$(filter-out \,,$(LIST_WITH_COMMAS))
> $(warning $(LIST_WITHOUT_COMMAS))
> LIST2_WITHOUT_COMMAS:=$(subst \,, ,$(LIST_WITH_COMMAS))
> $(warning $(LIST2_WITHOUT_COMMAS))
>
> all:
> @
>
> --------------------end comma.mk--------------------
>
>  The obvious first approach - escape the comma so that filter-out doesn't
> think it's the separator between its two arguments - just doesn't work.  I
> can't quite see how to achieve this in make....

Try this:

--------------------begin comma.mk--------------------
COMMA := ,

LIST_WITH_COMMAS:= foo, bar, baz, quux
LIST_WITHOUT_COMMAS:=$(filter-out $(COMMA),$(LIST_WITH_COMMAS))
$(warning $(LIST_WITHOUT_COMMAS))
LIST2_WITHOUT_COMMAS:=$(subst $(COMMA), ,$(LIST_WITH_COMMAS))
$(warning $(LIST2_WITHOUT_COMMAS))

all:
--------------------end comma.mk--------------------

The first approach still fails of course because the comma isn't a word on
it's own in the list (so if the list would be "foo, bar, baz, quux ," the
last comma would be filtered out!), but the second one works fine :-)

Hope this helps,
Danny





reply via email to

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