From bf6157d7684fde7a2127d7d548d58576529daef8 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 31 Mar 2021 20:31:43 +0300 Subject: makefile_escaping: escape_arg -> noexpand --- _posts/2020-05-20-makefile-escaping.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to '_posts') diff --git a/_posts/2020-05-20-makefile-escaping.md b/_posts/2020-05-20-makefile-escaping.md index faa3754..4308467 100644 --- a/_posts/2020-05-20-makefile-escaping.md +++ b/_posts/2020-05-20-makefile-escaping.md @@ -50,7 +50,7 @@ your-command arg1 arg2)'` with `'$(call escape,$(dangerous_variable))'` and on the command line), add the following lengthy snippet to prevent the values from being expanded: - define escape_arg + define noexpand ifeq ($$(origin $(1)),environment) $(1) := $$(value $(1)) endif @@ -67,9 +67,9 @@ environment variable contains `$` as in `Accidental $variable reference`) are not expanded if you use the following pattern in the Makefile: param1 ?= Default value - $(eval $(call escape_arg,param1)) + $(eval $(call noexpand,param1)) - $(eval $(call escape_arg,param2)) + $(eval $(call noexpand,param2)) Quoting arguments ----------------- @@ -342,7 +342,7 @@ The snippet above can be generalized by defining a custom function that produces the required `make` code, and then calling `eval`. ``` -define escape_arg +define noexpand ifeq ($$(origin $(1)),environment) $(1) := $$(value $(1)) endif @@ -357,11 +357,11 @@ endef test_var ?= This is safe. test_var2 ?= This is safe - 2. -$(eval $(call escape_arg,test_var)) -$(eval $(call escape_arg,test_var2)) +$(eval $(call noexpand,test_var)) +$(eval $(call noexpand,test_var2)) ``` -I couldn't find a case where the combination of `escape` and `escape_arg` +I couldn't find a case where the combination of `escape` and `noexpand` wouldn't work. You can even safely use other variable as the default value of `test_var`, and it works: @@ -372,7 +372,7 @@ it works: escape = $(subst ','\'',$(1)) -define escape_arg +define noexpand ifeq ($$(origin $(1)),environment) $(1) := $$(value $(1)) endif @@ -387,7 +387,7 @@ endef simple_var := Simple value test_var ?= $(simple_var) in test_var -$(eval $(call escape_arg,test_var)) +$(eval $(call noexpand,test_var)) simple_var := New simple value composite_var := Composite value - $(simple_var) - $(test_var) -- cgit v1.2.3