automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I pass $@ to Makefile?


From: Nick Bowler
Subject: Re: How can I pass $@ to Makefile?
Date: Thu, 28 May 2015 13:39:40 -0400
User-agent: Mutt/1.5.23 (2014-03-12)

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/)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]