aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/makefile_escaping/env_vars.mk
blob: 47c1647789829b1b2c06e7cfe7475b6f13434a5d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                            
escape = $(subst ','\'',$(1))
escape_var = $(call escape,$(value $(1)))

test_var ?= This is safe.
export test_var

echo_test_var := printf '%s\n' '$(call escape_var,test_var)'
bash_test_var := bash -c '$(call escape_var,echo_test_var)'

.PHONY: test
test:
	@printf '%s\n' '$(call escape_var,test_var)'
	@printf '%s\n' "$$test_var"
	@bash -c '$(call escape_var,echo_test_var)'
	@bash -c '$(call escape_var,bash_test_var)'