help-make
[Top][All Lists]
Advanced

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

Re: Escaping shell-context variables from make


From: Paul D. Smith
Subject: Re: Escaping shell-context variables from make
Date: Fri, 18 Jan 2002 00:13:02 -0500

%% Nestor Amaya <address@hidden> writes:

  na> I find few things are quite as aggravating as a shell-scripting
  na> difficulty, and so your help is much appreciated. Here's what I've
  na> been banging my head against the wall with (today):

  na> #!/bin/sh
  na>   while  ( some_command ; [ $? -eq 255 ] );
  na>     do sleep 10;
  na>   done

  na> This loop simply checks the exist status of "some_command", and it
  na> keeps trying so long as the status is 255. The problem is that
  na> "$?" is expanded by make prior to being passed to the shell... I
  na> need to somehow pass an unexpanded "$?" to the shell. I have tried
  na> "\", using a ${DOLLARSIGN}, etc... to no avail.

Have you tried reading the manual?  I often find that works better than
beating my head against the wall.  YMMV, I guess :).

For example, from the section "Rule Syntax" in the manual:

     Because dollar signs are used to start variable references, if you
  really want a dollar sign in a rule you must write two of them, `$$'
  (*note How to Use Variables: Using Variables.).

There are various other places this is mentioned as well.

Writing shell scripts in makefiles is really very simple: you must write
them all on one (conceptual) line (so understand where the semicolons go
and don't forget backslashes if you break lines) and you must use "$$"
wherever you want a "$" in your shell script.

All other characters in a command script are passed to the shell verbatim.

-- 
-------------------------------------------------------------------------------
 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]