From 1482f730b47d1abad3d75199dde5237d9bf16a4a Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Sun, 18 Nov 2012 22:20:16 +0100 Subject: 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 . --- src/cut.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/cut.c b/src/cut.c index 87380ac66..2a571483a 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; } -- cgit v1.2.3-54-g00ecf