[PATCH 7/7] cp command: handle directories as last argument

Sascha Hauer s.hauer at pengutronix.de
Mon Apr 11 10:18:41 EDT 2011


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/cp.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/commands/cp.c b/commands/cp.c
index ae8719b..3428105 100644
--- a/commands/cp.c
+++ b/commands/cp.c
@@ -31,6 +31,7 @@
 #include <libbb.h>
 #include <fs.h>
 #include <malloc.h>
+#include <libgen.h>
 
 /**
  * @param[in] cmdtp FIXME
@@ -60,7 +61,7 @@ static int do_cp(struct command *cmdtp, int argc, char *argv[])
 	for (i = 1; i < argc - 1; i++) {
 		if (last_is_dir) {
 			char *dst;
-			dst = concat_path_file(argv[argc - 1], argv[i]);
+			dst = concat_path_file(argv[argc - 1], basename(argv[i]));
 			ret = copy_file(argv[i], dst);
 			if (ret)
 				goto out;
-- 
1.7.2.3




More information about the barebox mailing list