Reputation: 2531
I have got a .rules file with the following command:
echo "char _$(var1)_b_[] = \"@(#) $(var1) $(var2) $(var3)\";" > $@
Processing this file by cygwin bash I've got the following error:
echo "char _a_b_[] = \"@(#) abc 1.2.3 [03/05/2014 064 01:10]\";" > file.c
_a_b_[]: -c: line 1: unexpected EOF while looking for matching `"'
_a_b_[]: -c: line 2: syntax error: unexpected end of file
On Linux it works fine. I tried to replace double quotes with a single ones:
echo 'char _$(var1)_b_[] = "@(#) $(var1) $(var2) $(var3)";' > $@
But it doesn't help for me. What's wrong with this command?
UPD
I found out the error is raised due to space character. The command
echo 'char _$(var1)_b_[] = "@(#) $(var1)";' > $@
failes, but this one
echo 'char _$(var1)_b_[] = "@(#)$(var1)";' > $@
is OK. Looks like bash thinks $(var1) is a new command and can't find needed quote:
echo " " > file.c
\ > file.c: -c: line 1: unexpected EOF while looking for matching `"'
\ > file.c: -c: line 2: syntax error: unexpected end of file
Upvotes: 1
Views: 2644
Reputation: 28190
You could try to offload the echo command to a separate shell script, e.g.
target:
sh generate_code.sh $(var1) $(var2) $(var3) > $@
and generate_code.sh containing
#!/bin/sh
echo "char _${1}_b_[] = \"@(#) $1 $2 $3\";"
Upvotes: 1