Util-Linux package development
 help / color / mirror / Atom feed
From: Andreas Henriksson <andreas@fatal.se>
To: util-linux@vger.kernel.org
Cc: Sami Kerola <kerolasa@iki.fi>, Andreas Henriksson <andreas@fatal.se>
Subject: [PATCH v2] rename: allow full-path renames
Date: Mon, 22 Jun 2015 19:26:22 +0200	[thread overview]
Message-ID: <1434993982-20741-1-git-send-email-andreas@fatal.se> (raw)
In-Reply-To: <CAG27Bk353ASGr0hyDe4oQvAZ3Swf_HbgonENtkOPFE_qcjE7MQ@mail.gmail.com>

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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

v2: fixed my email address, add reviewed by.

diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index 7ac068d..c8a4f8c 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))
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in

  parent reply	other threads:[~2015-06-22 17:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-22 16:23 [PATCH] rename: allow full-path renames Andreas Henriksson
2015-06-22 17:08 ` Sami Kerola
2015-06-22 17:22   ` [PATCH] tests: add fullpath tests to rename/subdir Andreas Henriksson
2015-06-25 10:03     ` Karel Zak
2015-06-22 17:26   ` Andreas Henriksson [this message]
2015-06-25 10:04     ` [PATCH v2] rename: allow full-path renames Karel Zak
2015-06-22 17:29   ` [PATCH] " Andreas Henriksson
2015-06-25 10:06   ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434993982-20741-1-git-send-email-andreas@fatal.se \
    --to=andreas@fatal.se \
    --cc=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox