From fd924d90c1fdac2f9cd33e065c7aa540d0f65167 Mon Sep 17 00:00:00 2001 From: andersen Date: Thu, 14 Oct 1999 22:16:57 +0000 Subject: Fixed cp -[aR] and some other stuf. git-svn-id: svn://busybox.net/trunk/busybox@27 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- cp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cp.c') diff --git a/cp.c b/cp.c index 94b4ab024..6ca66e642 100644 --- a/cp.c +++ b/cp.c @@ -40,13 +40,14 @@ static int followLinks = FALSE; static int preserveFlag = FALSE; static const char *srcName; static const char *destName; +static const char *skipName; static int fileAction(const char *fileName) { char newdestName[NAME_MAX]; strcpy(newdestName, destName); - strcat(newdestName, fileName+(strlen(srcName))); + strcat(newdestName, strstr(fileName, skipName)); return (copyFile(fileName, newdestName, preserveFlag, followLinks)); } @@ -98,10 +99,13 @@ extern int cp_main(int argc, char **argv) exit (FALSE); } - while (argc-- >= 2) { + while (argc-- > 1) { srcName = *(argv++); - exit( recursiveAction(srcName, recursiveFlag, followLinks, - fileAction, fileAction)); + skipName = strrchr(srcName, '/'); + if (skipName) skipName++; + if (recursiveAction(srcName, recursiveFlag, followLinks, + fileAction, fileAction) == FALSE) + exit( FALSE); } exit( TRUE); } -- cgit v1.2.3-55-g6feb