summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Kerola2017-05-20 11:41:23 +0200
committerKarel Zak2017-06-14 12:17:27 +0200
commit9f430c8a5ba842465ac72b3a101cb66ba3848959 (patch)
treef17eb31fc7825fe423899a85618e32724a20ecac
parentMerge branch 'master' of ra.kernel.org:/pub/scm/utils/util-linux/util-linux (diff)
downloadkernel-qcow2-util-linux-9f430c8a5ba842465ac72b3a101cb66ba3848959.tar.gz
kernel-qcow2-util-linux-9f430c8a5ba842465ac72b3a101cb66ba3848959.tar.xz
kernel-qcow2-util-linux-9f430c8a5ba842465ac72b3a101cb66ba3848959.zip
rename: notice when expression and replacement are the same string
The rename(1) can exit early when replace expression and replacement are identical string. It is also appropriate to change return value in this case to 'nothing was renamed'. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
-rw-r--r--misc-utils/rename.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index b06a2d969..8230ac3da 100644
--- a/misc-utils/rename.c
+++ b/misc-utils/rename.c
@@ -204,6 +204,9 @@ int main(int argc, char **argv)
from = argv[0];
to = argv[1];
+ if (!strcmp(from, to))
+ return RENAME_EXIT_NOTHING;
+
for (i = 2; i < argc; i++)
ret |= do_rename(from, to, argv[i], verbose, noact, nooverwrite);