help-make
[Top][All Lists]
Advanced

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

RE: can't get shell var to work in rule


From: Paul D. Smith
Subject: RE: can't get shell var to work in rule
Date: Thu, 28 Feb 2002 18:15:33 -0500

%% Nestor Amaya <address@hidden> writes:

  nl> find $(TMPDIR) -name '*~' | while read line; do rm "$line"; done

As Nestor points out, the "$l" in "$line" is expanded by make as the
variable "l", which is not defined and so expands to nothing.

Whenever shell scripting in make command scripts you _MUST_ remember to
escape all "$"'s you want passed to the shell.

  na> I had the same problem. Do the following:

  na> find $(TMPDIR) -name '*~' | while read line; do rm "$$line"; done

Note that this is not portable shell script syntax.  If you want to do
it portably you need:

  find $(TMPDIR) -name '*~' | (while read line; do rm "$$line"; done)

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "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]