From 9b5871888989b16f94cbba5dd304ac444def3afd Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sun, 17 Oct 1999 05:43:39 +0000 Subject: Some fixes and such --- coreutils/cp.c | 14 ++++++++------ coreutils/mv.c | 7 +++---- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'coreutils') diff --git a/coreutils/cp.c b/coreutils/cp.c index 6ca66e642..4016fc760 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -41,21 +41,24 @@ static int preserveFlag = FALSE; static const char *srcName; static const char *destName; static const char *skipName; +static int dirFlag = FALSE; -static int fileAction(const char *fileName) +static int fileAction(const char *fileName, struct stat* statbuf) { char newdestName[NAME_MAX]; strcpy(newdestName, destName); - strcat(newdestName, strstr(fileName, skipName)); + if (dirFlag==TRUE && newdestName[strlen(newdestName)-1]!= '/' ) { + strcat(newdestName, "/"); + if ( skipName != NULL) + strcat(newdestName, strstr(fileName, skipName)); + } return (copyFile(fileName, newdestName, preserveFlag, followLinks)); } extern int cp_main(int argc, char **argv) { - int dirFlag; - if (argc < 3) { fprintf(stderr, "Usage: %s", cp_usage); exit (FALSE); @@ -91,10 +94,9 @@ extern int cp_main(int argc, char **argv) destName = argv[argc - 1]; - dirFlag = isDirectory(destName); - if ((argc > 3) && !dirFlag) { + if ((argc > 3) && dirFlag==FALSE) { fprintf(stderr, "%s: not a directory\n", destName); exit (FALSE); } diff --git a/coreutils/mv.c b/coreutils/mv.c index df56206a3..10a082210 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c @@ -41,7 +41,7 @@ extern int mv_main (int argc, char **argv) if (argc < 3) { fprintf (stderr, "Usage: %s %s", *argv, mv_usage); - return (FALSE); + exit (FALSE); } lastArg = argv[argc - 1]; @@ -49,8 +49,7 @@ extern int mv_main (int argc, char **argv) if ((argc > 3) && !dirFlag) { fprintf (stderr, "%s: not a directory\n", lastArg); - - return (FALSE); + exit (FALSE); } while (argc-- > 2) { @@ -80,5 +79,5 @@ extern int mv_main (int argc, char **argv) if (unlink (srcName) < 0) perror (srcName); } - return (TRUE); + exit (TRUE); } -- cgit v1.2.3