[GRASS-dev] Re: [bug #4498] (grass) d.out.png script copied

Glynn Clements glynn at gclements.plus.com
Thu May 25 05:01:41 EDT 2006


Hamish wrote:

> > > >this bug's URL: http://intevation.de/rt/webrt?serial_num=4498
> > > >------------------------------------------------------------------
> ..
> > > >Subject: d.out.png script copied to docs/html/ in err
> ..
> > >         -for file in  *.png *.jpg ; do \
> > >                 head -1 $$file | grep '#!/bin/sh' > /dev/null \
> ..
> > 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).
> 
> two points:
> 
> 1) is it better to use `file $file | grep script` ? 
> Is "file" as portable as "head -1|cut -c1-2" will i18n break the grep?
> 
> 2) are we going about it from the wrong end: the above doesn't copy the
> file if it _is a script_. Shouldn't the test not copy the file if it
> _isn't an image_?

If you are going to use "file", it would be better to check that the
file is an image, rather than not a script. But using "file" is more
problematic, as it isn't part of the coreutils package, and its output
depends upon the "magic" file (which might conceivably be localised).

To identify scripts, "^#!" is reliable, as that's what the kernel
checks for when it's asked to execute a file.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list