In the spirit of .ONESHELL, you can come close to the difficult conditions .ONESHELL:
define _oneshell_newline_ endef define oneshell @eval "$$(printf '%s\n' '$(strip \ $(subst $(_oneshell_newline_),\n, \ $(subst \,\/, \ $(subst /,//, \ $(subst ','"'"',$(1))))))' | \ sed -e 's,\\n,\n,g' -e 's,\\/,\\,g' -e 's,
A usage example would be something like this:
define TEST printf '>\n%s\n' "Hello World\n/$$$$/" endef all: $(call oneshell,$(TEST))
This shows the output (assuming pid 27801):
> Hello World\n/27801/
This approach allows you to use some additional features:
define oneshell @eval "set -eux ; $$(printf '%s\n' '$(strip \ $(subst $(_oneshell_newline_),\n, \ $(subst \,\/, \ $(subst /,//, \ $(subst ','"'"',$(1))))))' | \ sed -e 's,\\n,\n,g' -e 's,\\/,\\,g' -e 's,
These shell options will be:
- Print each command when it is executed
- Exiting the first failed team
- Use shell variables undefined as an error
Other interesting features are likely to tell themselves.