help-make
[Top][All Lists]
Advanced

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

Re: Quoting when passing variables via $(MAKE)


From: Paul D. Smith
Subject: Re: Quoting when passing variables via $(MAKE)
Date: Tue, 31 Jan 2006 13:38:09 -0500

%% Greg Chicares <address@hidden> writes:

  gc> In the example below, shouldn't
  gc>   foo='$(foo)'
  gc> with single quotes pass the string
  gc>   $(foo)
  gc> itself, instead of its value?

  gc> all:
  gc>         $(MAKE) -f receive_options.make foo=$(foo)
  gc>         $(MAKE) -f receive_options.make foo='$(foo)'
  gc>         $(MAKE) -f receive_options.make foo="$(foo)"

No.

Make is not the shell and it doesn't implement the shell's parser.
Every "$" in the shell script is expanded by make before the shell is
invoked, without regard to quoting etc.

If you want to put a literal "$" into your shell script, you have to
escape it as "$$":

> all:
>         $(MAKE) -f receive_options.make foo=$$(foo)
>         $(MAKE) -f receive_options.make foo='$$(foo)'
>         $(MAKE) -f receive_options.make foo="$$(foo)"

and quotes don't make any difference.  They will, of course, matter
greatly as to how the _shell_ parses the command line.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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