summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2012-11-18 22:20:16 +0100
committerBernhard Voelker <mail@bernhard-voelker.de>2012-11-19 00:08:38 +0100
commit1482f730b47d1abad3d75199dde5237d9bf16a4a (patch)
tree857b97da89b2fd93bfe304ad530f104bd42aec21 /tests/misc
parent6a5843d92fca254f0b27c3fee88a11840034ce32 (diff)
downloadcoreutils-1482f730b47d1abad3d75199dde5237d9bf16a4a.tar.xz
cut: do not accept the invalid range 0-
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>.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/cut.pl5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index 0ce051ab0..cd5655569 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"}],