diff options
author | Elliott Hughes <enh@google.com> | 2019-08-17 20:13:38 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-08-26 21:54:44 -0500 |
commit | 0ec6b113985f4470e021f84b216c1b98e1e194ad (patch) | |
tree | c286b8d3792648fd5eef78a65f4be8206b1f0079 /lib | |
parent | c26870dab3462c6176936384b090df6b9ba46dee (diff) | |
download | toybox-0ec6b113985f4470e021f84b216c1b98e1e194ad.tar.gz |
xargs: add --max-args synonym, -o option, and fix -p.
The Linux kernel uses the --max-args synonym for -n.
Barbarians who use vi need xargs' -o to be able to do something like:
find -name xargs.c | xargs vi # Sad vi.
find -name xargs.c | xargs -o vi # Happy vi.
The -p option needs fixing to read from /dev/tty because stdin is
otherwise occupied in xargs. I think xargs is the only place that needs
this, so it didn't seem sensible to make all callers to yesno() be
specific about which they wanted, hence the new function.
Also remove the documentation for the build-time XARGS_PEDANTIC option
which isn't actually implemented.
Also add a TODO for -P (which is used by at least one script in the
Linux kernel).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 7 | ||||
-rw-r--r-- | lib/lib.h | 1 |
2 files changed, 7 insertions, 1 deletions
@@ -819,11 +819,16 @@ void base64_init(char *p) int yesno(int def) { + return fyesno(stdin, def); +} + +int fyesno(FILE *in, int def) +{ char buf; fprintf(stderr, " (%c/%c):", def ? 'Y' : 'y', def ? 'n' : 'N'); fflush(stderr); - while (fread(&buf, 1, 1, stdin)) { + while (fread(&buf, 1, 1, in)) { int new; // The letter changes the value, the newline (or space) returns it. @@ -250,6 +250,7 @@ void replace_tempfile(int fdin, int fdout, char **tempname); void crc_init(unsigned int *crc_table, int little_endian); void base64_init(char *p); int yesno(int def); +int fyesno(FILE *fp, int def); int qstrcmp(const void *a, const void *b); void create_uuid(char *uuid); char *show_uuid(char *uuid); |