summaryrefslogtreecommitdiffstats
path: root/misc-utils/rename.c
diff options
context:
space:
mode:
authorAndreas Henriksson2015-06-22 19:26:22 +0200
committerKarel Zak2015-06-25 12:01:36 +0200
commit9fa6088aa9b279f3f4de3df0eb8eb9cbcda7f09e (patch)
tree88e5d9e1040f63520ec58ce241c8b79413799997 /misc-utils/rename.c
parenttests: add fullpath tests to rename/subdir (diff)
downloadkernel-qcow2-util-linux-9fa6088aa9b279f3f4de3df0eb8eb9cbcda7f09e.tar.gz
kernel-qcow2-util-linux-9fa6088aa9b279f3f4de3df0eb8eb9cbcda7f09e.tar.xz
kernel-qcow2-util-linux-9fa6088aa9b279f3f4de3df0eb8eb9cbcda7f09e.zip
rename: allow full-path renames
The command "touch b0;rename.ul -v ./b0 ./b1 ./b0" used to work before "allow renaming in subdirectories" change. (regression in commit bd9ced628bb86) Addresses: https://bugs.debian.org/789240 Reported-by: gregrwm <bug-grub@whitleymott.net> Reviewed-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Diffstat (limited to 'misc-utils/rename.c')
-rw-r--r--misc-utils/rename.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index 7ac068d63..c8a4f8ca5 100644
--- a/misc-utils/rename.c
+++ b/misc-utils/rename.c
@@ -92,10 +92,11 @@ static int do_symlink(char *from, char *to, char *s, int verbose)
static int do_file(char *from, char *to, char *s, int verbose)
{
- char *newname = NULL, *file;
+ char *newname = NULL, *file=NULL;
int ret = 1;
- file = strrchr(s, '/');
+ if (strchr(from, '/') == NULL && strchr(to, '/') == NULL)
+ file = strrchr(s, '/');
if (file == NULL)
file = s;
if (string_replace(from, to, file, s, &newname))