GNU bug report logs - #8442
coreutils 5.90 (2005-09-29) drops support for +N option usage

Previous Next

Package: coreutils;

Reported by: "Jyotin Patel" <Jyotin.Patel <at> inttra.com>

Date: Thu, 7 Apr 2011 19:56:02 UTC

Severity: normal

Tags: moreinfo, notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8442 in the body.
You can then email your comments to 8442 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8442; Package coreutils. (Thu, 07 Apr 2011 19:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Jyotin Patel" <Jyotin.Patel <at> inttra.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 07 Apr 2011 19:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Jyotin Patel" <Jyotin.Patel <at> inttra.com>
To: <bug-coreutils <at> gnu.org>
Subject: sort command in Redhat 5 does not work
Date: Thu, 7 Apr 2011 15:40:36 -0400
[Message part 1 (text/plain, inline)]
[root <at> cnprodftp02 root]# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 3 (Taroon Update 5)
[root <at> cnprodftp02 root]# sort

[root <at> cnprodftp02 root]# set -o vi
 
[root <at> cnprodftp02 root]# grep prftp /etc/passwd | sort -n +2 -t':' |
head -2
xmit:x:150:204::/prftp/forwarder:/bin/bash
anl:x:213:206:test user:/prftp/carriers/anl:/sbin/nologin
 



[root <at> cnprodftp02 root]# uname -a
Linux cnprodftp02 2.4.21-32.0.1.ELsmp #1 SMP Tue May 17 17:52:23 EDT
2005 i686 i686 i386 GNU/Linux



Sort does not work on REdhat-AS5 ; it used to work on Redhat AS-3

[root <at> cnprodedi01 mail]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.6 (Tikanga)
[root <at> cnprodedi01 mail]# grep prftp /etc/passwd | sort -n +2 -t':' |
head -2
sort: open failed: +2: No such file or directory
[root <at> cnprodedi01 mail]#


[root <at> cnprodftp02 bin]# uname -a
Linux cnprodftp02 2.6.18-238.5.1.el5 #1 SMP Mon Feb 21 05:52:39 EST 2011
x86_64 x86_64 x86_64 GNU/Linux


Thanks.
Jay Patel
Systems Administrator
INTTRA
+1 973.265.2263 Office 
+1 973.641.0510 Mobile 
+1 973.263.5969 Fax
www.inttra.com <http://www.inttra.com/> 
This e-mail and any attachments thereto are intended only for use by the addressee(s) named herein and may contain proprietary and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify Postmaster <at> INTTRA.com and permanently delete the original, any attachments, any copies thereof, and any printouts thereof.
[Message part 2 (text/html, inline)]

Reply sent to Eric Blake <eblake <at> redhat.com>:
You have taken responsibility. (Thu, 07 Apr 2011 21:14:01 GMT) Full text and rfc822 format available.

Notification sent to "Jyotin Patel" <Jyotin.Patel <at> inttra.com>:
bug acknowledged by developer. (Thu, 07 Apr 2011 21:14:02 GMT) Full text and rfc822 format available.

Message #10 received at 8442-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Jyotin Patel <Jyotin.Patel <at> inttra.com>
Cc: 8442-done <at> debbugs.gnu.org
Subject: Re: bug#8442: sort command in Redhat 5 does not work
Date: Thu, 07 Apr 2011 15:12:51 -0600
[Message part 1 (text/plain, inline)]
On 04/07/2011 01:40 PM, Jyotin Patel wrote:
> 
> Sort does not work on REdhat-AS5 ; it used to work on Redhat AS-3

> [root <at> cnprodedi01 mail]# cat /etc/redhat-release
> Red Hat Enterprise Linux Server release 5.6 (Tikanga)
> [root <at> cnprodedi01 mail]# grep prftp /etc/passwd | sort -n +2 -t':' |
> head -2
> sort: open failed: +2: No such file or directory

Thanks for the report.  However, this is not a bug in sort, but a
misunderstanding on your part about changes to sort syntax as POSIX has
evolved over the years.  From the NEWS file:

  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


See also 'info coreutils standards' for information on how to set
_POSIX2_VERSION=199209 for the behavior you were expecting.

But in general, the old +2 syntax should be converted to the newer
POSIX-compliant -k3 (or even the safer -k3,3) instead.  Newer coreutils
(the latest is 8.10) added a --debug option, to help in that:

$ echo hi | _POSIX2_VERSION=199209 sort -n +2 -t: --debug
sort: using `en_US.UTF-8' sorting rules
sort: obsolescent key `+2' used; consider `-k 3' instead
sort: key 1 is numeric and spans multiple fields
hi
  ^ no match for key
__


-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8442; Package coreutils. (Thu, 07 Apr 2011 21:20:03 GMT) Full text and rfc822 format available.

Message #13 received at 8442 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: Jyotin Patel <Jyotin.Patel <at> inttra.com>
Cc: 8442 <at> debbugs.gnu.org
Subject: Re: bug#8442: sort command in Redhat 5 does not work
Date: Thu, 7 Apr 2011 15:19:48 -0600
retitle 8442 coreutils 5.90 (2005-09-29) drops support for +N option usage
tags 8442 + moreinfo notabug
thanks

Jyotin Patel wrote:
> [root <at> cnprodftp02 root]# grep prftp /etc/passwd | sort -n +2 -t':' | head -2
> xmit:x:150:204::/prftp/forwarder:/bin/bash
> anl:x:213:206:test user:/prftp/carriers/anl:/sbin/nologin

You are using obsolete options that are not portable.  The +2 and -2
options are problematic.  Don't use them.

> Sort does not work on REdhat-AS5 ; it used to work on Redhat AS-3
> 
> [root <at> cnprodedi01 mail]# cat /etc/redhat-release
> Red Hat Enterprise Linux Server release 5.6 (Tikanga)
> [root <at> cnprodedi01 mail]# grep prftp /etc/passwd | sort -n +2 -t':' | head -2
> sort: open failed: +2: No such file or directory

That is correct.  This is documented in the NEWS file.

    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
       tail +4           tail -n +4           tail ./+4
       tail - f          tail f               [see (*) below]
       tail -c 4         tail -c 10 ./4       tail -c4
       touch 12312359 f  touch -t 12312359 f  touch ./12312359 f
       uniq +4           uniq -s 4            uniq ./+4
     
       (*) "tail - f" does not conform to POSIX 1003.1-2001; to read
       standard input and then "f", use the command "tail -- - f".
     
     These changes are in response to decisions taken in the January 2005
     Austin Group standardization meeting.  For more details, please see
     "Utility Syntax Guidelines" in the Minutes of the January 2005
     Meeting http://www.opengroup.org/austin/docs/austin_239.html.

Also the coreutils info manual has the following documentation.

    The gnu utilities normally conform to the version of POSIX that is
    standard for your system.  To cause them to conform to a different
    version of POSIX, define the _POSIX2_VERSION environment variable
    to a value of the form yyyymm specifying the year and month the
    standard was adopted.  Two values are currently supported for
    _POSIX2_VERSION: ‘199209’ stands for POSIX 1003.2-1992, and
    ‘200112’ stands for POSIX 1003.1-2001.  For example, if you have a
    newer system but are running software that assumes an older
    version of POSIX and uses ‘sort +1’ or ‘tail +10’, you can work
    around any compatibility problems by setting
    ‘_POSIX2_VERSION=199209’ in your environment.

See also this FAQ entry:

  http://www.gnu.org/software/coreutils/faq/#Old-tail-plus-N-syntax-now-fails

Instead of:

> grep prftp /etc/passwd | sort -n +2 -t':' | head -2

Use something like this instead:

  $ sort -t : -k 3n,3 /etc/passwd | head -n 20

Bob




Changed bug title to 'coreutils 5.90 (2005-09-29) drops support for +N option usage' from 'sort command in Redhat 5 does not work' Request was from Bob Proulx <bob <at> proulx.com> to control <at> debbugs.gnu.org. (Thu, 07 Apr 2011 21:20:04 GMT) Full text and rfc822 format available.

Added tag(s) notabug and moreinfo. Request was from Bob Proulx <bob <at> proulx.com> to control <at> debbugs.gnu.org. (Thu, 07 Apr 2011 21:20:04 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 06 May 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 54 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.