]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: cut: ensure multi-byte delimiter is rejected in uni-byte locales
authorPádraig Brady <P@draigBrady.com>
Fri, 20 Mar 2026 19:25:59 +0000 (19:25 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 5 Apr 2026 12:15:56 +0000 (13:15 +0100)
tests/cut/cut.pl: Check the appropriate diagnostic is presented.

tests/cut/cut.pl

index 186142e239cbe0e9872aa6c5918f1e1af7eac2a2..8c3c06653ef4754840df8ed68994a3d0310627c2 100755 (executable)
@@ -37,6 +37,19 @@ my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try";
 my $nofield = "$prog: an input delimiter makes sense\n\tonly when " .
               "operating on fields\n$try";
 my $mutual_dw = "$prog: -d and -w are mutually exclusive\n$try";
+my $single_char = "$prog: the delimiter must be a single character\n$try";
+my $single_byte_locale = 'C';
+
+{
+  my $codeset = qx(LC_ALL=C locale charmap 2>/dev/null);
+  chomp $codeset;
+  if ($codeset eq 'UTF-8')
+    {
+      my $fr_locale = $ENV{LOCALE_FR};
+      $single_byte_locale
+        = defined $fr_locale && $fr_locale ne 'none' ? $fr_locale : undef;
+    }
+}
 
 my @Tests =
  (
@@ -329,6 +342,12 @@ if ($mb_locale ne 'C')
        {ENV => "LC_ALL=$mb_locale"}];
   }
 
+defined $single_byte_locale
+  and push @Tests,
+    ['mb-delim-C', '-d', "\xc3\xa9", '-f1',
+     {EXIT=>1}, {ERR=>$single_char},
+     {ENV => "LC_ALL=$single_byte_locale"}];
+
 
 @Tests = triple_test \@Tests;