[Cook] Escaping shell characters

Jason Evans jasone at canonware.com
Tue Jan 31 07:12:24 EST 2006


On Jan 29, 2006, at 7:21 PM, John Darrington wrote:
> How can I pass quoted expressions in a rule? Cook insists on pinching
> the ' characters so that the expression gets passed to the shell
> unquoted, and therefore completely screws up.  Such as:
>
> %0%.aux.d: %0%.aux
> {
>   sed  -n -e 's/\\xyzzy{\(.*\)}/gp'  %0%.aux > [target] ;
> }
>
> This problem, so far as I can tell means that only very trivial sed
> examples can be used in cook.

Here's a rule from one of my Cookfiles that uses sed.  It uses  
multiple escapes, as you can see.  It isn't pretty, but it works.

Jason

----
@objroot@/%0html/%1/%.html : @objroot@/%0latex/%1/%.tex
   set mkdir
{
   @LATEX2HTML@ -init_file @srcroot@/%0latex/%1/.latex2html-init
     -dir @abs_objroot@/%0html/%1 -split 5 -toc_depth 4 - 
show_section_numbers
     -footnode -noinfo -auto_link -transparent -image_type png - 
local_icons
     @abs_objroot@/%0latex/%1/%.tex;
   /*
    * Fix up [, ], and \ characters.
    * Get rid of spurious <> at the end of tables.
    */
   [SHELL] -e;
data
   for i in `find @objroot@/%0html/%1/ -type f |grep "\.html$"` ; do
     echo "Fix up $i"
     mv $i $i.tmp
     cat $i.tmp | sed -e s/YYYbsZZZ/\\\\\\\\/g \\
       | sed -e s/YYYlbZZZ/\[/g \\
       | sed -e s/YYYrbZZZ/\]/g \\
       | sed -e s/YYYhrZZZ/\\<hr\\>/g \\
       | sed -e s/YYYddashZZZ/--/g \\
       | sed -e \\
         "s/^\\\\\\(\\\\\\<\\\\/TABLE\\\\\\>\\\\\\)\\\\\\<\\\\\\>/\\\ 
\1/g" \\
       > $i
     rm $i.tmp
   done
dataend

   /*
    * Clean up temp files so that they won't get installed.
    */
   rm -f @objroot@/%0html/%1/WARNINGS;
   rm -f [addprefix @objroot@/%0html/%1/images. aux idx log pl tex];
   rm -f @objroot@/%0html/%1/internals.pl;
   rm -f @objroot@/%0html/%1/labels.pl;
}



More information about the Cook-users mailing list