From: Sami Kerola Date: Sat, 20 May 2017 09:41:23 +0000 (+0100) Subject: rename: notice when expression and replacement are the same string X-Git-Tag: v2.31-rc1~304 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f430c8a5ba842465ac72b3a101cb66ba3848959;p=thirdparty%2Futil-linux.git 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 --- diff --git a/misc-utils/rename.c b/misc-utils/rename.c index b06a2d969b..8230ac3da0 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);