[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Escaping ${STRING}
From: |
Ian Gibbs |
Subject: |
Escaping ${STRING} |
Date: |
Wed, 1 Feb 2012 08:05:46 -0800 (PST) |
Dear all,
I need to run this command in my make file, and capture the output to a
variable:
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:
.PHONY: linux_package
PROJECT_SOURCE_SHORT := $(shell basename $(ROOT_DIR))
VERSION_CMD := "python $(ROOT_DIR)/make/scripts/version-info.py
--path=$(ROOT_DIR) --format='$${DATE}-$${TAG_OR_HASH8}$${DIRTY}'"
VERSION := $(shell $(VERSION_CMD))
linux_package:
echo $(VERSION_CMD)
Here's the output:
address@hidden:~/dev/OP/OpenPilot/package$ make ground_package
/bin/sh: python /home/igibbs/dev/OP/OpenPilot/make/scripts/version-info.py
--path=/home/igibbs/dev/OP/OpenPilot --format='-': No such file or directory
echo "python /home/igibbs/dev/OP/OpenPilot/make/scripts/version-info.py
--path=/home/igibbs/dev/OP/OpenPilot --format='${DATE}-${TAG_OR_HASH8}${DIRTY}'"
python /home/igibbs/dev/OP/OpenPilot/make/scripts/version-info.py
--path=/home/igibbs/dev/OP/OpenPilot --format='-'
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...
Thanks for your help.
--
Ian Gibbs
address@hidden
- Escaping ${STRING},
Ian Gibbs <=