emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-bug-tracker] bug#8081: closed (sort -z and shuf -z don't work)


From: GNU bug Tracking System
Subject: [Emacs-bug-tracker] bug#8081: closed (sort -z and shuf -z don't work)
Date: Sat, 19 Feb 2011 13:59:02 +0000

Your message dated Sat, 19 Feb 2011 14:58:36 +0100
with message-id <address@hidden>
and subject line Re: bug#8081: sort -z and shuf -z don't work
has caused the GNU bug report #8081,
regarding sort -z and shuf -z don't work
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
8081: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8081
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: sort -z and shuf -z don't work Date: Sat, 19 Feb 2011 08:24:45 +0100 User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101210 Thunderbird/3.1.7
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

Please note that sort's input stream is not zero-terminated. "tac"
doesn't support this option. sort(1) doesn't mention such an
assumption, either. Obviously there are many more tools with
this restriction.

Instead of mixing input and output options I would suggest to
introduce 2 new tools "nl2zero" and "zero2nl". Sample implementation:

% alias nl2zero='tr \\n \\0'
% alias zero2nl='tr \\0 \\n'
% ( echo 1; echo 2; echo 3 ) | tac | nl2zero | sort -z | xargs -0 -L 1 echo xxx
xxx 1
xxx 2
xxx 3


Regards

Harri
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1fcD0ACgkQUTlbRTxpHjd/6wCfTWOs/o3AYk2205IRJU0b5hjj
PyMAnRChOFwIdsKps9wyJwjGs7Cwd7ba
=Kab0
-----END PGP SIGNATURE-----



--- End Message ---
--- Begin Message --- Subject: Re: 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.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]