[PATCH 2/3] cp: Use posix_basename() on source argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux