diff options
author | imp <imp@FreeBSD.org> | 1996-11-01 18:46:05 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 1996-11-01 18:46:05 +0000 |
commit | bb3c2821a8ce93edc2bc6ab1ddcfd0cf8eaa6a5f (patch) | |
tree | 86d174ff260a034a928372b3750d921a7b3cf648 /usr.bin/xargs | |
parent | 8cf03fedfcf64ae6fece48a91405127bd03433e0 (diff) | |
download | FreeBSD-src-bb3c2821a8ce93edc2bc6ab1ddcfd0cf8eaa6a5f.zip FreeBSD-src-bb3c2821a8ce93edc2bc6ab1ddcfd0cf8eaa6a5f.tar.gz |
Reviewed by: Warner Losh <imp@village.org>
Submitted by: Marc Slemko <marcs@znep.com>
Obtained from: OpenBSD
Add -0 for reading the results of find -0.
Diffstat (limited to 'usr.bin/xargs')
-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 e703c43..ab10647 100644 --- a/usr.bin/xargs/xargs.1 +++ b/usr.bin/xargs/xargs.1 @@ -43,6 +43,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 @@ -79,6 +80,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 print0 +function 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 4d8c071..91f403b 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -55,6 +55,7 @@ static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93"; #include "pathnames.h" int tflag, rval; +int zflag; void err __P((const char *, ...)); void run __P((char **)); @@ -89,7 +90,7 @@ main(argc, argv, env) nline -= strlen(*ep++) + 1 + sizeof(*ep); } 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; @@ -105,6 +106,9 @@ main(argc, argv, env) case 'x': xflag = 1; break; + case '0': + zflag = 1; + break; case '?': default: usage(); @@ -178,10 +182,17 @@ main(argc, argv, env) 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; @@ -212,16 +223,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) err("backslash at EOF"); @@ -295,7 +308,7 @@ 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); } |