GNU bug report logs -
#12903
"cut -b 0-" is supposed to be invalid
Previous Next
Reported by: "Marcel Böhme" <hawkie <at> web.de>
Date: Fri, 16 Nov 2012 07:30:01 UTC
Severity: normal
Done: Bernhard Voelker <mail <at> bernhard-voelker.de>
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 12903 in the body.
You can then email your comments to 12903 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#12903
; Package
coreutils
.
(Fri, 16 Nov 2012 07:30:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Marcel Böhme" <hawkie <at> web.de>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 16 Nov 2012 07:30:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12903
; Package
coreutils
.
(Fri, 16 Nov 2012 20:22:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 12903 <at> debbugs.gnu.org (full text, mbox):
Hi Marcel,
On 11/16/2012 07:35 AM, Marcel Böhme wrote:
> Hi,
> The command "echo 12345 | cut -b 0-" prints an empty line while it
> should fail with "fields and positions are numbered from 1" according
> to this specification "cut: diagnose a range starting with 0 (-f 0-2)
> as invalid".
> Can you confirm this is an incomplete bugfix made on 2007-05-22?
I'd say yes.
Here's a proposed fix.
Have a nice day,
Berny
From 26c6ab75498c4ec6710828799f5452c8243feda1 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail <at> bernhard-voelker.de>
Date: Fri, 16 Nov 2012 21:12:16 +0100
Subject: [PATCH] cut: do not accept the range 0-
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* src/cut.c (set_fields): Add a diagnostic for the invalid open
range which start with Zero, i.e., the range 0-.
* tests/misc/cut.pl: Add a test to ensure the range 0- fails.
* Mention the fix.
Reported by Marcel Böhme.
---
NEWS | 3 +++
src/cut.c | 3 +++
tests/misc/cut.pl | 3 +++
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
index db6a207..9239943 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,9 @@ GNU coreutils NEWS -*- outline -*-
** Bug fixes
+ cut now does not accept the range 0- any longer.
+ [This bug was present in "the beginning".]
+
pr -n no longer crashes when passed values >= 32. Also line numbers are
consistently padded with spaces, rather than with zeros for certain widths.
[bug introduced in TEXTUTILS-1_22i]
diff --git a/src/cut.c b/src/cut.c
index 87380ac..2a57148 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -369,6 +369,9 @@ set_fields (const char *fieldstr)
dash_found = true;
fieldstr++;
+ if (lhs_specified && !value)
+ FATAL_ERROR (_("fields and positions are numbered from 1"));
+
initial = (lhs_specified ? value : 1);
value = 0;
}
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index 0ce051a..43a5108 100755
--- a/tests/misc/cut.pl
+++ b/tests/misc/cut.pl
@@ -46,6 +46,9 @@ my @Tests =
# It was treated just like "-2".
['zero-2', '-f0-2', {ERR=>$from_1}, {EXIT => 1} ],
+ # Up to coreutils-8.20, specifying a range of 0- was not an error.
+ ['zero-3', '-b0-', {ERR=>$from_1}, {EXIT => 1} ],
+
['1', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
['2', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
['3', qw(-d: -f2-), {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}],
--
1.7.7
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12903
; Package
coreutils
.
(Fri, 16 Nov 2012 22:25:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 12903 <at> debbugs.gnu.org (full text, mbox):
Bernhard Voelker wrote:
> Hi Marcel,
>
> On 11/16/2012 07:35 AM, Marcel Böhme wrote:
>> Hi,
>> The command "echo 12345 | cut -b 0-" prints an empty line while it
>> should fail with "fields and positions are numbered from 1" according
>> to this specification "cut: diagnose a range starting with 0 (-f 0-2)
>> as invalid".
>> Can you confirm this is an incomplete bugfix made on 2007-05-22?
>
> I'd say yes.
> Here's a proposed fix.
...
> Subject: [PATCH] cut: do not accept the range 0-
>
> * src/cut.c (set_fields): Add a diagnostic for the invalid open
> range which start with Zero, i.e., the range 0-.
> * tests/misc/cut.pl: Add a test to ensure the range 0- fails.
> * Mention the fix.
>
> Reported by Marcel Böhme.
Thank you!
That change looks fine, at first glance,
but please amend the log to mention the bug number URL.
Also, technically this is a bug, so please mention the
fix in NEWS.
Send a request in savannah, and tonight or tomorrow I'll
give you push-after-approval access.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12903
; Package
coreutils
.
(Sun, 18 Nov 2012 21:30:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 12903 <at> debbugs.gnu.org (full text, mbox):
On 11/16/2012 11:23 PM, Jim Meyering wrote:
> Bernhard Voelker wrote:
>
>> Hi Marcel,
>>
>> On 11/16/2012 07:35 AM, Marcel Böhme wrote:
>>> Hi,
>>> The command "echo 12345 | cut -b 0-" prints an empty line while it
>>> should fail with "fields and positions are numbered from 1" according
>>> to this specification "cut: diagnose a range starting with 0 (-f 0-2)
>>> as invalid".
>>> Can you confirm this is an incomplete bugfix made on 2007-05-22?
>>
>> I'd say yes.
>> Here's a proposed fix.
> ...
> Thank you!
> That change looks fine, at first glance,
> but please amend the log to mention the bug number URL.
> Also, technically this is a bug, so please mention the
> fix in NEWS.
Thanks for the review.
I amended with updated NEWS and also improved the test to include
both the field option -f and the position options -b and -c,
plus mentioned the bug URL in the commit message.
Have a nice day,
Berny
From 10fc244ac8e4f24eb330eae110fadc0b7d78cf8d Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail <at> bernhard-voelker.de>
Date: Sun, 18 Nov 2012 22:20:16 +0100
Subject: [PATCH] cut: do not accept the invalid range 0-
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The command "echo 12345 | cut -b 0-" prints an empty line while
it should fail with "fields and positions are numbered from 1".
* src/cut.c (set_fields): Add a diagnostic for the invalid open
range which starts with Zero, i.e., the range 0-.
* tests/misc/cut.pl: Add tests to ensure the range 0- fails for
fields (-f) and for positions (-b, -c).
* NEWS: Mention the fix.
Reported by Marcel Böhme in <http://bugs.gnu.org/12903>.
---
NEWS | 4 ++++
src/cut.c | 3 +++
tests/misc/cut.pl | 5 +++++
3 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
index db6a207..e4a284c 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ GNU coreutils NEWS -*- outline -*-
** Bug fixes
+ cut no longer accepts the invalid range 0-, which made it print empty lines.
+ Instead, cut now fails and emits an appropriate diagnostic.
+ [This bug was present in "the beginning".]
+
pr -n no longer crashes when passed values >= 32. Also line numbers are
consistently padded with spaces, rather than with zeros for certain widths.
[bug introduced in TEXTUTILS-1_22i]
diff --git a/src/cut.c b/src/cut.c
index 87380ac..2a57148 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -369,6 +369,9 @@ set_fields (const char *fieldstr)
dash_found = true;
fieldstr++;
+ if (lhs_specified && !value)
+ FATAL_ERROR (_("fields and positions are numbered from 1"));
+
initial = (lhs_specified ? value : 1);
value = 0;
}
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index 0ce051a..cd56555 100755
--- a/tests/misc/cut.pl
+++ b/tests/misc/cut.pl
@@ -46,6 +46,11 @@ my @Tests =
# It was treated just like "-2".
['zero-2', '-f0-2', {ERR=>$from_1}, {EXIT => 1} ],
+ # Up to coreutils-8.20, specifying a range of 0- was not an error.
+ ['zero-3b', '-b0-', {ERR=>$from_1}, {EXIT => 1} ],
+ ['zero-3c', '-c0-', {ERR=>$from_1}, {EXIT => 1} ],
+ ['zero-3f', '-f0-', {ERR=>$from_1}, {EXIT => 1} ],
+
['1', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
['2', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
['3', qw(-d: -f2-), {IN=>"a:b:c\n"}, {OUT=>"b:c\n"}],
--
1.7.7
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12903
; Package
coreutils
.
(Mon, 19 Nov 2012 01:07:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 12903 <at> debbugs.gnu.org (full text, mbox):
Bernhard Voelker wrote:
> On 11/16/2012 11:23 PM, Jim Meyering wrote:
>> Bernhard Voelker wrote:
>>
>>> Hi Marcel,
>>>
>>> On 11/16/2012 07:35 AM, Marcel Böhme wrote:
>>>> Hi,
>>>> The command "echo 12345 | cut -b 0-" prints an empty line while it
>>>> should fail with "fields and positions are numbered from 1" according
>>>> to this specification "cut: diagnose a range starting with 0 (-f 0-2)
>>>> as invalid".
>>>> Can you confirm this is an incomplete bugfix made on 2007-05-22?
>>>
>>> I'd say yes.
>>> Here's a proposed fix.
>> ...
>
>> Thank you!
>> That change looks fine, at first glance,
>> but please amend the log to mention the bug number URL.
>> Also, technically this is a bug, so please mention the
>> fix in NEWS.
>
> Thanks for the review.
>
> I amended with updated NEWS and also improved the test to include
> both the field option -f and the position options -b and -c,
> plus mentioned the bug URL in the commit message.
>
> Have a nice day,
> Berny
>
>
>>From 10fc244ac8e4f24eb330eae110fadc0b7d78cf8d Mon Sep 17 00:00:00 2001
> From: Bernhard Voelker <mail <at> bernhard-voelker.de>
> Date: Sun, 18 Nov 2012 22:20:16 +0100
> Subject: [PATCH] cut: do not accept the invalid range 0-
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> The command "echo 12345 | cut -b 0-" prints an empty line while
> it should fail with "fields and positions are numbered from 1".
>
> * src/cut.c (set_fields): Add a diagnostic for the invalid open
> range which starts with Zero, i.e., the range 0-.
> * tests/misc/cut.pl: Add tests to ensure the range 0- fails for
> fields (-f) and for positions (-b, -c).
> * NEWS: Mention the fix.
>
> Reported by Marcel Böhme in <http://bugs.gnu.org/12903>.
Looks perfect, now. You're welcome to push it.
Thanks!
Reply sent
to
Bernhard Voelker <mail <at> bernhard-voelker.de>
:
You have taken responsibility.
(Mon, 19 Nov 2012 21:26:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Marcel Böhme" <hawkie <at> web.de>
:
bug acknowledged by developer.
(Mon, 19 Nov 2012 21:26:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 12903-done <at> debbugs.gnu.org (full text, mbox):
On 11/19/2012 02:05 AM, Jim Meyering wrote:
> You're welcome to push it.
Thanks, pushed:
http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=1482f730b47d1abad3d75199dde5237d9bf16a4a
Marking as done.
Have a nice day,
Berny
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 18 Dec 2012 12:24:02 GMT)
Full text and
rfc822 format available.
This bug report was last modified 11 years and 141 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.