Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-22 16:28:34 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-22 16:28:34 +0300
commit56bbbfae7df48f778362d1848d2a4afd2c293d76 (patch)
treeb0ad2dff6ec225e2f41383f870f2f55d47911dd8 /coreutils
parent91b9549a8c739e5f0061dffb292d0dedbe913892 (diff)
cp: implement -n
function old new delta .rodata 103681 103722 +41 packed_usage 33698 33717 +19 copy_file 1678 1696 +18 cp_main 500 492 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 78/-8) Total: 70 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cp.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 8b9e03c95..b7f0e290f 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -84,8 +84,8 @@
// (SELinux) set SELinux security context of copy to CONTEXT
//usage:#define cp_trivial_usage
-//usage: "[-arPLHpfilsTu] SOURCE DEST\n"
-//usage: "or: cp [-arPLHpfilsu] SOURCE... { -t DIRECTORY | DIRECTORY }"
+//usage: "[-arPLHpfinlsTu] SOURCE DEST\n"
+//usage: "or: cp [-arPLHpfinlsu] SOURCE... { -t DIRECTORY | DIRECTORY }"
//usage:#define cp_full_usage "\n\n"
//usage: "Copy SOURCEs to DEST\n"
//usage: "\n -a Same as -dpR"
@@ -99,6 +99,7 @@
//usage: "\n -p Preserve file attributes if possible"
//usage: "\n -f Overwrite"
//usage: "\n -i Prompt before overwrite"
+//usage: "\n -n Don't overwrite"
//usage: "\n -l,-s Create (sym)links"
//usage: "\n -T Refuse to copy if DEST is a directory"
//usage: "\n -t DIR Copy all SOURCEs into DIR"
@@ -122,9 +123,9 @@ int cp_main(int argc, char **argv)
int status;
enum {
#if ENABLE_FEATURE_CP_LONG_OPTIONS
- /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */
- OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1),
- OPT_reflink = 1 << (FILEUTILS_CP_OPTNUM+2),
+ /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTBITS */
+ OPT_parents = 1 << (FILEUTILS_CP_OPTBITS+1),
+ OPT_reflink = 1 << (FILEUTILS_CP_OPTBITS+2),
#endif
};
#if ENABLE_FEATURE_CP_LONG_OPTIONS
@@ -134,23 +135,25 @@ int cp_main(int argc, char **argv)
flags = getopt32long(argv, "^"
FILEUTILS_CP_OPTSTR
"\0"
- // Need at least two arguments
+ // Need at least one argument. (Usually two+, but -t DIR can have only one)
// Soft- and hardlinking doesn't mix
// -P and -d are the same (-P is POSIX, -d is GNU)
// -r and -R are the same
// -R (and therefore -r) turns on -d (coreutils does this)
// -a = -pdR
- /* At least one argument. (Usually two+, but -t DIR can have only one) */
- "-1:l--s:s--l:Pd:rRd:Rd:apdR",
+ // -i overrides -n and vice versa (last wins)
+ "-1:l--s:s--l:Pd:rRd:Rd:apdR:i-n:n-i",
"archive\0" No_argument "a"
"force\0" No_argument "f"
"interactive\0" No_argument "i"
+ "no-clobber\0" No_argument "n"
"link\0" No_argument "l"
"dereference\0" No_argument "L"
"no-dereference\0" No_argument "P"
"recursive\0" No_argument "R"
"symbolic-link\0" No_argument "s"
"no-target-directory\0" No_argument "T"
+ "target-directory\0" Required_argument "t"
"verbose\0" No_argument "v"
"update\0" No_argument "u"
"remove-destination\0" No_argument "\xff"