summaryrefslogtreecommitdiff
path: root/usr.bin/xargs
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2017-01-19 17:08:43 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2017-01-19 17:08:43 +0000
commit337b912b1629923596361c535306302b507bfbbf (patch)
tree627dab22a63cdb474256482756cef782dd74c856 /usr.bin/xargs
parent4b728c68f3744629640dbbc93189b831529a5678 (diff)
Fix -L/-I processing in -0 mode so that NUL-delimited entries are
treated as "lines". From FreeBSD.
Diffstat (limited to 'usr.bin/xargs')
-rw-r--r--usr.bin/xargs/xargs.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index 6c1c31b1fea..d32364b16f1 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xargs.c,v 1.31 2015/12/09 19:29:49 mmcc Exp $ */
+/* $OpenBSD: xargs.c,v 1.32 2017/01/19 17:08:41 millert Exp $ */
/* $FreeBSD: xargs.c,v 1.51 2003/05/03 19:09:11 obrien Exp $ */
/*-
@@ -278,15 +278,22 @@ parse_input(int argc, char *argv[])
}
goto arg1;
case '\0':
- if (zflag)
+ if (zflag) {
+ /*
+ * Increment 'count', so that nulls will be treated
+ * as end-of-line, as well as end-of-argument. This
+ * is needed so -0 works properly with -I and -L.
+ */
+ count++;
goto arg2;
+ }
goto addch;
case '\n':
+ if (zflag)
+ goto addch;
hasblank = 1;
if (hadblank == 0)
count++;
- if (zflag)
- goto addch;
/* Quotes do not escape newlines. */
arg1: if (insingle || indouble)