summaryrefslogtreecommitdiffstats
path: root/usr.bin/xargs/xargs.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1996-11-01 18:46:05 +0000
committerimp <imp@FreeBSD.org>1996-11-01 18:46:05 +0000
commitbb3c2821a8ce93edc2bc6ab1ddcfd0cf8eaa6a5f (patch)
tree86d174ff260a034a928372b3750d921a7b3cf648 /usr.bin/xargs/xargs.c
parent8cf03fedfcf64ae6fece48a91405127bd03433e0 (diff)
downloadFreeBSD-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/xargs.c')
-rw-r--r--usr.bin/xargs/xargs.c23
1 files changed, 18 insertions, 5 deletions
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);
}
OpenPOWER on IntegriCloud