diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | src/cut.c | 6 | ||||
-rwxr-xr-x | tests/misc/cut.pl | 3 |
3 files changed, 11 insertions, 2 deletions
@@ -14,6 +14,10 @@ GNU coreutils NEWS -*- outline -*- Instead, cut now fails and emits an appropriate diagnostic. [This bug was present in "the beginning".] + cut now handles overlapping to-EOL ranges properly. Before, it would + interpret "-b2-,3-" like "-b3-". Now it's treated like "-b2-". + [This bug was present in "the beginning".] + install -m M SOURCE DEST no longer has a race condition where DEST's permissions are temporarily derived from SOURCE instead of from M. @@ -391,8 +391,10 @@ set_fields (const char *fieldstr) In any case, 'initial' contains the start of the range. */ if (!rhs_specified) { - /* 'n-'. From 'initial' to end of line. */ - eol_range_start = initial; + /* 'n-'. From 'initial' to end of line. If we've already + seen an M- range, ignore subsequent N- unless N < M. */ + if (eol_range_start == 0 || initial < eol_range_start) + eol_range_start = initial; field_found = true; } else diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl index cd5655569..cb4781a7d 100755 --- a/tests/misc/cut.pl +++ b/tests/misc/cut.pl @@ -163,6 +163,9 @@ my @Tests = ['big-unbounded-b', '--output-d=:', '-b1234567890-', {IN=>''}, {OUT=>''}], ['big-unbounded-c', '--output-d=:', '-c1234567890-', {IN=>''}, {OUT=>''}], ['big-unbounded-f', '--output-d=:', '-f1234567890-', {IN=>''}, {OUT=>''}], + + ['overlapping-unbounded-1', '-b3-,2-', {IN=>"1234\n"}, {OUT=>"234\n"}], + ['overlapping-unbounded-2', '-b2-,3-', {IN=>"1234\n"}, {OUT=>"234\n"}], ); if ($mb_locale ne 'C') |