I came up wit this cunning use of bash to remove the back-slash before the newline allows true multi-line shell fragments as make recipes.

SHELL:=bash -c 'exec $(SHELL) "$${@//\\$$'\''\012'\''/$$'\''\012'\''}"' --

test:
        if test 1 = 1 \
        then echo yes \
        else echo no \
        fi


Or for those who prefer:

NEW_SHELL:=bash -c 'exec $(SHELL) "$${@//\\$$'\''\012'\''/$$'\''\012'\''}"' --

test: SHELL=$(NEW_SHELL)
        if test 1 = 1 \
        then echo yes \
        else echo no \
        fi

with associated warnings about SHELL being set for dependencies (if any).

Why? Because my literate-programming tools which automatically quote characters based on file type make it all too easy to include a shell-script fragment in a makefile (with an $ automatically quoted to $$) and I wanted a way to allow multi-line shell script - which might only be multi-line because it includes a multi-line sed fragment (so the old "; \" trick for makefiles won't work).

Sam

--
[FSF Associate Member #2325] <http://www.fsf.org/register_form?referrer=2325>

<http://www.openrightsgroup.org/>
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to