On 2015-05-28 10:23 -0700, Arthur Schwarz wrote: > I'm have a little program in my makefile.am: > > test3.abc: > echo '#!/bin/bash' > test3.abc > echo "echo test3.abc $$# ' [' $$@ ']'>> test3.log" >> test3.abc > echo "echo I am a test script >> test3.log" >> test3.abc > > Which works fine except the $$#. What I'm trying to do is to have: > > test3.abc > echo test3.abc $# ' [' $@ '] > > But I don't know how to do the escapes properly.
Since make prints out all the commands it runs by default, quoting issues are normally straightforward to debug as you can just look at the commands it prints to see what's wrong with them. You can go even further and use a command like: make SHELL='sh -x' to additionally have the shell print the commands it runs (after all expansions). So let's try this with your make rule. The lines starting with a "+" character are the actual commands being executed by the shell: % make SHELL='sh -x' test3.abc echo '#!/bin/bash' > test3.abc + echo '#!/bin/bash' echo "echo test3.abc $# ' [' $@ ']'>> test3.log" >> test3.abc + echo 'echo test3.abc 0 '\'' ['\'' '\'']'\''>> test3.log' echo "echo I am a test script >> test3.log" >> test3.abc + echo 'echo I am a test script >> test3.log' Do you see the problem now? Cheers, -- Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)