help-make
[Top][All Lists]
Advanced

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

Re: Escaping ${STRING}


From: Paul Smith
Subject: Re: Escaping ${STRING}
Date: Wed, 1 Feb 2012 12:34:20 -0500

On Wed, 2012-02-01 at 08:05 -0800, Ian Gibbs wrote:
> python /home/igibbs/dev/OP/OpenPilot/make/scripts/version-info.py
> --path=/home/igibbs/dev/OP/OpenPilot
> --format='${DATE}-${TAG_OR_HASH8}${DIRTY}'
> 
> It works fine like that on the command line. The single quotes prevent
> the shell from interpreting the format string, so that the python
> script can use it as intended. Here's my make file:

> VERSION_CMD := "python $(ROOT_DIR)/make/scripts/version-info.py 
> --path=$(ROOT_DIR) --format='$${DATE}-$${TAG_OR_HASH8}$${DIRTY}'"

> It looks like VERSION_CMD is being set correctly.  However, clearly
> when make tries to set VERSION, the strings such as ${DATE} have been
> interpreted somewhere and thus disappeared (I presume it's the shell
> that's done this). Why have the single quotes no longer prevented them
> from being interpreted? I promise I've read the make manual...

You have double-quotes around your entire command:

VERSION_CMD := "python ..."

That's wrong.  That causes the entire thing to be passed to the shell as
one quoted argument.  Try running that with the quotes on the shell
command line and you'll get the same behavior.

The reason your single quotes are hiding the variables is that you've
rendered them inert by adding double-quotes around them: single quotes
are not special within double quotes, and variables are expanded within
double quotes.

Try in your shell

   FOO=foo
   echo '$FOO'
   echo "'$FOO'"

and see the difference.




reply via email to

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