[GRASS-dev] [bug #4498] (grass) d.out.png script copied
	to	docs/html/ in err
    Glynn Clements 
    glynn at gclements.plus.com
       
    Wed May 24 17:02:13 EDT 2006
    
    
  
Markus Neteler wrote:
> Request Tracker wrote:
> 
> >this bug's URL: http://intevation.de/rt/webrt?serial_num=4498
> >-------------------------------------------------------------------------
> >
> >Subject: d.out.png script copied to docs/html/ in err
> >
> >Hi,
> >
> >I just noticed that the d.out.png script is copied to $GISBASE/docs/html/.
> >I guess the Makefile figures it is an image for the help page.
> 
> Right.
> 
> How to get
> 
>         -for file in  *.png *.jpg ; do \
>                 head -1 $$file | grep '#!/bin/sh' > /dev/null \
>                 if [ $$? -ne 0 ] ; then
>                    $(INSTALL_DATA) $$file $(GISBASE)/docs/html \
>                 fi \
>                 done 2> /dev/null ; true
> 
> working (in include/Make/Html.make)?
Add some semicolons, and a backslash.
The above is equivalent to two separate command lines, both erroneous:
        -for file in  *.png *.jpg ; do head -1 $$file | grep '#!/bin/sh' > /dev/null if [ $$? -ne 0 ] ; then
        $(INSTALL_DATA) $$file $(GISBASE)/docs/html ; fi done 2> /dev/null ; true
The missing backslash after the "then" causes the command to be split
into two, each executed by a separate invocation of "/bin/sh -c ...";
as the do/done and if/fi are both split in half, that won't work. 
Also, the missing semicolons before the "if" and the "done" will
result in syntax errors.
Also, I would just check for #! at the beginning of the line;
#!/bin/sh is too specific (e.g. you could have a space after the #!,
or it might be a script in some other language). Any file which begins
with #! is treated as a script by the kernel (i.e. exec()ing the file
will execute the program whose path follows the #! with the script's
path given as an argument).
Finally, "head -n 1" may be more portable than "head -1" (recent
versions generate a warning).
Try:
        -for file in  *.png *.jpg ; do \
                head -n 1 $$file | grep '^#!' > /dev/null ; \
                if [ $$? -ne 0 ] ; then \
                   $(INSTALL_DATA) $$file $(GISBASE)/docs/html ; \
                fi \
                done 2> /dev/null ; true
-- 
Glynn Clements <glynn at gclements.plus.com>
    
    
More information about the grass-dev
mailing list