]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rename: allow full-path renames
authorAndreas Henriksson <andreas@fatal.se>
Mon, 22 Jun 2015 17:26:22 +0000 (19:26 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 25 Jun 2015 10:01:36 +0000 (12:01 +0200)
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>
misc-utils/rename.c

index 7ac068d639eee19811a0dbe32075d86586b111f5..c8a4f8ca579def4e00ddafc746f8ee0ccee1e04d 100644 (file)
@@ -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))