aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-22 15:28:34 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-22 15:28:34 +0200
commit56bbbfae7df48f778362d1848d2a4afd2c293d76 (patch)
treeb0ad2dff6ec225e2f41383f870f2f55d47911dd8 /coreutils
parent91b9549a8c739e5f0061dffb292d0dedbe913892 (diff)
downloadbusybox-w32-56bbbfae7df48f778362d1848d2a4afd2c293d76.tar.gz
busybox-w32-56bbbfae7df48f778362d1848d2a4afd2c293d76.tar.bz2
busybox-w32-56bbbfae7df48f778362d1848d2a4afd2c293d76.zip
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 @@
84// (SELinux) set SELinux security context of copy to CONTEXT 84// (SELinux) set SELinux security context of copy to CONTEXT
85 85
86//usage:#define cp_trivial_usage 86//usage:#define cp_trivial_usage
87//usage: "[-arPLHpfilsTu] SOURCE DEST\n" 87//usage: "[-arPLHpfinlsTu] SOURCE DEST\n"
88//usage: "or: cp [-arPLHpfilsu] SOURCE... { -t DIRECTORY | DIRECTORY }" 88//usage: "or: cp [-arPLHpfinlsu] SOURCE... { -t DIRECTORY | DIRECTORY }"
89//usage:#define cp_full_usage "\n\n" 89//usage:#define cp_full_usage "\n\n"
90//usage: "Copy SOURCEs to DEST\n" 90//usage: "Copy SOURCEs to DEST\n"
91//usage: "\n -a Same as -dpR" 91//usage: "\n -a Same as -dpR"
@@ -99,6 +99,7 @@
99//usage: "\n -p Preserve file attributes if possible" 99//usage: "\n -p Preserve file attributes if possible"
100//usage: "\n -f Overwrite" 100//usage: "\n -f Overwrite"
101//usage: "\n -i Prompt before overwrite" 101//usage: "\n -i Prompt before overwrite"
102//usage: "\n -n Don't overwrite"
102//usage: "\n -l,-s Create (sym)links" 103//usage: "\n -l,-s Create (sym)links"
103//usage: "\n -T Refuse to copy if DEST is a directory" 104//usage: "\n -T Refuse to copy if DEST is a directory"
104//usage: "\n -t DIR Copy all SOURCEs into DIR" 105//usage: "\n -t DIR Copy all SOURCEs into DIR"
@@ -122,9 +123,9 @@ int cp_main(int argc, char **argv)
122 int status; 123 int status;
123 enum { 124 enum {
124#if ENABLE_FEATURE_CP_LONG_OPTIONS 125#if ENABLE_FEATURE_CP_LONG_OPTIONS
125 /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */ 126 /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTBITS */
126 OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1), 127 OPT_parents = 1 << (FILEUTILS_CP_OPTBITS+1),
127 OPT_reflink = 1 << (FILEUTILS_CP_OPTNUM+2), 128 OPT_reflink = 1 << (FILEUTILS_CP_OPTBITS+2),
128#endif 129#endif
129 }; 130 };
130#if ENABLE_FEATURE_CP_LONG_OPTIONS 131#if ENABLE_FEATURE_CP_LONG_OPTIONS
@@ -134,23 +135,25 @@ int cp_main(int argc, char **argv)
134 flags = getopt32long(argv, "^" 135 flags = getopt32long(argv, "^"
135 FILEUTILS_CP_OPTSTR 136 FILEUTILS_CP_OPTSTR
136 "\0" 137 "\0"
137 // Need at least two arguments 138 // Need at least one argument. (Usually two+, but -t DIR can have only one)
138 // Soft- and hardlinking doesn't mix 139 // Soft- and hardlinking doesn't mix
139 // -P and -d are the same (-P is POSIX, -d is GNU) 140 // -P and -d are the same (-P is POSIX, -d is GNU)
140 // -r and -R are the same 141 // -r and -R are the same
141 // -R (and therefore -r) turns on -d (coreutils does this) 142 // -R (and therefore -r) turns on -d (coreutils does this)
142 // -a = -pdR 143 // -a = -pdR
143 /* At least one argument. (Usually two+, but -t DIR can have only one) */ 144 // -i overrides -n and vice versa (last wins)
144 "-1:l--s:s--l:Pd:rRd:Rd:apdR", 145 "-1:l--s:s--l:Pd:rRd:Rd:apdR:i-n:n-i",
145 "archive\0" No_argument "a" 146 "archive\0" No_argument "a"
146 "force\0" No_argument "f" 147 "force\0" No_argument "f"
147 "interactive\0" No_argument "i" 148 "interactive\0" No_argument "i"
149 "no-clobber\0" No_argument "n"
148 "link\0" No_argument "l" 150 "link\0" No_argument "l"
149 "dereference\0" No_argument "L" 151 "dereference\0" No_argument "L"
150 "no-dereference\0" No_argument "P" 152 "no-dereference\0" No_argument "P"
151 "recursive\0" No_argument "R" 153 "recursive\0" No_argument "R"
152 "symbolic-link\0" No_argument "s" 154 "symbolic-link\0" No_argument "s"
153 "no-target-directory\0" No_argument "T" 155 "no-target-directory\0" No_argument "T"
156 "target-directory\0" Required_argument "t"
154 "verbose\0" No_argument "v" 157 "verbose\0" No_argument "v"
155 "update\0" No_argument "u" 158 "update\0" No_argument "u"
156 "remove-destination\0" No_argument "\xff" 159 "remove-destination\0" No_argument "\xff"