Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Feb 2010 01:18:55 -0800
From:      Jeremy Chadwick <freebsd@jdc.parodius.com>
To:        freebsd-stable@freebsd.org
Subject:   Re: numeric sort(1) is broken on -STABLE
Message-ID:  <20100210091854.GA62983@icarus.home.lan>
In-Reply-To: <20100210085814.GE9748@acme.spoerlein.net>
References:  <20100210085814.GE9748@acme.spoerlein.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 10, 2010 at 09:58:14AM +0100, Ulrich Spörlein wrote:
> Hi guys,
> 
> not sure if this is a pilot error, but it seems to me that gnu sort -n
> is broken on at least -STABLE (couldn't test -CURRENT yet).
> 
> It somehow does not manifest when using a simple list and sorting on a
> specific column, but it always happens to me when using it in
> combination with find(1).
> 
> % truncate -s10m a; truncate -s5m b; truncate -s800k c
> % find a b c -ls|sort -nk7,7
>      8       64 -rw-r--r--    1 uqs              wheel            10485760 Feb 10 09:13 a
>     10       64 -rw-r--r--    1 uqs              wheel             5242880 Feb 10 09:13 b
>     12       64 -rw-r--r--    1 uqs              wheel              819200 Feb 10 09:13 c
> % find a b c -ls|sort -gk7,7
>     12       64 -rw-r--r--    1 uqs              wheel              819200 Feb 10 09:13 c
>     10       64 -rw-r--r--    1 uqs              wheel             5242880 Feb 10 09:13 b
>      8       64 -rw-r--r--    1 uqs              wheel            10485760 Feb 10 09:13 a

I can't repro this on 8.0-STABLE or 7.2-STABLE.  /usr/bin/sort on these
machines is what comes with the base system (which is GNU coreutils
sort).

Maybe your issue is related to locale(1) variables?

$ uname -a
FreeBSD icarus.home.lan 8.0-STABLE FreeBSD 8.0-STABLE #0: Sat Jan 16 17:48:04 PST 2010     root@icarus.home.lan:/usr/obj/usr/src/sys/X7SBA_RELENG_8_amd64  amd64
$ truncate -s10m a; truncate -s5m b; truncate -s800k c
$ find a b c -ls | /usr/bin/sort -nk7,7
  3078        1 -rw-------    1 jdc              users              819200 10 Feb 01:11 c
  3077        1 -rw-------    1 jdc              users             5242880 10 Feb 01:11 b
  3076        1 -rw-------    1 jdc              users            10485760 10 Feb 01:11 a
$ find a b c -ls | /usr/bin/sort -gk7,7
  3078        1 -rw-------    1 jdc              users              819200 10 Feb 01:11 c
  3077        1 -rw-------    1 jdc              users             5242880 10 Feb 01:11 b
  3076        1 -rw-------    1 jdc              users            10485760 10 Feb 01:11 a
$ /usr/bin/sort --version
sort (GNU coreutils) 5.3.0-20040812-FreeBSD
Written by Mike Haertel and Paul Eggert.

Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ locale
LANG=en_GB.ISO8859-1
LC_CTYPE="en_GB.ISO8859-1"
LC_COLLATE=C
LC_TIME="en_GB.ISO8859-1"
LC_NUMERIC="en_GB.ISO8859-1"
LC_MONETARY="en_GB.ISO8859-1"
LC_MESSAGES="en_GB.ISO8859-1"
LC_ALL=


$ uname -a
FreeBSD horus.parodius.com 7.2-STABLE FreeBSD 7.2-STABLE #0: Sat Jan  9 07:52:27 PST 2010     root@horus.sc1.parodius.com:/usr/obj/usr/src/sys/PDSMI_PLUS_RELENG_7_amd64  amd64
$ truncate -s10m a; truncate -s5m b; truncate -s800k c
$ find a b c -ls | /usr/bin/sort -nk7,7
406132        1 -rw-------    1 jdc              users              819200 10 Feb 01:13 c
406131        1 -rw-------    1 jdc              users             5242880 10 Feb 01:13 b
406130        1 -rw-------    1 jdc              users            10485760 10 Feb 01:13 a
$ find a b c -ls | /usr/bin/sort -gk7,7
406132        1 -rw-------    1 jdc              users              819200 10 Feb 01:13 c
406131        1 -rw-------    1 jdc              users             5242880 10 Feb 01:13 b
406130        1 -rw-------    1 jdc              users            10485760 10 Feb 01:13 a
$ /usr/bin/sort --version
sort (GNU coreutils) 5.3.0-20040812-FreeBSD
Written by Mike Haertel and Paul Eggert.

Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ locale
LANG=en_GB.ISO8859-1
LC_CTYPE="en_GB.ISO8859-1"
LC_COLLATE=C
LC_TIME="en_GB.ISO8859-1"
LC_NUMERIC="en_GB.ISO8859-1"
LC_MONETARY="en_GB.ISO8859-1"
LC_MESSAGES="en_GB.ISO8859-1"
LC_ALL=

-- 
| Jeremy Chadwick                                   jdc@parodius.com |
| Parodius Networking                       http://www.parodius.com/ |
| UNIX Systems Administrator                  Mountain View, CA, USA |
| Making life hard for others since 1977.              PGP: 4BD6C0CB |




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100210091854.GA62983>