xstrtol-error: Use quote() before print command line arguments.
Collin Funk <[email protected]>
| Newsgroups | gmane.comp.lib.gnulib.bugs |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
I noticed the following inconsistent error message in GNU coreutils:
$ od -S $'\t'
od: invalid -S argument ' '
For clarity, would would usually escape that, e.g., like this:
$ uname $'\t'
uname: extra operand ‘\t’
Try 'uname --help' for more information.
The cause of this inconsistency is the xstrtol-error module, which does
not use quote().
I am proposing the attached patch to fix this inconsistency. However,
since it affects other packages, I felt it would be rude to make this
change without asking for approval. Here is the list of affected
packages from the lists in maint-tools.git:
$ git grep -F 'xstrtol-error' used-modules/
used-modules/coreutils: xstrtol-error
used-modules/datamash: xstrtol-error
used-modules/findutils: xstrtol-error
I beleive findutils and datamash already use quote() so I think (and
hope) this change is uncontroversial.
Collin
0001-xstrtol-error-Use-quote-before-print-command-line-ar.patch
(text/x-patch, 2.5 KB)
From 30253a70c047b2b62845a7683c8c7c7ac59e6aa4 Mon Sep 17 00:00:00 2001 Message-ID: <30253a70c047b2b62845a7683c8c7c7ac59e6aa4.1781224205.git.collin.funk1@gmail.com> From: Collin Funk <[email protected]> Date: Thu, 11 Jun 2026 17:23:50 -0700 Subject: [PATCH] xstrtol-error: Use quote() before print command line arguments. * lib/xstrtol-error.c: Include quote.h. (xstrtol_error): Adjust the format strings and call quote() before printing the argument. --- ChangeLog | 7 +++++++ lib/xstrtol-error.c | 9 +++++---- modules/xstrtol-error | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63f2d8b50a..5f255d0aff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2026-06-11 Collin Funk <[email protected]> + + xstrtol-error: Use quote() before print command line arguments. + * lib/xstrtol-error.c: Include quote.h. + (xstrtol_error): Adjust the format strings and call quote() before + printing the argument. + 2026-06-08 Bruno Haible <[email protected]> strerror: Detect invalid writes to the returned string in some cases. diff --git a/lib/xstrtol-error.c b/lib/xstrtol-error.c index 94c6a016d2..765340a5a6 100644 --- a/lib/xstrtol-error.c +++ b/lib/xstrtol-error.c @@ -24,6 +24,7 @@ #include <error.h> #include "exitfail.h" #include "gettext.h" +#include "quote.h" #define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid) #define N_(msgid) msgid @@ -57,16 +58,16 @@ xstrtol_error (enum strtol_error err, abort (); case LONGINT_INVALID: - msgid = N_("invalid %s%s argument '%s'"); + msgid = N_("invalid %s%s argument %s"); break; case LONGINT_INVALID_SUFFIX_CHAR: case LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW: - msgid = N_("invalid suffix in %s%s argument '%s'"); + msgid = N_("invalid suffix in %s%s argument %s"); break; case LONGINT_OVERFLOW: - msgid = N_("%s%s argument '%s' too large"); + msgid = N_("%s%s argument %s too large"); break; } @@ -84,7 +85,7 @@ xstrtol_error (enum strtol_error err, option = long_options[opt_idx].name; error (exit_status, 0, dgettext (GNULIB_TEXT_DOMAIN, msgid), - hyphens, option, arg); + hyphens, option, quote (arg)); } /* Like xstrtol_error, except exit with a failure status. */ diff --git a/modules/xstrtol-error b/modules/xstrtol-error index 674e2f7290..3fa70933fe 100644 --- a/modules/xstrtol-error +++ b/modules/xstrtol-error @@ -12,6 +12,7 @@ exitfail getopt-gnu gettext-h gnulib-i18n +quote configure.ac: -- 2.54.0