[GRASS-dev] [GRASS GIS] #496: g.rename vect=Map1,map1 doesn't work

#496: g.rename vect=Map1,map1 doesn't work
----------------------+-----------------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Keywords: g.rename | Platform: Linux
      Cpu: x86-32 |
----------------------+-----------------------------------------------------
Hi,

{{{
g.rename vect=Map1,map1
}}}

is a no-op. The map is not renamed. :frowning:

in the above example there was no attached DB. not sure what happens if
there is (ie partial rename->breakage?).

perhaps due to some MS-Windows accommodation which has gone too far?
I've been using case sensitive names for years to indicate type of map /
protection from typos. Losing the ability to manage them properly or
having all treated as lowercase() would stink.

?,
Hamish

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

#496: g.rename vect=Map1,map1 doesn't work
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: g.rename
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by glynn):

Replying to [ticket:496 hamish]:

> {{{
> g.rename vect=Map1,map1
> }}}
>
> is a no-op. The map is not renamed. :frowning:

This is intentional.

> perhaps due to some MS-Windows accommodation which has gone too far?

It's more accurate to say "non-Unix filesystem accommodation"; you can use
[V]FAT, NTFS, SMB/CIFS, etc filesystems from Unix.

The problem is that if we used a case-sensitive check and the filesystem
happens to be case-insensitive, the above command would simply delete the
map. This was considered to be a bad thing. Sufficiently bad that, until
someone can come up with a 100%-reliable mechanism for determining whether
or not the filesystem is case-sensitive (I'm not holding my breath), we
always assume that the filesystem might be case-insensitive.

If you want to change the case, you will have to do it in two steps, e.g.:

{{{
g.rename vect=Map1,map1.tmp
g.rename vect=map1.tmp,map1
}}}

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

#496: g.rename vect=Map1,map1 doesn't work
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: g.rename
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by hamish):

mmph.

how about a warning then:

{{{
Index: general/manage/cmd/rename.c

--- general/manage/cmd/rename.c (revision 35912)
+++ general/manage/cmd/rename.c (working copy)
@@ -84,8 +84,8 @@
                 G_warning(_("<%s> is an illegal file name"), new);
                 continue;
             }
- if (strcmp(old, new) == 0) {
- G_warning(_("%s=%s,%s: files are the same, no rename
required"),
+ if (strcasecmp(old, new) == 0) {
+ G_warning(_("%s=%s,%s: files could be the same, no rename
possible"),
                           parm[n]->key, old, new);
                 continue;
             }
}}}

(afaict this only affects g.rename)

Hamish

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

#496: g.rename vect=Map1,map1 doesn't work
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: | Keywords: g.rename
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Comment (by glynn):

Replying to [comment:2 hamish]:
> mmph.
>
> how about a warning then:
>
{{{
- if (strcmp(old, new) == 0) {
+ if (strcasecmp(old, new) == 0) {
}}}

Done in r35919 (7.0). Except that it needs to be G_strcasemp(), as Windows
doesn't have strcasecmp().

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

#496: g.rename vect=Map1,map1 doesn't work
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: fixed | Keywords: g.rename
  Platform: Linux | Cpu: x86-32
---------------------+------------------------------------------------------
Changes (by hamish):

  * status: new => closed
  * resolution: => fixed

Comment:

Replying to [comment:3 glynn]:
> Done in r35919 (7.0). Except that it needs to be G_strcasemp(),
> as Windows doesn't have strcasecmp().

ok; backported to develbranch_6 and releasebranch_6_4, and updated the
warning message as well.

closing bug.

Hamish

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