[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8081: sort -z and shuf -z don't work
From: |
Jim Meyering |
Subject: |
bug#8081: sort -z and shuf -z don't work |
Date: |
Sat, 19 Feb 2011 14:58:36 +0100 |
Harald Dunkel wrote:
> Package: coreutils
> Version: 8.10
>
> Hi folks,
>
> According to the man page "sort -z" and "shuf -z" are supposed to
> "end lines with 0 byte, not newline". This doesn't work. Example:
>
> % ( echo 1; echo 2; echo 3 ) | tac | sort -z | xargs -0 -L 1 echo xxx
> xxx 3
> 2
> 1
>
> There are 3 line on input, so there should be 3 lines with "xxx" on
> output. If I omit the -z, then it works:
>
> % ( echo 1; echo 2; echo 3 ) | tac | sort | xargs -L 1 echo xxx
> xxx 1
> xxx 2
> xxx 3
Thanks for the report, but I don't see a bug -- except that the -z
description in --help (and hence in the generated man page) can be
improved. Suggestions welcome.
Here's the real documentation from "info coreutils sort":
`-z'
`--zero-terminated'
Delimit items with a zero byte rather than a newline (ASCII LF).
I.E. treat input as items separated by ASCII NUL and terminate
output items with ASCII NUL. This option can be useful in
conjunction with `perl -0' or `find -print0' and `xargs -0' which
do the same in order to reliably handle arbitrary file names (even
those containing blanks or other special characters).
That should make it clear that your example should look like this:
$ printf '%s\0' 1 2 3 | sort -z | xargs -0 -L 1 echo xxx
xxx 1
xxx 2
xxx 3
I've closed this "issue", since the option obviously does work.
If you want to suggest improved --help wording, please do that in
a separate thread so it gets a new number in the bug-tracking system.