aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-03-21 08:44:53 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2022-03-21 08:44:53 +0300
commitf30ef63fd29b968af6495fdb4603eb14583aa208 (patch)
tree50d55fe5eb4025efbc8dfa064974bfc7d344ebd0
parentmakefile_escaping: add to the TL;DR (diff)
downloadblog-f30ef63fd29b968af6495fdb4603eb14583aa208.tar.gz
blog-f30ef63fd29b968af6495fdb4603eb14583aa208.zip
makefile_escaping: terser TL;DR
Diffstat (limited to '')
-rw-r--r--_posts/2020-05-20-makefile-escaping.md14
1 files changed, 6 insertions, 8 deletions
diff --git a/_posts/2020-05-20-makefile-escaping.md b/_posts/2020-05-20-makefile-escaping.md
index 70bf802..d16e3b5 100644
--- a/_posts/2020-05-20-makefile-escaping.md
+++ b/_posts/2020-05-20-makefile-escaping.md
@@ -43,8 +43,7 @@ and you're pretty much good to go.
escape = $(subst ','\'',$(1))
- Use it to safeguard against single quote characters in your variables/function
-outputs.
+ It protects against quite characters in command arguments.
You can then replace things like `'$(dangerous_variable)'` or `'$(shell
your-command arg1 arg2)'` with `'$(call escape,$(dangerous_variable))'` and
`'$(call escape,$(shell your-command arg1 arg2))'`.
@@ -64,14 +63,13 @@ from being expanded:
endif
endef
- You can then be sure any accidental variables references (like if the
-environment variable contains `$` as in `Accidental $variable reference`) are
-not expanded if you use the following pattern in the Makefile:
+ Then `eval` the `noexpand` function output for every possibly overridden
+variable or a used environment variable:
- param1 ?= Default value
- $(eval $(call noexpand,param1))
+ param_with_default_value ?= Default value
+ $(eval $(call noexpand,param_with_default_value))
- $(eval $(call noexpand,param2))
+ $(eval $(call noexpand,used_environment_variable))
Quoting arguments
-----------------