GNU bug report logs - #8070
cut command

Previous Next

Package: coreutils;

Reported by: George Gallen <ggallen <at> wyanokegroup.com>

Date: Thu, 17 Feb 2011 22:16:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eric Blake <eblake <at> redhat.com>
To: George Gallen <ggallen <at> wyanokegroup.com>
Cc: 8070 <at> debbugs.gnu.org
Subject: bug#8070: cut command
Date: Thu, 17 Feb 2011 15:46:07 -0700
[Message part 1 (text/plain, inline)]
On 02/17/2011 03:19 PM, George Gallen wrote:
> I'm not sure whether this is a bug or not.
> 
> On Redhat Enterprise Linux, the cut command will accept the following " cut -c0-5 " (Cut ver 5.97)
> On Fedora it will not accept the 0, it must be " cut -c1-5 " (cut ver 8.5)

Thanks for the report.

POSIX states this:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cut.html

"The application shall ensure that the option-argument list (see options
-b, -c, and -f below) is a <comma>-separated list or <blank>-separated
list of positive numbers and ranges. Ranges can be in three forms. The
first is two positive numbers separated by a <hyphen> ( low- high),
which represents all fields from the first number to the second number.
The second is a positive number preceded by a <hyphen> (- high), which
represents all fields from field number 1 to that number. The third is a
positive number followed by a <hyphen> ( low-), which represents that
number to the last field, inclusive."

0 is not a positive integer, it lends itself to confusion (is the first
character 0-based or 1-based?), and coreutils had not documented it as
an explicit extension, therefore this functionality was removed as a bug
fix in 6.9.90:

http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=a6a447fc

And NEWS backs this up:

  cut now diagnoses a range starting with zero (e.g., -f 0-2) as invalid;
  before, it would treat it as if it started with 1 (-f 1-2).

> I was able to copy the cut command from RHEL to Fedora 14 and it works fine. What am losing
>   between these two versions?

Your script was not POSIX compliant to begin with - it was pure luck
that it worked for you in older installations.

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

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

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

Previous Next


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