Opened 15 years ago

Last modified 8 years ago

#767 new enhancement

g.copy only issues warning when destination exists

Reported by: ferrouswheel Owned by: grass-dev@…
Priority: major Milestone: 6.4.6
Component: Default Version: svn-develbranch6
Keywords: g.copy, g.rename Cc:
CPU: Unspecified Platform: Unspecified

Description

g.copy rast=src,dst

When dst already exists, g.copy only issues a "WARNING" message and returns 0 without copying src to dst. This behaviour is erroneous, is should give an "ERROR" message and return non-zero (unless an overwrite flag is enabled).

Change History (8)

comment:1 by neteler, 13 years ago

comment:2 by neteler, 13 years ago

The same applies to g.rename.

comment:3 by hamish, 13 years ago

Keywords: g.copy g.rename added
Milestone: 6.4.06.4.2
Priority: normalmajor

in reply to:  1 ; comment:4 by hamish, 13 years ago

Replying to neteler:

What is the reason that there is only G_warning()?

I don't know, but it seems to have been like that since forever.

http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_5_5/src/general/manage/cmd/copy.c?rev=3

G_fatal_error() seems like the right thing to do AFAICT.

Hamish

in reply to:  4 comment:5 by glynn, 13 years ago

Replying to hamish:

G_fatal_error() seems like the right thing to do AFAICT.

One issue is that, with multiple map names, it will abort at the first case where the destination exists. Maps prior to that will be copied, maps after that won't be.

The existing behaviour is more consistent: maps which can be copied are copied; errors only affect the specific copy operation to which they apply.

The existing behaviour differs from modules which use ->gisprompt="new,..." (which g.copy can't do because of its interface; see #178). With those, the parser checks either that --overwrite was used or that none of the "new" maps exist. If the check fails, it fails in G_parser(), before the module starts to do any work.

If we want the "usual" behaviour from g.copy and g.rename, they will need to loop over the inputs twice: the first time to check for errors, the second time to actually perform the copy/rename operations.

comment:6 by neteler, 12 years ago

Milestone: 6.4.26.4.4
Type: defectenhancement

comment:7 by hamish, 11 years ago

see also #1658

comment:8 by neteler, 8 years ago

Milestone: 6.4.46.4.6
Note: See TracTickets for help on using tickets.