]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: getlimits: output error strings
authorPádraig Brady <P@draigBrady.com>
Sun, 8 Feb 2026 19:34:13 +0000 (19:34 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 10 Feb 2026 12:24:17 +0000 (12:24 +0000)
* src/getlimits.c (main): Iterate over defined errnos,
and output shell compatible error strings.
* tests/Coreutils.pm: Adjust so shell quotes are stripped.

bootstrap.conf
src/getlimits.c
tests/Coreutils.pm

index 07ab7e7e6f13e24b12c418cb436d6601620febd3..1cab8a804999f694f6a844836ad46fa8b0ae861d 100644 (file)
@@ -85,6 +85,7 @@ gnulib_modules="
   dup2
   endian
   environ
+  errno-iter
   error
   euidaccess
   exclude
@@ -274,6 +275,7 @@ gnulib_modules="
   stpcpy
   str_endswith
   strdup-posix
+  strerrorname_np
   stringeq
   strnlen
   strnumcmp
index 6113988a255bfc28fbb3fcd3b793b73f2ad69e0d..86224a3d0b3cb6ad7065d7e45ea6511d457ad396 100644 (file)
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 #include <float.h>
 
+#include "errno-iter.h"
 #include "ftoastr.h"
 #include "system.h"
 #include "ioblksize.h"
@@ -129,6 +130,16 @@ PRINT_FLOATTYPE (print_FLT, float, ftoastr, FLT_BUFSIZE_BOUND)
 PRINT_FLOATTYPE (print_DBL, double, dtoastr, DBL_BUFSIZE_BOUND)
 PRINT_FLOATTYPE (print_LDBL, long double, ldtoastr, LDBL_BUFSIZE_BOUND)
 
+static int
+print_errno (void *name, int e)
+{
+  char const *err_name = name ? name : strerrorname_np (e);
+  if (err_name)
+    printf ("%s=%s\n", err_name,
+            quotearg_style (shell_escape_quoting_style, strerror (e)));
+  return 0;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -192,5 +203,21 @@ main (int argc, char **argv)
   printf ("SIGRTMAX=%jd\n", (intmax_t) SIGRTMAX);
   printf ("IO_BUFSIZE=%ju\n", (uintmax_t) IO_BUFSIZE);
 
+  /* Errnos */
+  errno_iterate (print_errno, NULL);
+  /* Common errno aliases */
+#if defined ENOTEMPTY && ENOTEMPTY == EEXIST
+  print_errno ((char*)"ENOTEMPTY", EEXIST);
+#endif
+#if defined ENOTSUP && ENOTSUP == EOPNOTSUPP
+  print_errno ((char*)"ENOTSUP", EOPNOTSUPP);
+#endif
+#if defined EWOULDBLOCK && EWOULDBLOCK == EAGAIN
+  print_errno ((char*)"EWOULDBLOCK", EAGAIN);
+#endif
+#if defined EDEADLOCK && EDEADLOCK == EDEADLK
+  print_errno ((char*)"EDEADLOCK", EDEADLK);
+#endif
+
   return EXIT_SUCCESS;
 }
index 393a8c8dfc10152d9b9d397d1312ceb25caf102c..376609d73191435f41725cb1fdc59b39c93d65ae 100644 (file)
@@ -21,6 +21,7 @@ use vars qw($VERSION @ISA @EXPORT);
 
 use FileHandle;
 use File::Compare qw(compare);
+use Text::ParseWords qw(shellwords);
 
 @ISA = qw(Exporter);
 ($VERSION = '$Revision: 1.5 $ ') =~ tr/[0-9].//cd;
@@ -213,7 +214,12 @@ sub getlimits()
 {
   my $NV;
   open $NV, "getlimits |" or die "Error running getlimits\n";
-  my %limits = map {split /=|\n/} <$NV>;
+  my %limits = map {
+    chomp;
+    my ($k, $v) = split /=/, $_, 2;
+    $v = (shellwords($v))[0] if defined $v;
+    ($k, $v)
+  } <$NV>;
   return \%limits;
 }