From: G.raud Meyer Date: Sat, 24 Mar 2018 22:53:21 +0000 (+0100) Subject: rename: fix/reverse the semantics of --no-overwrite in --symlink mode X-Git-Tag: v2.32.1~55^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f3b185e5221fe2edbee9888fd781396385e0ec39;p=thirdparty%2Futil-linux.git rename: fix/reverse the semantics of --no-overwrite in --symlink mode 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. --- diff --git a/misc-utils/rename.1 b/misc-utils/rename.1 index aa0b01251d..d476d2435f 100644 --- a/misc-utils/rename.1 +++ b/misc-utils/rename.1 @@ -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. diff --git a/misc-utils/rename.c b/misc-utils/rename.c index cbda638e18..ba71174e66 100644 --- a/misc-utils/rename.c +++ b/misc-utils/rename.c @@ -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; }