In bash file, I can write this:
my_program << EOF
Some test
More test
A lot of multi-line text
EOF
This will launch my_program executable and pass three lines of text (or more) to it through a pipe.
Now I want to so same in Makefile (GNU make). I’ve found no standard solution and it’s solved like this:
LaunchMyProgram:
echo -en "Some test\\nMore test\\nA lot of multi-line text\\n" | my_program
But this look very ugly. Is there more fine solution?
Yes, that is ugly, but there’s not much you can do about it.
makeexecutes each line as its own shell script, unless the line ends with a\continuation character; but then the newline is stripped. This is a little bit cleaner:Normally I’d use
echohere butprintfis a bit more portable when it comes to handling escape characters.