----- Original Message ----- From: "Dave Korn" <[EMAIL PROTECTED]> To: <[email protected]> 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 _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
