diff options
-rw-r--r-- | Changelog | 7 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | coreutils/cp.c | 7 | ||||
-rw-r--r-- | coreutils/mv.c | 7 | ||||
-rw-r--r-- | cp.c | 7 | ||||
-rw-r--r-- | mv.c | 7 |
6 files changed, 32 insertions, 5 deletions
@@ -1,3 +1,10 @@ +0.41 + * Fixed a bug in both cp and mv preventing 'cp foo/README bar' + type commands (file in a directory to another directory) + from working. + + -Erik Andersen, + 0.40 * New Apps: sort, uniq. -beppu * New Apps: lsmod, rmmod -erik @@ -22,7 +22,7 @@ BUILDTIME=$(shell date "+%Y%m%d-%H%M") # Comment out the following to make a debuggable build # Leave this off for production use. -DODEBUG=false +DODEBUG=true # If you want a static binary, turn this on. I can't think # of many situations where anybody would ever want it static, # but... diff --git a/coreutils/cp.c b/coreutils/cp.c index 4af73c274..e96012d50 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -48,6 +48,7 @@ static int srcDirFlag = FALSE; static int fileAction(const char *fileName, struct stat* statbuf) { char newdestName[NAME_MAX]; + char* newsrcName = NULL; strcpy(newdestName, destName); if ( srcDirFlag == TRUE ) { @@ -62,7 +63,11 @@ static int fileAction(const char *fileName, struct stat* statbuf) if (newdestName[strlen(newdestName)-1] != '/' ) { strcat(newdestName, "/"); } - strcat(newdestName, srcName); + newsrcName = strrchr(srcName, '/'); + if (newsrcName && *newsrcName != '\0') + strcat(newdestName, newsrcName); + else + strcat(newdestName, srcName); } return (copyFile(fileName, newdestName, preserveFlag, followLinks)); diff --git a/coreutils/mv.c b/coreutils/mv.c index 92c40c9b7..467a360de 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c @@ -40,6 +40,7 @@ static int srcDirFlag = FALSE; static int fileAction(const char *fileName, struct stat* statbuf) { char newdestName[NAME_MAX]; + char* newsrcName = NULL; strcpy(newdestName, destName); if ( srcDirFlag == TRUE ) { @@ -50,7 +51,11 @@ static int fileAction(const char *fileName, struct stat* statbuf) if (newdestName[strlen(newdestName)-1] != '/' ) { strcat(newdestName, "/"); } - strcat(newdestName, srcName); + newsrcName = strrchr(srcName, '/'); + if (newsrcName && *newsrcName != '\0') + strcat(newdestName, newsrcName); + else + strcat(newdestName, srcName); } return (copyFile(fileName, newdestName, TRUE, TRUE)); @@ -48,6 +48,7 @@ static int srcDirFlag = FALSE; static int fileAction(const char *fileName, struct stat* statbuf) { char newdestName[NAME_MAX]; + char* newsrcName = NULL; strcpy(newdestName, destName); if ( srcDirFlag == TRUE ) { @@ -62,7 +63,11 @@ static int fileAction(const char *fileName, struct stat* statbuf) if (newdestName[strlen(newdestName)-1] != '/' ) { strcat(newdestName, "/"); } - strcat(newdestName, srcName); + newsrcName = strrchr(srcName, '/'); + if (newsrcName && *newsrcName != '\0') + strcat(newdestName, newsrcName); + else + strcat(newdestName, srcName); } return (copyFile(fileName, newdestName, preserveFlag, followLinks)); @@ -40,6 +40,7 @@ static int srcDirFlag = FALSE; static int fileAction(const char *fileName, struct stat* statbuf) { char newdestName[NAME_MAX]; + char* newsrcName = NULL; strcpy(newdestName, destName); if ( srcDirFlag == TRUE ) { @@ -50,7 +51,11 @@ static int fileAction(const char *fileName, struct stat* statbuf) if (newdestName[strlen(newdestName)-1] != '/' ) { strcat(newdestName, "/"); } - strcat(newdestName, srcName); + newsrcName = strrchr(srcName, '/'); + if (newsrcName && *newsrcName != '\0') + strcat(newdestName, newsrcName); + else + strcat(newdestName, srcName); } return (copyFile(fileName, newdestName, TRUE, TRUE)); |