On 08/02/2026 22:52, Collin Funk wrote:
In general this looks like a great change. It will save us a lot of time remember which error strings are different on each platform.Just one comment after reviewing the patch.+ /* Errnos */ + for (int e = 1; e < 256; e++) + { + char const *err_name = strerrorname_np (e); + if (err_name) + printf ("%s=%s\n", err_name, + quotearg_style (shell_escape_quoting_style, strerror (e))); + }I think strerror is okay here, since we set LC_ALL=C in tests/lang-default which is sourced in TESTS_ENVIRONMENT? We don't want translated strings of course since they may not exist or change between platforms (even if they have the same string in English).
It's probably best to leave as the translated string for flexibility. BTW I verified the shell parsing works fine for the single quotes within fr_FR translated messages.
Second, you might want to use the 'errno-iter' module from Gnulib. It looks a bit safer to me than using a loop over integers 1 - 255.
Oh good call. Also we should output common errno aliases. I'll apply the attached later. cheers, Padraig
From afd2e534f3ec8c498bdc787bc4f390fe723cb870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]> Date: Sun, 8 Feb 2026 19:34:13 +0000 Subject: [PATCH] tests: getlimits: output error strings * 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 | 2 ++ src/getlimits.c | 27 +++++++++++++++++++++++++++ tests/Coreutils.pm | 8 +++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf index 07ab7e7e6..1cab8a804 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -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 diff --git a/src/getlimits.c b/src/getlimits.c index 6113988a2..86224a3d0 100644 --- a/src/getlimits.c +++ b/src/getlimits.c @@ -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; } diff --git a/tests/Coreutils.pm b/tests/Coreutils.pm index 393a8c8df..376609d73 100644 --- a/tests/Coreutils.pm +++ b/tests/Coreutils.pm @@ -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; } -- 2.52.0
