[GRASS5] Re: [bug #1231] (grass) g.copy bug: cell_misc ignored

On Wed, Aug 14, 2002 at 02:03:15PM +0200, Glynn Clements via RT wrote:

Request Tracker wrote:

> this bug's URL: http://intevation.de/rt/webrt?serial_num=1231
> -------------------------------------------------------------------------
>
> Hi,
>
> it seems that g.copy doesn't completely cop a map.
> At least the range file in cell_misc/ is ignored:
>
> E.g. current mapset 'modis', I am copying from 'PERMANENT' into
> 'modis':
>
> GRASS:~ > l ~/grassdata/pat/PERMANENT/cell_misc/geologia/
> total 4
> -r--r--r-- 1 merler ssi 10 Jul 20 1998 range
>
> GRASS:~ > g.copy geologia,test
> COPY [geologia@PERMANENT] to [test]
> raster
> header
> category
> color
> history
> misc
> fcell MISSING
> g3dcell MISSING
>
> GRASS:~ >l ~/grassdata/pat/PERMANENT/cell_misc/test
> ls: /ssi0/ssi/neteler/grassdata/pat/PERMANENT/cell_misc/test: No such file or
> directory

Er, shouldn't this be "modis" instead of "PERMANENT"?

Er, yes. Sorry, but....

AFAICT, g.copy *does* copy the cell_misc/<map> directory (assuming
that it's in etc/element_list).

You are right. The problem is still there, but different:

GRASS:~ > l /ssi0/ssi/neteler/grassdata/pat/neteler/cell_misc/test
total 4
-r--r--r-- 1 neteler ssi 10 Aug 14 14:25 range
^^^

GRASS:~ > r.support -r test
   Updating the stats for [test]
WARNING: can't write range file for [test in neteler]
   Updating the number of categories for [test]

The permissions should be
-rw-r--r--

right? That's the real problem where I was struggling.

> I feel that this should be fixed for 5.0.0 since the cell_misc
> may also contain histogram, reclassed_to and null.

Note that g.copy explicitly removes the reclassed_to file. This is
correct; however:

1. The code is part of cmd/copy.c, whereas the code to remove the
colr2 file is in lib/do_copy.c.

2. It uses sprintf/system ("rm -f ..."), rather than G_remove().

Brrr...

Markus

Markus Neteler wrote:

> > GRASS:~ >l ~/grassdata/pat/PERMANENT/cell_misc/test
> > ls: /ssi0/ssi/neteler/grassdata/pat/PERMANENT/cell_misc/test: No such file or
> > directory
>
> Er, shouldn't this be "modis" instead of "PERMANENT"?

Er, yes. Sorry, but....

> AFAICT, g.copy *does* copy the cell_misc/<map> directory (assuming
> that it's in etc/element_list).

You are right. The problem is still there, but different:

GRASS:~ > l /ssi0/ssi/neteler/grassdata/pat/neteler/cell_misc/test
total 4
-r--r--r-- 1 neteler ssi 10 Aug 14 14:25 range
^^^

GRASS:~ > r.support -r test
   Updating the stats for [test]
WARNING: can't write range file for [test in neteler]
   Updating the number of categories for [test]

The permissions should be
-rw-r--r--

right? That's the real problem where I was struggling.

I suspect that adding:

    chmod u+rw $b

after the line:

    cp $a $b

in src/general/manage/lib/copy.sh should solve the immediate problem.

However, this wouldn't be specific to the cell_misc files. AFAICT, all
files retain their permissions when copied. The obvious question is:
why was the original range file read-only?

Also, that script (in fact, almost *every* script) should really have
double quotes around all of the variable expansions, i.e.

    cp "$a" "$b"

This particular issue is likely to be the source of around half of the
bugs relating to spaces in pathnames. The other half are due to the
use of sprintf/system.

In the longer term, src/general/manage should be completely
re-written. Much of the code there is suspect, even by GRASS'
standards.

--
Glynn Clements <glynn.clements@virgin.net>