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 /usr.bin/xargs/xargs.c | |
parent | 5fe6f013e0a8a192a9585306aeeb5b2a2f900daa (diff) |
add -0 option, written by me
Diffstat (limited to 'usr.bin/xargs/xargs.c')
-rw-r--r-- | usr.bin/xargs/xargs.c | 23 |
1 files changed, 18 insertions, 5 deletions
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); } |