aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-01-08 21:16:29 +0000
committerErik Andersen <andersen@codepoet.org>2000-01-08 21:16:29 +0000
commit1dbc17f630fa92e2ee3ac0f1e2bccb6adf6f9032 (patch)
treef86b3ad6f14114543da369473d0f4b20a4fdc436
parent5338ce19c873e7fc2a312eb0fd6443514b5cdb05 (diff)
downloadbusybox-w32-1dbc17f630fa92e2ee3ac0f1e2bccb6adf6f9032.tar.gz
busybox-w32-1dbc17f630fa92e2ee3ac0f1e2bccb6adf6f9032.tar.bz2
busybox-w32-1dbc17f630fa92e2ee3ac0f1e2bccb6adf6f9032.zip
Fix cp and mv so 'cp foo/README bar' where foo and bar are directories,
and README is a file. -Erik
-rw-r--r--Changelog7
-rw-r--r--Makefile2
-rw-r--r--coreutils/cp.c7
-rw-r--r--coreutils/mv.c7
-rw-r--r--cp.c7
-rw-r--r--mv.c7
6 files changed, 32 insertions, 5 deletions
diff --git a/Changelog b/Changelog
index 5c06ec1b1..52b34b663 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,10 @@
10.41
2 * Fixed a bug in both cp and mv preventing 'cp foo/README bar'
3 type commands (file in a directory to another directory)
4 from working.
5
6 -Erik Andersen,
7
10.40 80.40
2 * New Apps: sort, uniq. -beppu 9 * New Apps: sort, uniq. -beppu
3 * New Apps: lsmod, rmmod -erik 10 * New Apps: lsmod, rmmod -erik
diff --git a/Makefile b/Makefile
index f1f25cd43..9a59c1fff 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ BUILDTIME=$(shell date "+%Y%m%d-%H%M")
22 22
23# Comment out the following to make a debuggable build 23# Comment out the following to make a debuggable build
24# Leave this off for production use. 24# Leave this off for production use.
25DODEBUG=false 25DODEBUG=true
26# If you want a static binary, turn this on. I can't think 26# If you want a static binary, turn this on. I can't think
27# of many situations where anybody would ever want it static, 27# of many situations where anybody would ever want it static,
28# but... 28# 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;
48static int fileAction(const char *fileName, struct stat* statbuf) 48static int fileAction(const char *fileName, struct stat* statbuf)
49{ 49{
50 char newdestName[NAME_MAX]; 50 char newdestName[NAME_MAX];
51 char* newsrcName = NULL;
51 52
52 strcpy(newdestName, destName); 53 strcpy(newdestName, destName);
53 if ( srcDirFlag == TRUE ) { 54 if ( srcDirFlag == TRUE ) {
@@ -62,7 +63,11 @@ static int fileAction(const char *fileName, struct stat* statbuf)
62 if (newdestName[strlen(newdestName)-1] != '/' ) { 63 if (newdestName[strlen(newdestName)-1] != '/' ) {
63 strcat(newdestName, "/"); 64 strcat(newdestName, "/");
64 } 65 }
65 strcat(newdestName, srcName); 66 newsrcName = strrchr(srcName, '/');
67 if (newsrcName && *newsrcName != '\0')
68 strcat(newdestName, newsrcName);
69 else
70 strcat(newdestName, srcName);
66 } 71 }
67 72
68 return (copyFile(fileName, newdestName, preserveFlag, followLinks)); 73 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;
40static int fileAction(const char *fileName, struct stat* statbuf) 40static int fileAction(const char *fileName, struct stat* statbuf)
41{ 41{
42 char newdestName[NAME_MAX]; 42 char newdestName[NAME_MAX];
43 char* newsrcName = NULL;
43 44
44 strcpy(newdestName, destName); 45 strcpy(newdestName, destName);
45 if ( srcDirFlag == TRUE ) { 46 if ( srcDirFlag == TRUE ) {
@@ -50,7 +51,11 @@ static int fileAction(const char *fileName, struct stat* statbuf)
50 if (newdestName[strlen(newdestName)-1] != '/' ) { 51 if (newdestName[strlen(newdestName)-1] != '/' ) {
51 strcat(newdestName, "/"); 52 strcat(newdestName, "/");
52 } 53 }
53 strcat(newdestName, srcName); 54 newsrcName = strrchr(srcName, '/');
55 if (newsrcName && *newsrcName != '\0')
56 strcat(newdestName, newsrcName);
57 else
58 strcat(newdestName, srcName);
54 } 59 }
55 60
56 return (copyFile(fileName, newdestName, TRUE, TRUE)); 61 return (copyFile(fileName, newdestName, TRUE, TRUE));
diff --git a/cp.c b/cp.c
index 4af73c274..e96012d50 100644
--- a/cp.c
+++ b/cp.c
@@ -48,6 +48,7 @@ static int srcDirFlag = FALSE;
48static int fileAction(const char *fileName, struct stat* statbuf) 48static int fileAction(const char *fileName, struct stat* statbuf)
49{ 49{
50 char newdestName[NAME_MAX]; 50 char newdestName[NAME_MAX];
51 char* newsrcName = NULL;
51 52
52 strcpy(newdestName, destName); 53 strcpy(newdestName, destName);
53 if ( srcDirFlag == TRUE ) { 54 if ( srcDirFlag == TRUE ) {
@@ -62,7 +63,11 @@ static int fileAction(const char *fileName, struct stat* statbuf)
62 if (newdestName[strlen(newdestName)-1] != '/' ) { 63 if (newdestName[strlen(newdestName)-1] != '/' ) {
63 strcat(newdestName, "/"); 64 strcat(newdestName, "/");
64 } 65 }
65 strcat(newdestName, srcName); 66 newsrcName = strrchr(srcName, '/');
67 if (newsrcName && *newsrcName != '\0')
68 strcat(newdestName, newsrcName);
69 else
70 strcat(newdestName, srcName);
66 } 71 }
67 72
68 return (copyFile(fileName, newdestName, preserveFlag, followLinks)); 73 return (copyFile(fileName, newdestName, preserveFlag, followLinks));
diff --git a/mv.c b/mv.c
index 92c40c9b7..467a360de 100644
--- a/mv.c
+++ b/mv.c
@@ -40,6 +40,7 @@ static int srcDirFlag = FALSE;
40static int fileAction(const char *fileName, struct stat* statbuf) 40static int fileAction(const char *fileName, struct stat* statbuf)
41{ 41{
42 char newdestName[NAME_MAX]; 42 char newdestName[NAME_MAX];
43 char* newsrcName = NULL;
43 44
44 strcpy(newdestName, destName); 45 strcpy(newdestName, destName);
45 if ( srcDirFlag == TRUE ) { 46 if ( srcDirFlag == TRUE ) {
@@ -50,7 +51,11 @@ static int fileAction(const char *fileName, struct stat* statbuf)
50 if (newdestName[strlen(newdestName)-1] != '/' ) { 51 if (newdestName[strlen(newdestName)-1] != '/' ) {
51 strcat(newdestName, "/"); 52 strcat(newdestName, "/");
52 } 53 }
53 strcat(newdestName, srcName); 54 newsrcName = strrchr(srcName, '/');
55 if (newsrcName && *newsrcName != '\0')
56 strcat(newdestName, newsrcName);
57 else
58 strcat(newdestName, srcName);
54 } 59 }
55 60
56 return (copyFile(fileName, newdestName, TRUE, TRUE)); 61 return (copyFile(fileName, newdestName, TRUE, TRUE));