help-make
[Top][All Lists]
Advanced

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

Re: substitution in many files


From: Bob Proulx
Subject: Re: substitution in many files
Date: Wed, 19 Sep 2012 01:19:56 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Dave C wrote:
> perl -i -pe 's|\.\/|\${MPATH}\/|g'
> 
> but when I put this into a make target, I can not get the character
> escaping right.  The shell always ends up interpreting $MPATH as an
> empty variable.

Make is going to do variable espansion on the line first before
passing it to the shell.  Meaning that you will need to escape all '$'
characters that you want passed through to the shell verbatim.  Escape
them by using two dollar signs.

  perl -i -pe 's|\.\/|\$${MPATH}\/|g'

For reference the make documentation says:

  To substitute a variable's value, write a dollar sign followed by the
  name of the variable in parentheses or braces: either `$(foo)' or
  `${foo}' is a valid reference to the variable `foo'.  This special
  significance of `$' is why you must write `$$' to have the effect of a
  single dollar sign in a file name or command.

Bob



reply via email to

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