[GRASS-dev] [GRASS GIS] #1886: Error in input may result in r.proj overwriting exising layers

#1886: Error in input may result in r.proj overwriting exising layers
------------------------+---------------------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: | Platform: Unspecified
      Cpu: x86-64 |
------------------------+---------------------------------------------------
Suppose I want to project the layer bio_2 to the current mapset from the
location/mapset latlon/climate. I would use:

{{{
r.proj input=bio_2 location=latlon mapset=climate
dbase=/home/paulo/Data/GRASSdb
}}}

The following (erroneous?) statement also works:

{{{
r.proj input=bio_2@climate location=latlon mapset=climate
dbase=/home/paulo/Data/GRASSdb
}}}

There is one important difference. If the layer bio_2 already exist in the
current mapset, the first statement will give an error message stating
that the layer already exists. Using the second statement, the existing
layer is overwritten without any further warning.

Yes, the user is suppose to only give the name of the layer (without the
mapset name). But if somebody does make such a mistake (I evidently did),
layers might get overwritten unintentionally.

It seems the function takes the whole name, including the '@mapset' when
checking if a layer already exists, but then continues to only use the
part before '@mapset' when creating the layer.

A more consistent behavior, i.m.h.o., would be if in both steps, the
'@mapset' is ignored (which would eliminate the possibility of unwittingly
overwriting layers). Alternatively, it should be impossible to use an
input name which includes a '@mapset' part (doing so should give an error
message).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1886&gt;
GRASS GIS <http://grass.osgeo.org>

#1886: Error in input may result in r.proj overwriting exising layers
------------------------+---------------------------------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Raster | Version: svn-trunk
Keywords: | Platform: Unspecified
      Cpu: x86-64 |
------------------------+---------------------------------------------------

Comment(by glynn):

Replying to [ticket:1886 pvanbosgeo]:

> A more consistent behavior, i.m.h.o., would be if in both steps, the
'@mapset' is ignored (which would eliminate the possibility of unwittingly
overwriting layers). Alternatively, it should be impossible to use an
input name which includes a '@mapset' part (doing so should give an error
message).

The most consistent behaviour would be to make the output= parameter non-
optional. The parser will automatically generate an error if an "output"
map exists and overwrite wasn't enabled.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1886#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>