diff options
author | Rob Landley <rob@landley.net> | 2012-01-30 07:40:32 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-01-30 07:40:32 -0600 |
commit | 801c3d52adaf2c976b075c63bc2f0ae79dcfbe3c (patch) | |
tree | c28d6f937211be49bbdea20b7c7291f3c0115e96 /toys/xargs.c | |
parent | b6063de0382e9145df7fdb63383244f68d355243 (diff) | |
download | toybox-801c3d52adaf2c976b075c63bc2f0ae79dcfbe3c.tar.gz |
More work on xargs: bugfix and tests.
Diffstat (limited to 'toys/xargs.c')
-rw-r--r-- | toys/xargs.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/toys/xargs.c b/toys/xargs.c index 67e88cfc..8b873d57 100644 --- a/toys/xargs.c +++ b/toys/xargs.c @@ -6,7 +6,7 @@ * * See http://opengroup.org/onlinepubs/9699919799/utilities/xargs.html -USE_XARGS(NEWTOY(xargs, "n#s#0", TOYFLAG_USR|TOYFLAG_BIN)) +USE_XARGS(NEWTOY(xargs, "^I:E:L#ptxrn#<1s#0", TOYFLAG_USR|TOYFLAG_BIN)) config XARGS bool "xargs" @@ -16,9 +16,17 @@ config XARGS Run command line one or more times, appending arguments from stdin. + If command exits with 255, don't launch another even if arguments remain. + -s Size in bytes per command line -n Max number of arguments per command -0 Each argument is NULL terminated, no whitespace or quote processing + #-p Prompt for y/n from tty before running each command + #-t Trace, print command line to stderr + #-x Exit if can't fit everything in one command + #-r Don't run command with empty input + #-L Max number of lines of input per command + #-E stop at line matching string */ #include "toys.h" @@ -64,7 +72,7 @@ static char *handle_entries(char *data, char **entry) } if (TT.entries >= TT.max_entries && TT.max_entries) - return *s ? (char *)1: s; + return *s ? s : (char *)1; if (!*s) break; save = s; @@ -106,10 +114,11 @@ void xargs_main(void) bytes += strlen(toys.optargs[entries]); // Loop through exec chunks. - while (!done) { + while (data || !done) { + char **out; + TT.entries = 0; TT.bytes = bytes; - char **out; // Loop reading input for (;;) { |