|
| 1 | +diff --git a/tests/cut/cut.pl b/tests/cut/cut.pl |
| 2 | +index 1670db02e..ed633792a 100755 |
| 3 | +--- a/tests/cut/cut.pl |
| 4 | ++++ b/tests/cut/cut.pl |
| 5 | +@@ -29,13 +29,15 @@ my $mb_locale = $ENV{LOCALE_FR_UTF8}; |
| 6 | + |
| 7 | + my $prog = 'cut'; |
| 8 | + my $try = "Try '$prog --help' for more information.\n"; |
| 9 | +-my $from_field1 = "$prog: fields are numbered from 1\n$try"; |
| 10 | +-my $from_pos1 = "$prog: byte/character positions are numbered from 1\n$try"; |
| 11 | +-my $inval_fld = "$prog: invalid field range\n$try"; |
| 12 | +-my $inval_pos = "$prog: invalid byte or character range\n$try"; |
| 13 | +-my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try"; |
| 14 | +-my $nofield = "$prog: an input delimiter may be specified only when " . |
| 15 | +- "operating on fields\n$try"; |
| 16 | ++my $from_field1 = "$prog: range '' was invalid: failed to parse range\n"; |
| 17 | ++my $from_field_0 = "$prog: range '0' was invalid: fields and positions are numbered from 1\n"; |
| 18 | ++my $from_field_0_dash = "$prog: range '0-' was invalid: fields and positions are numbered from 1\n"; |
| 19 | ++my $from_field_0_2 = "$prog: range '0-2' was invalid: fields and positions are numbered from 1\n"; |
| 20 | ++my $from_pos1 = "$prog: range '' was invalid: failed to parse range\n"; |
| 21 | ++my $inval_fld = "$prog: range '--' was invalid: failed to parse range\n"; |
| 22 | ++my $inval_pos = "$prog: range '--' was invalid: failed to parse range\n"; |
| 23 | ++my $no_endpoint = "$prog: range '-' was invalid: invalid range with no endpoint\n"; |
| 24 | ++my $nofield = "$prog: invalid input: The '--delimiter' ('-d') option only usable if printing a sequence of fields\n"; |
| 25 | + |
| 26 | + my @Tests = |
| 27 | + ( |
| 28 | +@@ -44,16 +46,16 @@ my @Tests = |
| 29 | + |
| 30 | + # This failed (as it should) even before coreutils-6.9.90, |
| 31 | + # but cut from 6.9.90 produces a more useful diagnostic. |
| 32 | +- ['zero-1', '-b0', {ERR=>$from_pos1}, {EXIT => 1} ], |
| 33 | ++ ['zero-1', '-b0', {ERR=>$from_field_0}, {EXIT => 1} ], |
| 34 | + |
| 35 | + # Up to coreutils-6.9, specifying a range of 0-2 was not an error. |
| 36 | + # It was treated just like "-2". |
| 37 | +- ['zero-2', '-f0-2', {ERR=>$from_field1}, {EXIT => 1} ], |
| 38 | ++ ['zero-2', '-f0-2', {ERR=>$from_field_0_2}, {EXIT => 1} ], |
| 39 | + |
| 40 | + # Up to coreutils-8.20, specifying a range of 0- was not an error. |
| 41 | +- ['zero-3b', '-b0-', {ERR=>$from_pos1}, {EXIT => 1} ], |
| 42 | +- ['zero-3c', '-c0-', {ERR=>$from_pos1}, {EXIT => 1} ], |
| 43 | +- ['zero-3f', '-f0-', {ERR=>$from_field1}, {EXIT => 1} ], |
| 44 | ++ ['zero-3b', '-b0-', {ERR=>$from_field_0_dash}, {EXIT => 1} ], |
| 45 | ++ ['zero-3c', '-c0-', {ERR=>$from_field_0_dash}, {EXIT => 1} ], |
| 46 | ++ ['zero-3f', '-f0-', {ERR=>$from_field_0_dash}, {EXIT => 1} ], |
| 47 | + |
| 48 | + ['1', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}], |
| 49 | + ['2', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}], |
| 50 | +@@ -96,11 +98,10 @@ my @Tests = |
| 51 | + # Errors |
| 52 | + # -s may be used only with -f |
| 53 | + ['y', qw(-s -b4), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, |
| 54 | +- {ERR=>"$prog: suppressing non-delimited lines makes sense\n" |
| 55 | +- . "\tonly when operating on fields\n$try"}], |
| 56 | ++ {ERR=>"$prog: invalid input: The '--only-delimited' ('-s') option only usable if printing a sequence of fields\n"}], |
| 57 | + # You must specify bytes or fields (or chars) |
| 58 | + ['z', '', {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, |
| 59 | +- {ERR=>"$prog: you must specify a list of bytes, characters, or fields\n$try"} |
| 60 | ++ {ERR=>"$prog: invalid usage: expects one of --fields (-f), --chars (-c) or --bytes (-b)\n"} |
| 61 | + ], |
| 62 | + # Empty field list |
| 63 | + ['empty-fl', qw(-f ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, |
| 64 | +@@ -199,7 +200,7 @@ my @Tests = |
| 65 | + |
| 66 | + # None of the following invalid ranges provoked an error up to coreutils-6.9. |
| 67 | + ['inval1', qw(-f 2-0), {IN=>''}, {OUT=>''}, {EXIT=>1}, |
| 68 | +- {ERR=>"$prog: invalid decreasing range\n$try"}], |
| 69 | ++ {ERR=>"$prog: range '2-0' was invalid: fields and positions are numbered from 1\n"}], |
| 70 | + ['inval2', qw(-f -), {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], |
| 71 | + ['inval3', '-f', '4,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}], |
| 72 | + ['inval4', '-f', '1-2,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, |
0 commit comments