]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rename: fix/reverse the semantics of --no-overwrite in --symlink mode
authorG.raud Meyer <graud@gmx.com>
Sat, 24 Mar 2018 22:53:21 +0000 (23:53 +0100)
committerG.raud Meyer <graud@gmx.com>
Tue, 27 Mar 2018 16:50:24 +0000 (18:50 +0200)
The previous behaviour was to overwrite a symlink only when the new
destination did not exist, i.e. to avoid creating a symlink to an
existing file!  It had not been documented and it seems
counter-intuitive to me.  So the new behavior protects symlinks pointing
to existing targets from being changed.

Also update manpage to document this mode.

misc-utils/rename.1
misc-utils/rename.c

index aa0b01251da6e5569edb106e96d6584e9fc3e8b8..d476d2435fc7988d95b6a52f255a3fccb4562bcc 100644 (file)
@@ -26,7 +26,9 @@ Show which files were renamed, if any.
 Do not make any changes.
 .TP
 .BR \-o , " \-\-no\-overwrite"
-Do not overwrite existing files.
+Do not overwrite existing files.  When
+.BR \-\-symlink
+is active, do not overwrite symlinks pointing to existing targets.
 .TP
 .BR \-V , " \-\-version"
 Display version information and exit.
index cbda638e18faa3a999c0dd645b564ecfa5fc9c86..ba71174e66f5cdc1a0612d45f80803d313f40537 100644 (file)
@@ -77,9 +77,9 @@ static int do_symlink(char *from, char *to, char *s, int verbose, int noact, int
        if (string_replace(from, to, target, target, &newname))
                ret = 0;
 
-       if (ret == 1 && nooverwrite && lstat(newname, &sb) == 0) {
+       if (ret == 1 && nooverwrite && lstat(target, &sb) == 0) {
                if (verbose)
-                       printf(_("Skipping existing link: `%s'\n"), newname);
+                       printf(_("Skipping existing link: `%s'\n"), target);
 
                ret = 0;
        }