diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-08-25 22:42:05 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-29 21:05:40 +0200 |
commit | f8ee849ecd42fa11da6c5f381ad83594840b3cca (patch) | |
tree | 9ba537ad3ea5aaa26395f5ab846a654ca096b3de | |
parent | f41ffff2dce2c08d96a11a21a01437e6354e659e (diff) | |
download | busybox-w32-f8ee849ecd42fa11da6c5f381ad83594840b3cca.tar.gz busybox-w32-f8ee849ecd42fa11da6c5f381ad83594840b3cca.tar.bz2 busybox-w32-f8ee849ecd42fa11da6c5f381ad83594840b3cca.zip |
xargs: support -a FILE
The GNU-specific option -a lets xargs read the arguments from a file
rather than from stdin.
This is particularly convenient when debugging in gdb interactively,
and it might be of more general use.
function old new delta
xargs_main 788 823 +35
packed_usage 31683 31671 -12
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | findutils/xargs.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c index 77e01ef6c..acee0319a 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -64,6 +64,11 @@ | |||
64 | //config: bool "Enable -P N: processes to run in parallel" | 64 | //config: bool "Enable -P N: processes to run in parallel" |
65 | //config: default y | 65 | //config: default y |
66 | //config: depends on XARGS | 66 | //config: depends on XARGS |
67 | //config: | ||
68 | //config:config FEATURE_XARGS_SUPPORT_ARGS_FILE | ||
69 | //config: bool "Enable -a FILE: use FILE instead of stdin" | ||
70 | //config: default y | ||
71 | //config: depends on XARGS | ||
67 | 72 | ||
68 | //applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, BB_DIR_USR_BIN, BB_SUID_DROP, xargs)) | 73 | //applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, BB_DIR_USR_BIN, BB_SUID_DROP, xargs)) |
69 | 74 | ||
@@ -517,6 +522,9 @@ static int xargs_ask_confirmation(void) | |||
517 | //usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( | 522 | //usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( |
518 | //usage: "\n -0 Input is separated by NUL characters" | 523 | //usage: "\n -0 Input is separated by NUL characters" |
519 | //usage: ) | 524 | //usage: ) |
525 | //usage: IF_FEATURE_XARGS_SUPPORT_ARGS_FILE( | ||
526 | //usage: "\n -a FILE Read from FILE instead of stdin" | ||
527 | //usage: ) | ||
520 | //usage: "\n -t Print the command on stderr before execution" | 528 | //usage: "\n -t Print the command on stderr before execution" |
521 | //usage: "\n -e[STR] STR stops input processing" | 529 | //usage: "\n -e[STR] STR stops input processing" |
522 | //usage: "\n -n N Pass no more than N args to PROG" | 530 | //usage: "\n -n N Pass no more than N args to PROG" |
@@ -565,7 +573,8 @@ enum { | |||
565 | IF_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \ | 573 | IF_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \ |
566 | IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0") \ | 574 | IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0") \ |
567 | IF_FEATURE_XARGS_SUPPORT_REPL_STR( "I:i::") \ | 575 | IF_FEATURE_XARGS_SUPPORT_REPL_STR( "I:i::") \ |
568 | IF_FEATURE_XARGS_SUPPORT_PARALLEL( "P:+") | 576 | IF_FEATURE_XARGS_SUPPORT_PARALLEL( "P:+") \ |
577 | IF_FEATURE_XARGS_SUPPORT_ARGS_FILE( "a:") | ||
569 | 578 | ||
570 | int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 579 | int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
571 | int xargs_main(int argc UNUSED_PARAM, char **argv) | 580 | int xargs_main(int argc UNUSED_PARAM, char **argv) |
@@ -584,6 +593,7 @@ int xargs_main(int argc UNUSED_PARAM, char **argv) | |||
584 | #else | 593 | #else |
585 | #define read_args process_stdin | 594 | #define read_args process_stdin |
586 | #endif | 595 | #endif |
596 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(char *opt_a = NULL;) | ||
587 | 597 | ||
588 | INIT_G(); | 598 | INIT_G(); |
589 | 599 | ||
@@ -592,6 +602,7 @@ int xargs_main(int argc UNUSED_PARAM, char **argv) | |||
592 | &max_args, &max_chars, &G.eof_str, &G.eof_str | 602 | &max_args, &max_chars, &G.eof_str, &G.eof_str |
593 | IF_FEATURE_XARGS_SUPPORT_REPL_STR(, &G.repl_str, &G.repl_str) | 603 | IF_FEATURE_XARGS_SUPPORT_REPL_STR(, &G.repl_str, &G.repl_str) |
594 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(, &G.max_procs) | 604 | IF_FEATURE_XARGS_SUPPORT_PARALLEL(, &G.max_procs) |
605 | IF_FEATURE_XARGS_SUPPORT_ARGS_FILE(, &opt_a) | ||
595 | ); | 606 | ); |
596 | 607 | ||
597 | #if ENABLE_FEATURE_XARGS_SUPPORT_PARALLEL | 608 | #if ENABLE_FEATURE_XARGS_SUPPORT_PARALLEL |
@@ -599,6 +610,11 @@ int xargs_main(int argc UNUSED_PARAM, char **argv) | |||
599 | G.max_procs = 100; /* let's not go crazy high */ | 610 | G.max_procs = 100; /* let's not go crazy high */ |
600 | #endif | 611 | #endif |
601 | 612 | ||
613 | #if ENABLE_FEATURE_XARGS_SUPPORT_ARGS_FILE | ||
614 | if (opt_a) | ||
615 | xmove_fd(xopen(opt_a, O_RDONLY), 0); | ||
616 | #endif | ||
617 | |||
602 | /* -E ""? You may wonder why not just omit -E? | 618 | /* -E ""? You may wonder why not just omit -E? |
603 | * This is used for portability: | 619 | * This is used for portability: |
604 | * old xargs was using "_" as default for -E / -e */ | 620 | * old xargs was using "_" as default for -E / -e */ |