aboutsummaryrefslogtreecommitdiff
path: root/findutils/xargs.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-08-04 21:30:55 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-08-04 21:30:55 +0000
commit82ad032e263de5d69a70cc9b169aab393f5a2b50 (patch)
tree0a066bd8a2408974ed0b5acbacb47493ab08b243 /findutils/xargs.c
parent855ff6f503ee50fad3eb6fa30e2b02f53f32d63d (diff)
downloadbusybox-w32-82ad032e263de5d69a70cc9b169aab393f5a2b50.tar.gz
busybox-w32-82ad032e263de5d69a70cc9b169aab393f5a2b50.tar.bz2
busybox-w32-82ad032e263de5d69a70cc9b169aab393f5a2b50.zip
xargs: fix -e default to match newer GNU xargs, add SUS mandated -E.
closes bug 4414
Diffstat (limited to 'findutils/xargs.c')
-rw-r--r--findutils/xargs.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 92d01f7b6..f22d089ca 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -355,20 +355,22 @@ enum {
355 OPTBIT_UPTO_NUMBER, 355 OPTBIT_UPTO_NUMBER,
356 OPTBIT_UPTO_SIZE, 356 OPTBIT_UPTO_SIZE,
357 OPTBIT_EOF_STRING, 357 OPTBIT_EOF_STRING,
358 OPTBIT_EOF_STRING1,
358 USE_FEATURE_XARGS_SUPPORT_CONFIRMATION(OPTBIT_INTERACTIVE,) 359 USE_FEATURE_XARGS_SUPPORT_CONFIRMATION(OPTBIT_INTERACTIVE,)
359 USE_FEATURE_XARGS_SUPPORT_TERMOPT( OPTBIT_TERMINATE ,) 360 USE_FEATURE_XARGS_SUPPORT_TERMOPT( OPTBIT_TERMINATE ,)
360 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( OPTBIT_ZEROTERM ,) 361 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( OPTBIT_ZEROTERM ,)
361 362
362 OPT_VERBOSE = 1<<OPTBIT_VERBOSE , 363 OPT_VERBOSE = 1 << OPTBIT_VERBOSE ,
363 OPT_NO_EMPTY = 1<<OPTBIT_NO_EMPTY , 364 OPT_NO_EMPTY = 1 << OPTBIT_NO_EMPTY ,
364 OPT_UPTO_NUMBER = 1<<OPTBIT_UPTO_NUMBER, 365 OPT_UPTO_NUMBER = 1 << OPTBIT_UPTO_NUMBER,
365 OPT_UPTO_SIZE = 1<<OPTBIT_UPTO_SIZE , 366 OPT_UPTO_SIZE = 1 << OPTBIT_UPTO_SIZE ,
366 OPT_EOF_STRING = 1<<OPTBIT_EOF_STRING , 367 OPT_EOF_STRING = 1 << OPTBIT_EOF_STRING , /* GNU: -e[<param>] */
367 OPT_INTERACTIVE = USE_FEATURE_XARGS_SUPPORT_CONFIRMATION((1<<OPTBIT_INTERACTIVE)) + 0, 368 OPT_EOF_STRING1 = 1 << OPTBIT_EOF_STRING1, /* SUS: -E<param> */
368 OPT_TERMINATE = USE_FEATURE_XARGS_SUPPORT_TERMOPT( (1<<OPTBIT_TERMINATE )) + 0, 369 OPT_INTERACTIVE = USE_FEATURE_XARGS_SUPPORT_CONFIRMATION((1 << OPTBIT_INTERACTIVE)) + 0,
369 OPT_ZEROTERM = USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( (1<<OPTBIT_ZEROTERM )) + 0, 370 OPT_TERMINATE = USE_FEATURE_XARGS_SUPPORT_TERMOPT( (1 << OPTBIT_TERMINATE )) + 0,
371 OPT_ZEROTERM = USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( (1 << OPTBIT_ZEROTERM )) + 0,
370}; 372};
371#define OPTION_STR "+trn:s:e::" \ 373#define OPTION_STR "+trn:s:e::E:" \
372 USE_FEATURE_XARGS_SUPPORT_CONFIRMATION("p") \ 374 USE_FEATURE_XARGS_SUPPORT_CONFIRMATION("p") \
373 USE_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \ 375 USE_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \
374 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0") 376 USE_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0")
@@ -376,8 +378,6 @@ enum {
376int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 378int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
377int xargs_main(int argc, char **argv) 379int xargs_main(int argc, char **argv)
378{ 380{
379 static const char const_eof_str[] ALIGN1 = "_";
380
381 char **args; 381 char **args;
382 int i, n; 382 int i, n;
383 xlist_t *list = NULL; 383 xlist_t *list = NULL;
@@ -387,7 +387,7 @@ int xargs_main(int argc, char **argv)
387 int n_max_arg; 387 int n_max_arg;
388 size_t n_chars = 0; 388 size_t n_chars = 0;
389 long orig_arg_max; 389 long orig_arg_max;
390 const char *eof_str = const_eof_str; 390 const char *eof_str = NULL;
391 unsigned opt; 391 unsigned opt;
392 size_t n_max_chars; 392 size_t n_max_chars;
393#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 393#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
@@ -396,10 +396,12 @@ int xargs_main(int argc, char **argv)
396#define read_args process_stdin 396#define read_args process_stdin
397#endif 397#endif
398 398
399 opt = getopt32(argv, OPTION_STR, &max_args, &max_chars, &eof_str); 399 opt = getopt32(argv, OPTION_STR, &max_args, &max_chars, &eof_str, &eof_str);
400 400
401 /* -e without optional param? */ 401 /* -E ""? You may wonder why not just omit -E?
402 if ((opt & OPT_EOF_STRING) && eof_str == const_eof_str) 402 * This is used for portability:
403 * old xargs was using "_" as default for -E / -e */
404 if ((opt & OPT_EOF_STRING1) && eof_str[0] == '\0')
403 eof_str = NULL; 405 eof_str = NULL;
404 406
405 if (opt & OPT_ZEROTERM) 407 if (opt & OPT_ZEROTERM)