[Cook] Escaping characters for the shell command line
Henderson, Michael D
michael.d.henderson at lmco.com
Tue Jun 14 02:44:32 EST 2005
Jerry, thanks for the reply.
It looks like you're using single quotes around the part after the equal
signs. That's smarter than what I did, since it'll remove all of those
\\\" from it.
I don't understand the use of unsplit, though. It seems to be producing
the equivalent to
' " __FILE__ " " __DATE__ " " __TIME__'
after you apply the catenate. What's the reasoning there? Is unsplit a
good idiom in this case?
Also, Jeff had suggested using the quote function. I went through the
manuals but there's not much on it. I'll keep looking at that.
Thanks again,
Mike
-----Original Message-----
Sent: Friday, June 10, 2005 11:28 PM
Subject: Re: [Cook] Escaping characters for the shell command line
Many times it is easier to use some cook functions to create such
strings.
The following pretty much does what you want but for a couple things.
I did not include the newline characters because they result in a
compiler
warning about multiline string constants. Also using __FILE__ etc must
rely on pre-processor concatination. I believe it might be easier to
construct that data within the cook recipe and build the whole literal
string.
-----
/* THE VERSION STAMP FOR A PARTICULAR BUILD */
/* */
set nosilent;
Project = foo;
Ver = 0.0.0;
cpp_flags = [catenate -DPKG_IDENT\=
'\'"'
"@(#)" [Project] - [Ver]
' "'
[unsplit " " __FILE__ '" "' __DATE__ '" "' __TIME__]
'\''
];
all : ident.o set default;
%.o : %.cpp [__FILE__] set default
{
function print "gen" [target] "due to" [need];
g++ [cpp_flags] -o [target] -c %.cpp;
}
--
Jerry Pendergraft
jerry.pendergraft at endocardial.com
St. Jude Medical voice: 651-523-6935
1350 Energy Lane, Suite 110 fax: 651-644-7897
St Paul, MN 55108-5254 mobile: 651-491-0163
On Thu, 9 Jun 2005, Henderson, Michael D wrote:
> Okay, this is driving me nuts. Is there an easy way to escape
arguments for the command line? I'm trying to drive the ident string for
my files, but trying to figure out how to escape this string is driving
me nuts.
>
> Project = foo;
> Ver = 0.0.0;
> cpp_flags = -DPKG_IDENT\=\"\\\"\\n@(#)[Project]-[Ver] \\\" __FILE__
\\\" \\\" __DATE__ \\\" \\\" __TIME__\\\"\\n\\\"\";
>
> It took me about 15 minutes to plug through this, using trial and
error. Is there a simpler way to do this?
>
> If you want a sample ident.cpp, try a file with just the following in
it
>
> static const char *myIdent = PKG_IDENT;
>
> Thanks,
> Mike
More information about the Cook-users
mailing list