mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/3] cp: Use posix_basename() on source argument
Date: Wed, 19 Apr 2017 10:06:11 +0200	[thread overview]
Message-ID: <20170419080612.19797-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170419080612.19797-1-s.hauer@pengutronix.de>

The GNU basename version does not work with strings which have a
trailing slash. Use posix_basename instead. With this cp -r
can properly work on source arguments which have a trailing slash,
i.e. "cp /dir1/ dst".

Reported-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/cp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/commands/cp.c b/commands/cp.c
index 4f1c068dd6..54934dd64f 100644
--- a/commands/cp.c
+++ b/commands/cp.c
@@ -76,7 +76,8 @@ static int do_cp(int argc, char *argv[])
 
 	for (i = optind; i < argc - 1; i++) {
 		char *dst;
-		dst = concat_path_file(argv[argc - 1], basename(argv[i]));
+
+		dst = concat_path_file(argv[argc - 1], posix_basename(argv[i]));
 
 		if (recursive)
 			ret = copy_recursive(argv[i], dst);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2017-04-19  8:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19  8:06 [PATCH 1/3] libgen: implement posix_basename Sascha Hauer
2017-04-19  8:06 ` Sascha Hauer [this message]
2017-04-19  8:06 ` [PATCH 3/3] commands: basename: Use posix_basename() Sascha Hauer

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=20170419080612.19797-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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