diff options
author | Sami Kerola | 2017-05-20 11:41:23 +0200 |
---|---|---|
committer | Karel Zak | 2017-06-14 12:17:27 +0200 |
commit | 9f430c8a5ba842465ac72b3a101cb66ba3848959 (patch) | |
tree | f17eb31fc7825fe423899a85618e32724a20ecac | |
parent | Merge branch 'master' of ra.kernel.org:/pub/scm/utils/util-linux/util-linux (diff) | |
download | kernel-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.c | 3 |
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); |