aboutsummaryrefslogtreecommitdiff
path: root/coreutils/mv.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-21 23:40:20 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-21 23:40:20 +0000
commitf24e1f40e032e99cf57a05730e7632b825d3016d (patch)
treea6d0fa74d59e67d1570c54157f5ebcc47b4522d0 /coreutils/mv.c
parent8d73c35916cbae67f5d0269b128de40f9992ddc6 (diff)
downloadbusybox-w32-f24e1f40e032e99cf57a05730e7632b825d3016d.tar.gz
busybox-w32-f24e1f40e032e99cf57a05730e7632b825d3016d.tar.bz2
busybox-w32-f24e1f40e032e99cf57a05730e7632b825d3016d.zip
cp: add support for -s, -l. Fix free(nonmalloc) bug.
Add doc on POSIX's rules on -i and -f (insane!). ln: make "ln dangling_symlink new_link" work.
Diffstat (limited to 'coreutils/mv.c')
-rw-r--r--coreutils/mv.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 770b42417..52ddd9fb7 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -57,7 +57,8 @@ int mv_main(int argc, char **argv)
57 argv += optind; 57 argv += optind;
58 58
59 if (optind + 2 == argc) { 59 if (optind + 2 == argc) {
60 if ((dest_exists = cp_mv_stat(last, &dest_stat)) < 0) { 60 dest_exists = cp_mv_stat(last, &dest_stat);
61 if (dest_exists < 0) {
61 return 1; 62 return 1;
62 } 63 }
63 64
@@ -69,8 +70,8 @@ int mv_main(int argc, char **argv)
69 70
70 do { 71 do {
71 dest = concat_path_file(last, bb_get_last_path_component(*argv)); 72 dest = concat_path_file(last, bb_get_last_path_component(*argv));
72 73 dest_exists = cp_mv_stat(dest, &dest_stat);
73 if ((dest_exists = cp_mv_stat(dest, &dest_stat)) < 0) { 74 if (dest_exists < 0) {
74 goto RET_1; 75 goto RET_1;
75 } 76 }
76 77
@@ -79,7 +80,7 @@ DO_MOVE:
79 if (dest_exists && !(flags & OPT_FILEUTILS_FORCE) && 80 if (dest_exists && !(flags & OPT_FILEUTILS_FORCE) &&
80 ((access(dest, W_OK) < 0 && isatty(0)) || 81 ((access(dest, W_OK) < 0 && isatty(0)) ||
81 (flags & OPT_FILEUTILS_INTERACTIVE))) { 82 (flags & OPT_FILEUTILS_INTERACTIVE))) {
82 if (fprintf(stderr, "mv: overwrite `%s'? ", dest) < 0) { 83 if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) {
83 goto RET_1; /* Ouch! fprintf failed! */ 84 goto RET_1; /* Ouch! fprintf failed! */
84 } 85 }
85 if (!bb_ask_confirmation()) { 86 if (!bb_ask_confirmation()) {
@@ -92,7 +93,7 @@ DO_MOVE:
92 93
93 if (errno != EXDEV || 94 if (errno != EXDEV ||
94 (source_exists = cp_mv_stat(*argv, &source_stat)) < 1) { 95 (source_exists = cp_mv_stat(*argv, &source_stat)) < 1) {
95 bb_perror_msg("unable to rename `%s'", *argv); 96 bb_perror_msg("cannot rename '%s'", *argv);
96 } else { 97 } else {
97 if (dest_exists) { 98 if (dest_exists) {
98 if (dest_exists == 3) { 99 if (dest_exists == 3) {
@@ -107,7 +108,7 @@ DO_MOVE:
107 } 108 }
108 } 109 }
109 if (unlink(dest) < 0) { 110 if (unlink(dest) < 0) {
110 bb_perror_msg("cannot remove `%s'", dest); 111 bb_perror_msg("cannot remove '%s'", dest);
111 goto RET_1; 112 goto RET_1;
112 } 113 }
113 } 114 }