[Cook] Escaping characters for the shell command line

Jerry Pendergraft jerry at endocardial.com
Sat Jun 11 15:28:19 EST 2005


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
> 
> The lazy brown duck chased the quick green fox across the pasture and into the tree by the fence, then ate a grilled onion sandwich (on rye, of course).
> 
> _______________________________________________
> Cook-users mailing list
> Cook-users at auug.org.au
> http://www.auug.org.au/mailman/listinfo/cook-users
> 




More information about the Cook-users mailing list