aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-07-07 14:28:08 +0100
committerRon Yorston <rmy@pobox.com>2016-07-07 14:58:55 +0100
commit613f46218c53c8cabdbf0435653e74e0e0e91e1c (patch)
treeca06a7e7a3e4c861441acb4ea20648d7827fa6ae /coreutils
parenta0c61c9492723dd31681f878f9c68c92817a476d (diff)
parent237bedd499c58034a1355484d6d4d906f0180308 (diff)
downloadbusybox-w32-613f46218c53c8cabdbf0435653e74e0e0e91e1c.tar.gz
busybox-w32-613f46218c53c8cabdbf0435653e74e0e0e91e1c.tar.bz2
busybox-w32-613f46218c53c8cabdbf0435653e74e0e0e91e1c.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cp.c30
-rw-r--r--coreutils/df.c20
-rw-r--r--coreutils/du.c8
-rw-r--r--coreutils/env.c3
-rw-r--r--coreutils/od_bloaty.c3
-rw-r--r--coreutils/sort.c5
-rw-r--r--coreutils/split.c4
-rw-r--r--coreutils/tail.c4
-rw-r--r--coreutils/uniq.c3
9 files changed, 41 insertions, 39 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 247ed0fda..2630c0d59 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -31,6 +31,7 @@
31//usage: "\n -f Overwrite" 31//usage: "\n -f Overwrite"
32//usage: "\n -i Prompt before overwrite" 32//usage: "\n -i Prompt before overwrite"
33//usage: "\n -l,-s Create (sym)links" 33//usage: "\n -l,-s Create (sym)links"
34//usage: "\n -u Copy only newer files"
34 35
35#include "libbb.h" 36#include "libbb.h"
36#include "libcoreutils/coreutils.h" 37#include "libcoreutils/coreutils.h"
@@ -49,12 +50,10 @@ int cp_main(int argc, char **argv)
49 int flags; 50 int flags;
50 int status; 51 int status;
51 enum { 52 enum {
52 OPT_a = 1 << (sizeof(FILEUTILS_CP_OPTSTR)-1), 53 FILEUTILS_CP_OPTNUM = sizeof(FILEUTILS_CP_OPTSTR)-1,
53 OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)),
54 OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1),
55 OPT_v = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2),
56#if ENABLE_FEATURE_CP_LONG_OPTIONS 54#if ENABLE_FEATURE_CP_LONG_OPTIONS
57 OPT_parents = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3), 55 /*OPT_rmdest = FILEUTILS_RMDEST = 1 << FILEUTILS_CP_OPTNUM */
56 OPT_parents = 1 << (FILEUTILS_CP_OPTNUM+1),
58#endif 57#endif
59 }; 58 };
60 59
@@ -76,10 +75,12 @@ int cp_main(int argc, char **argv)
76 "recursive\0" No_argument "R" 75 "recursive\0" No_argument "R"
77 "symbolic-link\0" No_argument "s" 76 "symbolic-link\0" No_argument "s"
78 "verbose\0" No_argument "v" 77 "verbose\0" No_argument "v"
79 "parents\0" No_argument "\xff" 78 "update\0" No_argument "u"
79 "remove-destination\0" No_argument "\xff"
80 "parents\0" No_argument "\xfe"
80 ; 81 ;
81#endif 82#endif
82 flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPv"); 83 flags = getopt32(argv, FILEUTILS_CP_OPTSTR);
83 /* Options of cp from GNU coreutils 6.10: 84 /* Options of cp from GNU coreutils 6.10:
84 * -a, --archive 85 * -a, --archive
85 * -f, --force 86 * -f, --force
@@ -94,6 +95,11 @@ int cp_main(int argc, char **argv)
94 * -d same as --no-dereference --preserve=links 95 * -d same as --no-dereference --preserve=links
95 * -p same as --preserve=mode,ownership,timestamps 96 * -p same as --preserve=mode,ownership,timestamps
96 * -c same as --preserve=context 97 * -c same as --preserve=context
98 * -u, --update
99 * copy only when the SOURCE file is newer than the destination
100 * file or when the destination file is missing
101 * --remove-destination
102 * remove each existing destination file before attempting to open
97 * --parents 103 * --parents
98 * use full source file name under DIRECTORY 104 * use full source file name under DIRECTORY
99 * NOT SUPPORTED IN BBOX: 105 * NOT SUPPORTED IN BBOX:
@@ -106,8 +112,6 @@ int cp_main(int argc, char **argv)
106 * preserve attributes (default: mode,ownership,timestamps), 112 * preserve attributes (default: mode,ownership,timestamps),
107 * if possible additional attributes: security context,links,all 113 * if possible additional attributes: security context,links,all
108 * --no-preserve=ATTR_LIST 114 * --no-preserve=ATTR_LIST
109 * --remove-destination
110 * remove each existing destination file before attempting to open
111 * --sparse=WHEN 115 * --sparse=WHEN
112 * control creation of sparse files 116 * control creation of sparse files
113 * --strip-trailing-slashes 117 * --strip-trailing-slashes
@@ -118,9 +122,6 @@ int cp_main(int argc, char **argv)
118 * copy all SOURCE arguments into DIRECTORY 122 * copy all SOURCE arguments into DIRECTORY
119 * -T, --no-target-directory 123 * -T, --no-target-directory
120 * treat DEST as a normal file 124 * treat DEST as a normal file
121 * -u, --update
122 * copy only when the SOURCE file is newer than the destination
123 * file or when the destination file is missing
124 * -x, --one-file-system 125 * -x, --one-file-system
125 * stay on this file system 126 * stay on this file system
126 * -Z, --context=CONTEXT 127 * -Z, --context=CONTEXT
@@ -156,11 +157,16 @@ int cp_main(int argc, char **argv)
156 return EXIT_FAILURE; 157 return EXIT_FAILURE;
157 158
158#if ENABLE_FEATURE_CP_LONG_OPTIONS 159#if ENABLE_FEATURE_CP_LONG_OPTIONS
160 //bb_error_msg("flags:%x FILEUTILS_RMDEST:%x OPT_parents:%x",
161 // flags, FILEUTILS_RMDEST, OPT_parents);
159 if (flags & OPT_parents) { 162 if (flags & OPT_parents) {
160 if (!(d_flags & 2)) { 163 if (!(d_flags & 2)) {
161 bb_error_msg_and_die("with --parents, the destination must be a directory"); 164 bb_error_msg_and_die("with --parents, the destination must be a directory");
162 } 165 }
163 } 166 }
167 if (flags & FILEUTILS_RMDEST) {
168 flags |= FILEUTILS_FORCE;
169 }
164#endif 170#endif
165 171
166 /* ...if neither is a directory... */ 172 /* ...if neither is a directory... */
diff --git a/coreutils/df.c b/coreutils/df.c
index d79c11a6c..06b292018 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -188,7 +188,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
188 if (opt & OPT_INODE) { 188 if (opt & OPT_INODE) {
189 s.f_blocks = s.f_files; 189 s.f_blocks = s.f_files;
190 s.f_bavail = s.f_bfree = s.f_ffree; 190 s.f_bavail = s.f_bfree = s.f_ffree;
191 s.f_bsize = 1; 191 s.f_frsize = 1;
192 192
193 if (df_disp_hr) 193 if (df_disp_hr)
194 df_disp_hr = 1; 194 df_disp_hr = 1;
@@ -246,26 +246,26 @@ int df_main(int argc UNUSED_PARAM, char **argv)
246 246
247#if ENABLE_FEATURE_HUMAN_READABLE 247#if ENABLE_FEATURE_HUMAN_READABLE
248 printf(" %9s ", 248 printf(" %9s ",
249 /* f_blocks x f_bsize / df_disp_hr, show one fractional, 249 /* f_blocks x f_frsize / df_disp_hr, show one fractional,
250 * use suffixes if df_disp_hr == 0 */ 250 * use suffixes if df_disp_hr == 0 */
251 make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); 251 make_human_readable_str(s.f_blocks, s.f_frsize, df_disp_hr));
252 252
253 printf(" %9s " + 1, 253 printf(" %9s " + 1,
254 /* EXPR x f_bsize / df_disp_hr, show one fractional, 254 /* EXPR x f_frsize / df_disp_hr, show one fractional,
255 * use suffixes if df_disp_hr == 0 */ 255 * use suffixes if df_disp_hr == 0 */
256 make_human_readable_str((s.f_blocks - s.f_bfree), 256 make_human_readable_str((s.f_blocks - s.f_bfree),
257 s.f_bsize, df_disp_hr)); 257 s.f_frsize, df_disp_hr));
258 258
259 printf("%9s %3u%% %s\n", 259 printf("%9s %3u%% %s\n",
260 /* f_bavail x f_bsize / df_disp_hr, show one fractional, 260 /* f_bavail x f_frsize / df_disp_hr, show one fractional,
261 * use suffixes if df_disp_hr == 0 */ 261 * use suffixes if df_disp_hr == 0 */
262 make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), 262 make_human_readable_str(s.f_bavail, s.f_frsize, df_disp_hr),
263 blocks_percent_used, mount_point); 263 blocks_percent_used, mount_point);
264#else 264#else
265 printf(" %9lu %9lu %9lu %3u%% %s\n", 265 printf(" %9lu %9lu %9lu %3u%% %s\n",
266 kscale(s.f_blocks, s.f_bsize), 266 kscale(s.f_blocks, s.f_frsize),
267 kscale(s.f_blocks - s.f_bfree, s.f_bsize), 267 kscale(s.f_blocks - s.f_bfree, s.f_frsize),
268 kscale(s.f_bavail, s.f_bsize), 268 kscale(s.f_bavail, s.f_frsize),
269 blocks_percent_used, mount_point); 269 blocks_percent_used, mount_point);
270#endif 270#endif
271 } 271 }
diff --git a/coreutils/du.c b/coreutils/du.c
index 1240bcbbc..5f104736b 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -226,8 +226,8 @@ int du_main(int argc UNUSED_PARAM, char **argv)
226 * ignore -a. This is consistent with -s being equivalent to -d 0. 226 * ignore -a. This is consistent with -s being equivalent to -d 0.
227 */ 227 */
228#if ENABLE_FEATURE_HUMAN_READABLE 228#if ENABLE_FEATURE_HUMAN_READABLE
229 opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+"; 229 opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
230 opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth); 230 opt = getopt32(argv, "aHkLsx" "d:+" "lc" "hm", &G.max_print_depth);
231 argv += optind; 231 argv += optind;
232 if (opt & OPT_h_for_humans) { 232 if (opt & OPT_h_for_humans) {
233 G.disp_unit = 0; 233 G.disp_unit = 0;
@@ -239,8 +239,8 @@ int du_main(int argc UNUSED_PARAM, char **argv)
239 G.disp_unit = 1024; 239 G.disp_unit = 1024;
240 } 240 }
241#else 241#else
242 opt_complementary = "H-L:L-H:s-d:d-s:d+"; 242 opt_complementary = "H-L:L-H:s-d:d-s";
243 opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth); 243 opt = getopt32(argv, "aHkLsx" "d:+" "lc", &G.max_print_depth);
244 argv += optind; 244 argv += optind;
245#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K 245#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
246 if (opt & OPT_k_kbytes) { 246 if (opt & OPT_k_kbytes) {
diff --git a/coreutils/env.c b/coreutils/env.c
index 807ef13e9..cdfc30e14 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -54,11 +54,10 @@ int env_main(int argc UNUSED_PARAM, char **argv)
54 unsigned opts; 54 unsigned opts;
55 llist_t *unset_env = NULL; 55 llist_t *unset_env = NULL;
56 56
57 opt_complementary = "u::";
58#if ENABLE_FEATURE_ENV_LONG_OPTIONS 57#if ENABLE_FEATURE_ENV_LONG_OPTIONS
59 applet_long_options = env_longopts; 58 applet_long_options = env_longopts;
60#endif 59#endif
61 opts = getopt32(argv, "+iu:", &unset_env); 60 opts = getopt32(argv, "+iu:+", &unset_env);
62 argv += optind; 61 argv += optind;
63 if (argv[0] && LONE_DASH(argv[0])) { 62 if (argv[0] && LONE_DASH(argv[0])) {
64 opts |= 1; 63 opts |= 1;
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index a5b3e99f7..b02fb09bd 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -62,7 +62,7 @@ enum {
62}; 62};
63 63
64#define OD_GETOPT32() getopt32(argv, \ 64#define OD_GETOPT32() getopt32(argv, \
65 "A:N:abcdfhij:lot:vxsS:w::", \ 65 "A:N:abcdfhij:lot:*vxsS:w:+:", \
66 /* -w with optional param */ \ 66 /* -w with optional param */ \
67 /* -S was -s and also had optional parameter */ \ 67 /* -S was -s and also had optional parameter */ \
68 /* but in coreutils 6.3 it was renamed and now has */ \ 68 /* but in coreutils 6.3 it was renamed and now has */ \
@@ -1219,7 +1219,6 @@ int od_main(int argc UNUSED_PARAM, char **argv)
1219 address_pad_len_char = '7'; 1219 address_pad_len_char = '7';
1220 1220
1221 /* Parse command line */ 1221 /* Parse command line */
1222 opt_complementary = "w+:t::"; /* -w N, -t is a list */
1223#if ENABLE_LONG_OPTS 1222#if ENABLE_LONG_OPTS
1224 applet_long_options = od_longopts; 1223 applet_long_options = od_longopts;
1225#endif 1224#endif
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 9139d9f47..34a41999b 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -73,7 +73,7 @@
73*/ 73*/
74 74
75/* These are sort types */ 75/* These are sort types */
76static const char OPT_STR[] ALIGN1 = "ngMucszbrdfimS:T:o:k:t:"; 76static const char OPT_STR[] ALIGN1 = "ngMucszbrdfimS:T:o:k:*t:";
77enum { 77enum {
78 FLAG_n = 1, /* Numeric sort */ 78 FLAG_n = 1, /* Numeric sort */
79 FLAG_g = 2, /* Sort using strtod() */ 79 FLAG_g = 2, /* Sort using strtod() */
@@ -358,8 +358,7 @@ int sort_main(int argc UNUSED_PARAM, char **argv)
358 358
359 /* Parse command line options */ 359 /* Parse command line options */
360 /* -o and -t can be given at most once */ 360 /* -o and -t can be given at most once */
361 opt_complementary = "o--o:t--t:" /* -t, -o: at most one of each */ 361 opt_complementary = "o--o:t--t"; /* -t, -o: at most one of each */
362 "k::"; /* -k takes list */
363 opts = getopt32(argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t); 362 opts = getopt32(argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t);
364 /* global b strips leading and trailing spaces */ 363 /* global b strips leading and trailing spaces */
365 if (opts & FLAG_b) 364 if (opts & FLAG_b)
diff --git a/coreutils/split.c b/coreutils/split.c
index e67c3de66..19d58a21b 100644
--- a/coreutils/split.c
+++ b/coreutils/split.c
@@ -81,8 +81,8 @@ int split_main(int argc UNUSED_PARAM, char **argv)
81 81
82 setup_common_bufsiz(); 82 setup_common_bufsiz();
83 83
84 opt_complementary = "?2:a+"; /* max 2 args; -a N */ 84 opt_complementary = "?2"; /* max 2 args; -a N */
85 opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); 85 opt = getopt32(argv, "l:b:a:+", &count_p, &count_p, &suffix_len);
86 86
87 if (opt & SPLIT_OPT_l) 87 if (opt & SPLIT_OPT_l)
88 cnt = XATOOFF(count_p); 88 cnt = XATOOFF(count_p);
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 39f87679e..57ad0f3b7 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -121,8 +121,8 @@ int tail_main(int argc, char **argv)
121#endif 121#endif
122 122
123 /* -s NUM, -F imlies -f */ 123 /* -s NUM, -F imlies -f */
124 IF_FEATURE_FANCY_TAIL(opt_complementary = "s+:Ff";) 124 IF_FEATURE_FANCY_TAIL(opt_complementary = "Ff";)
125 opt = getopt32(argv, "fc:n:" IF_FEATURE_FANCY_TAIL("qs:vF"), 125 opt = getopt32(argv, "fc:n:" IF_FEATURE_FANCY_TAIL("qs:+vF"),
126 &str_c, &str_n IF_FEATURE_FANCY_TAIL(,&sleep_period)); 126 &str_c, &str_n IF_FEATURE_FANCY_TAIL(,&sleep_period));
127#define FOLLOW (opt & 0x1) 127#define FOLLOW (opt & 0x1)
128#define COUNT_BYTES (opt & 0x2) 128#define COUNT_BYTES (opt & 0x2)
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index e0133998a..ec7bde418 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -50,8 +50,7 @@ int uniq_main(int argc UNUSED_PARAM, char **argv)
50 skip_fields = skip_chars = 0; 50 skip_fields = skip_chars = 0;
51 max_chars = INT_MAX; 51 max_chars = INT_MAX;
52 52
53 opt_complementary = "f+:s+:w+"; 53 opt = getopt32(argv, "cduf:+s:+w:+", &skip_fields, &skip_chars, &max_chars);
54 opt = getopt32(argv, "cduf:s:w:", &skip_fields, &skip_chars, &max_chars);
55 argv += optind; 54 argv += optind;
56 55
57 input_filename = argv[0]; 56 input_filename = argv[0];