aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cp.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 5b34c27e7..a76af7b7c 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -47,6 +47,7 @@
47//usage: "\n -f Overwrite" 47//usage: "\n -f Overwrite"
48//usage: "\n -i Prompt before overwrite" 48//usage: "\n -i Prompt before overwrite"
49//usage: "\n -l,-s Create (sym)links" 49//usage: "\n -l,-s Create (sym)links"
50//usage: "\n -T Treat DEST as a normal file"
50//usage: "\n -u Copy only newer files" 51//usage: "\n -u Copy only newer files"
51 52
52#include "libbb.h" 53#include "libbb.h"
@@ -92,6 +93,7 @@ int cp_main(int argc, char **argv)
92 "no-dereference\0" No_argument "P" 93 "no-dereference\0" No_argument "P"
93 "recursive\0" No_argument "R" 94 "recursive\0" No_argument "R"
94 "symbolic-link\0" No_argument "s" 95 "symbolic-link\0" No_argument "s"
96 "no-target-directory\0" No_argument "T"
95 "verbose\0" No_argument "v" 97 "verbose\0" No_argument "v"
96 "update\0" No_argument "u" 98 "update\0" No_argument "u"
97 "remove-destination\0" No_argument "\xff" 99 "remove-destination\0" No_argument "\xff"
@@ -121,6 +123,8 @@ int cp_main(int argc, char **argv)
121 * remove each existing destination file before attempting to open 123 * remove each existing destination file before attempting to open
122 * --parents 124 * --parents
123 * use full source file name under DIRECTORY 125 * use full source file name under DIRECTORY
126 * -T, --no-target-directory
127 * treat DEST as a normal file
124 * NOT SUPPORTED IN BBOX: 128 * NOT SUPPORTED IN BBOX:
125 * --backup[=CONTROL] 129 * --backup[=CONTROL]
126 * make a backup of each existing destination file 130 * make a backup of each existing destination file
@@ -139,8 +143,6 @@ int cp_main(int argc, char **argv)
139 * override the usual backup suffix 143 * override the usual backup suffix
140 * -t, --target-directory=DIRECTORY 144 * -t, --target-directory=DIRECTORY
141 * copy all SOURCE arguments into DIRECTORY 145 * copy all SOURCE arguments into DIRECTORY
142 * -T, --no-target-directory
143 * treat DEST as a normal file
144 * -x, --one-file-system 146 * -x, --one-file-system
145 * stay on this file system 147 * stay on this file system
146 * -Z, --context=CONTEXT 148 * -Z, --context=CONTEXT
@@ -175,6 +177,12 @@ int cp_main(int argc, char **argv)
175 if (d_flags < 0) 177 if (d_flags < 0)
176 return EXIT_FAILURE; 178 return EXIT_FAILURE;
177 179
180 if (flags & FILEUTILS_NO_TARGET_DIR) { /* -T */
181 if (!(s_flags & 2) && (d_flags & 2))
182 /* cp -T NOTDIR DIR */
183 bb_error_msg_and_die("'%s' is a directory", last);
184 }
185
178#if ENABLE_FEATURE_CP_LONG_OPTIONS 186#if ENABLE_FEATURE_CP_LONG_OPTIONS
179 //bb_error_msg("flags:%x FILEUTILS_RMDEST:%x OPT_parents:%x", 187 //bb_error_msg("flags:%x FILEUTILS_RMDEST:%x OPT_parents:%x",
180 // flags, FILEUTILS_RMDEST, OPT_parents); 188 // flags, FILEUTILS_RMDEST, OPT_parents);
@@ -192,11 +200,14 @@ int cp_main(int argc, char **argv)
192 if (!((s_flags | d_flags) & 2) 200 if (!((s_flags | d_flags) & 2)
193 /* ...or: recursing, the 1st is a directory, and the 2nd doesn't exist... */ 201 /* ...or: recursing, the 1st is a directory, and the 2nd doesn't exist... */
194 || ((flags & FILEUTILS_RECUR) && (s_flags & 2) && !d_flags) 202 || ((flags & FILEUTILS_RECUR) && (s_flags & 2) && !d_flags)
203 || (flags & FILEUTILS_NO_TARGET_DIR)
195 ) { 204 ) {
196 /* Do a simple copy */ 205 /* Do a simple copy */
197 dest = last; 206 dest = last;
198 goto DO_COPY; /* NB: argc==2 -> *++argv==last */ 207 goto DO_COPY; /* NB: argc==2 -> *++argv==last */
199 } 208 }
209 } else if (flags & FILEUTILS_NO_TARGET_DIR) {
210 bb_error_msg_and_die("too many arguments");
200 } 211 }
201 212
202 while (1) { 213 while (1) {