diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 0fc9e52..7ce2f78 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1541,12 +1541,13 @@ Index: coreutils-9.5/src/fold.c - saved_errno = errno; + *saved_errno = errno; -+ if (!ferror (istream)) + if (!ferror (istream)) +- saved_errno = 0; + *saved_errno = 0; -+ -+ if (offset_out) -+ fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); -+ + + if (offset_out) + fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); + +} + +#if HAVE_MBRTOWC @@ -1718,19 +1719,18 @@ Index: coreutils-9.5/src/fold.c + } + + *saved_errno = errno; - if (!ferror (istream)) -- saved_errno = 0; ++ if (!ferror (istream)) + *saved_errno = 0; - - if (offset_out) - fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); - ++ ++ if (offset_out) ++ fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); ++ +} +#endif + +/* Fold file FILENAME, or standard input if FILENAME is "-", + to stdout, with maximum line length WIDTH. -+ Return 0 if successful, 1 if an error occurs. */ ++ Return true if successful. */ + +static bool +fold_file (char const *filename, size_t width) @@ -1741,15 +1741,15 @@ Index: coreutils-9.5/src/fold.c + if (STREQ (filename, "-")) + { + istream = stdin; -+ have_read_stdin = 1; ++ have_read_stdin = true; + } + else + istream = fopen (filename, "r"); + -+ if (istream == NULL) ++ if (istream == nullptr) + { + error (0, errno, "%s", filename); -+ return 1; ++ return false; + } + + /* Define how ISTREAM is being folded. */ diff --git a/coreutils.changes b/coreutils.changes index 4a633e9..9d2d52f 100644 --- a/coreutils.changes +++ b/coreutils.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Tue Jul 9 20:22:23 UTC 2024 - Bernhard Voelker + +- coreutils-i18n.patch: fold(1): fix exit code for non-existent file. + The exit code of fold(1) was zero for non-existent file: + $ fold badfile; echo $? + fold: badfile: No such file or directory + 0 + The bug was introduced by the downstrean I18N patch. (rhbz#2296201) + ------------------------------------------------------------------- Mon Apr 1 18:07:16 UTC 2024 - Bernhard Voelker