Change in cut behavior breaks scripts

Bug #211262 reported by agent 8131
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Invalid
Undecided
Unassigned
Hardy
Won't Fix
Undecided
Unassigned
xen-common (Ubuntu)
Expired
Low
Unassigned
Hardy
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: coreutils

When given a 0 field in cut it used to just treat it as 1; now it reports an error.

Old behavior (Gutsy):

$ echo foobar | cut -c0-3
foo

New behavior (Hardy):

$ echo foobar | cut -c0-3
cut: fields and positions are numbered from 1
Try `cut --help' for more information.
bash: echo: write error: Broken pipe

I wouldn't say this is a bug but it will cause problems elsewhere. I noticed the problem in the /etc/init.d/xendomains script. Treating 0 as 1 is really harmless so leaving the old behavior doesn't seem to present a problem. If the new behavior remains it might be worth trying to find places where it causes problems and fix them prior to the release of Hardy.

Revision history for this message
Steve Langasek (vorlon) wrote :

Not a bug in coreutils, marking as such.

Agreed that this should be fixed in any affected scripts for hardy; which should be a relatively small number, so far only the xen scripts seem to assume a 0 index is valid.

Changed in coreutils:
status: New → Won't Fix
status: New → Invalid
Revision history for this message
Mike Perry (mike.perry) wrote :

I agree, this change in behavior will affect third party scripts that were written for generic flavors of Linux. Although the old behavior may not have been "correct" it was accepted and widely used. I'd also like to point out that the behavior of -f was changed as well.

This was discovered while testing a Sybase ASA install on Hardy. The Sybase installation script uses the following to detect diskspace:

df -kP | sed 1d | tr -s ' ' | cut -d" " -f,4

Which in Hardy would return something like:
53217452
1552976
1553244
1553124
1553124
1553244
124355

Running the same command in Hardy causes the following error:
cut: fields and positions are numbered from 1
Try `cut --help` for more information.

I would like to see this bug reconsidered, as there are no alternatives for third party scripts. In fact changing changing the script to "-f1,4" is a different behavior than "-f,4". The cut command should have some way of restoring backwards compatibility in some manner, be it an environment variable, /etc/alternatives, or something else.

Revision history for this message
Mike Perry (mike.perry) wrote :

My note above should by qualified by stating that behavior obtained with "-f,4" in previous versions of cut are the same as "-f4" in old and new versions of cut.

Daniel T Chen (crimsun)
Changed in xen-common:
importance: Undecided → Low
Revision history for this message
Thomas Hotz (thotz-deactivatedaccount) wrote :

I cannot reproduce this.

Is this still an issue for you? Which Ubuntu version do you use? Thank you for telling us!

Changed in xen-common (Ubuntu Hardy):
status: New → Invalid
Changed in xen-common (Ubuntu):
status: New → Confirmed
status: Confirmed → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for xen-common (Ubuntu) because there has been no activity for 60 days.]

Changed in xen-common (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.