diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-11 06:48:07 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-11 06:48:07 +0000 |
commit | 5726d6ded5924b436fd5ef05d7053d50d49699ae (patch) | |
tree | 9b9015e9d6edf10d95cdf19086ea15177fd97500 | |
parent | 5fe6f013e0a8a192a9585306aeeb5b2a2f900daa (diff) |
add -0 option, written by me
-rw-r--r-- | usr.bin/xargs/xargs.1 | 11 | ||||
-rw-r--r-- | usr.bin/xargs/xargs.c | 23 |
2 files changed, 29 insertions, 5 deletions
diff --git a/usr.bin/xargs/xargs.1 b/usr.bin/xargs/xargs.1 index 312c7f0165b..4e3713e3757 100644 --- a/usr.bin/xargs/xargs.1 +++ b/usr.bin/xargs/xargs.1 @@ -45,6 +45,7 @@ .Nd "construct argument list(s) and execute utility" .Sh SYNOPSIS .Nm xargs +.Op Fl 0 .Op Fl t .Oo Op Fl x .Fl n Ar number @@ -81,6 +82,16 @@ Any single character, including newlines, may be escaped by a backslash. .Pp The options are as follows: .Bl -tag -width indent +.It Fl 0 +Changes +.Nm xargs +to expect NUL +(``\\0'') +characters as seperators, instead of spaces and newlines. +This is expected to be used in concert with the +.Fl 0 +option in +.Nm find . .It Fl n Ar number Set the maximum number of arguments taken from standard input for each invocation of the utility. diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index 73910240dcc..062f54f1f49 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -62,6 +62,7 @@ static char rcsid[] = "$NetBSD: xargs.c,v 1.7 1994/11/14 06:51:41 jtc Exp $"; #include "pathnames.h" int tflag, rval; +int zflag; void run __P((char **)); void usage __P((void)); @@ -94,7 +95,7 @@ main(argc, argv) nargs = 5000; nline = ARG_MAX - 4 * 1024; nflag = xflag = 0; - while ((ch = getopt(argc, argv, "n:s:tx")) != EOF) + while ((ch = getopt(argc, argv, "0n:s:tx")) != EOF) switch(ch) { case 'n': nflag = 1; @@ -110,6 +111,9 @@ main(argc, argv) case 'x': xflag = 1; break; + case '0': + zflag = 1; + break; case '?': default: usage(); @@ -183,10 +187,17 @@ main(argc, argv) case ' ': case '\t': /* Quotes escape tabs and spaces. */ - if (insingle || indouble) + if (insingle || indouble || zflag) goto addch; goto arg2; + case '\0': + if (zflag) + goto arg2; + goto addch; case '\n': + if (zflag) + goto addch; + /* Empty lines are skipped. */ if (argp == p) continue; @@ -217,16 +228,18 @@ arg2: *p = '\0'; argp = p; break; case '\'': - if (indouble) + if (indouble || zflag) goto addch; insingle = !insingle; break; case '"': - if (insingle) + if (insingle || zflag) goto addch; indouble = !indouble; break; case '\\': + if (zflag) + goto addch; /* Backslash escapes anything, is escaped by quotes. */ if (!insingle && !indouble && (ch = getchar()) == EOF) errx(1, "backslash at EOF"); @@ -316,6 +329,6 @@ void usage() { (void)fprintf(stderr, -"usage: xargs [-t] [-n number [-x]] [-s size] [utility [argument ...]]\n"); +"usage: xargs [-0] [-t] [-n number [-x]] [-s size] [utility [argument ...]]\n"); exit(1); } |