Ticket #496 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

g.rename vect=Map1,map1 doesn't work

Reported by: hamish Owned by: grass-dev@…
Priority: major Milestone: 6.4.0
Component: Vector Version: 6.4.0 RCs
Keywords: g.rename Cc:
Platform: Linux CPU: x86-32

Description

Hi,

g.rename vect=Map1,map1

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

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

Change History

in reply to: ↑ description   Changed 6 years ago by glynn

Replying to hamish:

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

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

follow-up: ↓ 3   Changed 6 years ago 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

in reply to: ↑ 2 ; follow-up: ↓ 4   Changed 6 years ago by glynn

Replying to 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().

in reply to: ↑ 3   Changed 6 years ago by hamish

  • status changed from new to closed
  • resolution set to fixed

Replying to 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

Note: See TracTickets for help on using tickets.