On Mon, 16 Jan 2017 16:51:16 +0100, Andreas Kusalananda =?iso-8859-1?B?S+Ro5HJp
?= wrote:

> Well, the manual also says, about "-0":
> 
>     Change xargs to expect NUL (‘\0’) characters as separators, instead
>     of spaces and newlines.
> 
> Note the "instead of".

It is definitely a bug.  The following diff fixes the problem you
see but causes xargs regress failures.

 - todd

Index: usr.bin/xargs/xargs.c
===================================================================
RCS file: /cvs/src/usr.bin/xargs/xargs.c,v
retrieving revision 1.31
diff -u -p -u -r1.31 xargs.c
--- usr.bin/xargs/xargs.c       9 Dec 2015 19:29:49 -0000       1.31
+++ usr.bin/xargs/xargs.c       16 Jan 2017 16:03:01 -0000
@@ -278,8 +278,12 @@ parse_input(int argc, char *argv[])
                }
                goto arg1;
        case '\0':
-               if (zflag)
+               if (zflag) {
+                       hasblank = 1;
+                       if (hadblank == 0)
+                               count++;
                        goto arg2;
+               }
                goto addch;
        case '\n':
                hasblank = 1;

Reply via email to