Collin Funk <[email protected]> writes:
> Bernhard Voelker <[email protected]> writes:
>
>> Do we need/want more patterns, e.g. for translated strings?
>>
>> $ GIT_PAGER= git grep -E '_\("[^"]*std(in|out|err)' -- '*/*.c'
>> src/du.c: error (0, 0, _("when reading file names from stdin, "
>> src/nohup.c: ? N_("ignoring input and redirecting stderr
>> to stdout")
>> src/nohup.c: : N_("redirecting stderr to stdout")));
>> src/sort.c: error (SORT_FAILURE, 0, _("when reading file
>> names from stdin, "
>> src/split.c: error (0, 0, _("--filter does not process a chunk
>> extracted to stdout"));
>> src/stdbuf.c: error (0, 0, _("line buffering stdin is
>> meaningless"));
>> src/wc.c: error (0, 0, _("when reading file names from stdin, "
>
> I think that it would be strange not to change these as well.
>
> I'll write a patch later. Good catch.
Your regex won't catch the following example:
error (0, 0, _("very long line printed"
"to stderr"));
But it seems good enough. And maybe it will be useful if we ever want it
printed to messages. That is similar to what is done to allow
false-positives for sc_error_quotes.
I'll hold off pushing the attached patch in case anyone disagrees. Or
wants to practice perl regex to catch them across multiple lines. :)
Collin
>From c9a30d67814f4b7daac7cdd33b69822ce5313d48 Mon Sep 17 00:00:00 2001
Message-ID: <c9a30d67814f4b7daac7cdd33b69822ce5313d48.1754445103.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Tue, 5 Aug 2025 18:46:04 -0700
Subject: [PATCH] maint: use consistent references to standard files in
messages
* cfg.mk (sc_standard_outputs): Add a grep command for source files.
* src/du.c (main): Use standard input instead of stdin, standard output
instead of stdout, and standard error instead of stderr in messages.
* src/nohup.c (main): Likewise.
* src/sort.c (main): Likewise.
* src/split.c (main): Likewise.
* src/stdbuf.c (main): Likewise.
* src/wc.c (main): Likewise.
* tests/du/files0-from.pl (@Tests): Adjust test case to new messages.
* tests/sort/sort-files0-from.pl: Likewise.
* tests/wc/wc-files0-from.pl: Likewise.
---
cfg.mk | 2 ++
src/du.c | 2 +-
src/nohup.c | 5 +++--
src/sort.c | 3 ++-
src/split.c | 3 ++-
src/stdbuf.c | 2 +-
src/wc.c | 2 +-
tests/du/files0-from.pl | 4 ++--
tests/sort/sort-files0-from.pl | 4 ++--
tests/wc/wc-files0-from.pl | 4 ++--
10 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index eecec2d72..2115b8441 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -341,6 +341,8 @@ sc_standard_outputs: $(ALL_MANS)
&& { echo 1>&2 '$@: use "standard ....." in user docs'; exit 1; } || :
@grep -E '[Ss]tandard (in|out|err)([^op]|$$)' man/*.1 doc/*.texi \
&& { echo 1>&2 '$@: use "standard ..put" in user docs'; exit 1; } || :
+ @grep -E '_\("[^"]*std(in|out|err)' src/*.c \
+ && { echo 1>&2 '$@: use "standard ..put" in messages'; exit 1; } || :
# Option descriptions should not start with a capital letter.
# One could grep source directly as follows:
diff --git a/src/du.c b/src/du.c
index c93d7f71b..e8ad3e93c 100644
--- a/src/du.c
+++ b/src/du.c
@@ -1070,7 +1070,7 @@ main (int argc, char **argv)
{
/* Give a better diagnostic in an unusual case:
printf - | du --files0-from=- */
- error (0, 0, _("when reading file names from stdin, "
+ error (0, 0, _("when reading file names from standard input, "
"no file name of %s allowed"),
quoteaf (file_name));
skip_file = true;
diff --git a/src/nohup.c b/src/nohup.c
index 5b590fbb5..d062d2cb8 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -191,8 +191,9 @@ main (int argc, char **argv)
if (!redirecting_stdout)
error (0, 0,
_(ignoring_input
- ? N_("ignoring input and redirecting stderr to stdout")
- : N_("redirecting stderr to stdout")));
+ ? N_("ignoring input and redirecting standard error "
+ "to standard output")
+ : N_("redirecting standard error to standard output")));
if (dup2 (out_fd, STDERR_FILENO) < 0)
error (exit_internal_failure, errno,
diff --git a/src/sort.c b/src/sort.c
index 7f1b51dd5..8363d2d1d 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -4760,7 +4760,8 @@ main (int argc, char **argv)
for (size_t i = 0; i < nfiles; i++)
{
if (STREQ (files[i], "-"))
- error (SORT_FAILURE, 0, _("when reading file names from stdin, "
+ error (SORT_FAILURE, 0, _("when reading file names from "
+ "standard input, "
"no file name of %s allowed"),
quoteaf (files[i]));
else if (files[i][0] == '\0')
diff --git a/src/split.c b/src/split.c
index 22a83ad5c..e5f6947f8 100644
--- a/src/split.c
+++ b/src/split.c
@@ -1558,7 +1558,8 @@ main (int argc, char **argv)
if (k_units != 0 && filter_command)
{
- error (0, 0, _("--filter does not process a chunk extracted to stdout"));
+ error (0, 0, _("--filter does not process a chunk extracted to "
+ "standard output"));
usage (EXIT_FAILURE);
}
diff --git a/src/stdbuf.c b/src/stdbuf.c
index 9fa9d01f4..b61ddf6a4 100644
--- a/src/stdbuf.c
+++ b/src/stdbuf.c
@@ -343,7 +343,7 @@ main (int argc, char **argv)
/* -oL will be by far the most common use of this utility,
but one could easily think -iL might have the same affect,
so disallow it as it could be confusing. */
- error (0, 0, _("line buffering stdin is meaningless"));
+ error (0, 0, _("line buffering standard input is meaningless"));
usage (EXIT_CANCELED);
}
diff --git a/src/wc.c b/src/wc.c
index 24dc4b3a9..05e78676e 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -876,7 +876,7 @@ main (int argc, char **argv)
{
/* Give a better diagnostic in an unusual case:
printf - | wc --files0-from=- */
- error (0, 0, _("when reading file names from stdin, "
+ error (0, 0, _("when reading file names from standard input, "
"no file name of %s allowed"),
quoteaf (file_name));
skip_file = true;
diff --git a/tests/du/files0-from.pl b/tests/du/files0-from.pl
index 77057aa46..fe053f648 100755
--- a/tests/du/files0-from.pl
+++ b/tests/du/files0-from.pl
@@ -42,8 +42,8 @@ my @Tests =
# input file name of '-'
['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1},
- {ERR => "$prog: when reading file names from stdin, no file name of"
- . " '-' allowed\n"}],
+ {ERR => "$prog: when reading file names from standard input, "
+ . "no file name of '-' allowed\n"}],
# empty input, regular file
['empty', '--files0-from=@AUX@', {AUX=>''}],
diff --git a/tests/sort/sort-files0-from.pl b/tests/sort/sort-files0-from.pl
index eb36e2118..d91924aac 100755
--- a/tests/sort/sort-files0-from.pl
+++ b/tests/sort/sort-files0-from.pl
@@ -42,8 +42,8 @@ my @Tests =
# input file name of '-'
['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>2},
- {ERR => "$prog: when reading file names from stdin, no file name of"
- . " '-' allowed\n"}],
+ {ERR => "$prog: when reading file names from standard input, "
+ . "no file name of '-' allowed\n"}],
# empty input, regular file
['empty', '--files0-from=@AUX@', {AUX=>''}, {EXIT=>2},
diff --git a/tests/wc/wc-files0-from.pl b/tests/wc/wc-files0-from.pl
index bf6b6f85b..5d803083e 100755
--- a/tests/wc/wc-files0-from.pl
+++ b/tests/wc/wc-files0-from.pl
@@ -42,8 +42,8 @@ my @Tests =
# input file name of '-'
['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1},
- {ERR => "$prog: when reading file names from stdin, no file name of"
- . " '-' allowed\n"}],
+ {ERR => "$prog: when reading file names from standard input, "
+ . "no file name of '-' allowed\n"}],
# empty input, regular file
['empty', '--files0-from=@AUX@', {AUX=>''}],
--
2.50.1