I just solved a problem with my Makefile(s). Make trips over every <<<
with the error message
/bin/sh: 1: Syntax error: redirection unexpected
And I would like to know why. (I am using Bash as SHELL
)
In my current projects I tried a lot of recipies along the lines of:
target:
read FOO <<< "XXX"; \
read BAR <<< "YYY"; \
read BAZ <<< "ZZZ"; \
someprog -a param0 -b $$FOO -c param1 -d $${BAR} -e param2 -f $${BAZ} >$@
Trying this will result in an error for every <<<
as described at the beginning. My workaround is
target.dep:
echo "XXX YYY ZZZ" >$@
target: %: %.dep
read FOO BAR BAZ < $<;\
someprog -a param0 -b $$FOO -c param1 -d $${BAR} -e param2 -f $${BAZ} >$@
which means I put my stuff into temporary files which I then read with <
, which works just fine. When I copy paste my make output to a normal bash prompt, every command works just as expected, even with the <<<
. I am fairly certain that my problem is, that using the <<<
operator, i.e. here strings, break something. Why is that and is there a way to make here strings work in Makefiles?
P.S.: Yes, sometimes I feel autotools would be the better choice over make.