bug-coreutils
[Top][All Lists]
Advanced

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

bug#7305: sort command not working in version 5.5 as it did in 4.7


From: Eric Blake
Subject: bug#7305: sort command not working in version 5.5 as it did in 4.7
Date: Fri, 29 Oct 2010 15:15:12 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.4

On 10/29/2010 02:12 PM, Michael Warnock wrote:
> Hi -- We are testing RHEL 5.5 and we noticed that the below command is not
> working in 5.5 -- It works in 4.7

The version of your distro is not quite as important as the version of
sort itself (via 'sort --version').

> I did notice that the version of the sort command is different between
> versions, but I didn't expect it to break.
> 
> Am I just using it incorrectly in 5.5 or could this be a bug.

Thanks for the report.  You surmised correctly - it was your usage
pattern at fault and not a bug in sort.

> sort +8 | grep  " 1 "
> 
> sort: open failed: +8: No such file or directory

From the NEWS file:

* Major changes in release 6.0 (2006-08-15) [unstable]
...
  sort now supports obsolete usages like "sort +1 -2" unless
  POSIXLY_CORRECT is set.  However, when conforming to POSIX
  1003.1-2001 "sort +1" still sorts the file named "+1".
...
* Major changes in release 5.90 (2005-09-29) [unstable]
...
  A few usages still have behavior that depends on which POSIX standard is
  being conformed to, and portable applications should beware these
  problematic usages.  These include:

    Problematic       Standard-conforming replacement, depending on
       usage            whether you prefer the behavior of:
                      POSIX 1003.2-1992    POSIX 1003.1-2001
    sort +4           sort -k 5            sort ./+4


Also, read 'info coreutils standards' to learn more about the
environment variable _POSIX2_VERSION, which you can set to 199209 if you
absolutely must have the behavior of the older standard instead of
modernizing your script (POSIX 2001 and POSIX 2008 are much more widely
supported these days).

By the way, the latest stable release of coreutils, 8.6, includes a
nifty new feature 'sort --debug' that can help you diagnose problems
with sort usage:

$ echo a b c d | sort --debug +2
sort: using `en_US.UTF-8' sorting rules
sort: open failed: +2: No such file or directory
$ echo a b c d | _POSIX2_VERSION=199209 sort --debug +2
sort: using `en_US.UTF-8' sorting rules
sort: obsolescent key `+2' used; consider `-k 3' instead
sort: leading blanks are significant in key 1; consider also specifying `b'
a b c d
   ____
_______
$ echo a b | _POSIX2_VERSION=199209 LC_ALL=C sort --debug +2
sort: using simple byte comparison
sort: obsolescent key `+2' used; consider `-k 3' instead
a b c d
   ____
_______

That said, we could probably improve 'sort --debug' to detect the
obsolescent 'sort +n' format and issue a warning in that situation.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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