Collin Funk [Wed, 20 May 2026 01:10:51 +0000 (18:10 -0700)]
shred: preserve the ENXIO errno from open
This fixes an issue in unreleased commit f77f365ef (shred: don't block
when opening FIFOs with no readers, 2026-05-09).
* src/shred.c: Save the errno before calling stat and use it in the
error message.
* tests/shred/fifo.sh: Call getlimits_ and uses_strace_. Add a test
case.
Pádraig Brady [Tue, 19 May 2026 17:45:26 +0000 (18:45 +0100)]
tests: avoid false failures with older strace
* tests/tee/short-write.sh: Check that all the required strace
options are supported, which is not the case with strace 5.10 at least.
* tests/tee/write-eagain.sh: Likewise.
Collin Funk [Tue, 19 May 2026 03:40:28 +0000 (20:40 -0700)]
tee: fix infinite loop when write returns EAGAIN and short write errors
* NEWS: Mention the bug fixes.
* THANKS.in: Add Bernhard M. Wiedemann for reporting the bugs.
* src/iopoll.c (close_wait): Remove function.
(write_wait): Don't call wait_for_nonblocking_write if write is
successful. Handle errors more robustly.
* src/iopoll.h (close_wait): Remove declaration.
* src/tee.c (tee_files): Use close instead of close_wait.
* tests/tee/short-write.sh: New test for the bug.
* tests/tee/write-eagain.sh: Likewise.
* tests/local.mk (all_tests): Add the new tests.
Fixes https://bugs.gnu.org/81060
Collin Funk [Wed, 13 May 2026 01:35:28 +0000 (18:35 -0700)]
doc: shred: mention unsupported file types
* src/shred.c (usage): Mention the behavior of 'shred' on FIFOs,
sockets, and terminals.
* doc/coreutils.texi (shred invocation): Likewise.
Addresses https://bugs.gnu.org/30177
Paul Eggert [Mon, 11 May 2026 06:29:05 +0000 (23:29 -0700)]
maint: pacify GCC 16 -Wuseless-cast
This mostly either removes casts if they are always no-ops, or
replaces casts (TYPE)(EXPR) with compound literals (TYPE){EXPR}.
Compound literals are a bit safer anyway, as casts are too
powerful in C.
* src/cksum_avx2.c (cksum_avx2):
* src/cksum_avx512.c (cksum_avx512):
* src/cksum_crc.c (cksum_slice8):
* src/cksum_pclmul.c (cksum_pclmul):
* src/cp-hash.c (remember_copied):
* src/numfmt.c (simple_strtod_float):
* src/system.h (x_timestyle_match):
Omit no-op casts.
* src/cp-hash.c (src_to_dest_hash):
* src/dd.c (dd_copy):
* src/df.c (devlist_hash):
* src/env.c (splitbuf_append_byte):
* src/getlimits.c (print_int, main):
* src/ls.c (dev_ino_hash):
* src/truncate.c (do_ftruncate):
Replace casts with compound literals.
* src/factor.c: Ignore -Wuseless-cast, as we include the imported
longlong.h file, which has many of them.
* src/numfmt.c (powerld): 2nd arg is now ptrdiff_t, not int, so
that integers are not silently mishandled in outlandish cases.
Collin Funk [Sat, 9 May 2026 22:43:39 +0000 (15:43 -0700)]
shred: don't block when opening FIFOs with no readers
* NEWS: Mention the bug fix.
* src/shred.c (wipefile): Open the file with O_NONBLOCK.
* tests/shred/fifo.sh: New file.
* tests/local.mk (all_tests): Add the new test.
Pádraig Brady [Fri, 8 May 2026 18:39:00 +0000 (19:39 +0100)]
doc: help2man: preserve layout of tables
This is useful in many man pages like date , dd, od, tr, ...
where there are tables presented, where extraneous lines
between each entry are best avoided.
* man/help2man: Use .PD 0 (Paragraph Distance)
to avoid extraneous blank lines within .TP delineated tables.
Also use explicit widths with .TP in such tables,
to preserve the alignment from the --help output.
* src/shuf.c (print_number): New function.
(write_permuted_numbers, write_random_numbers): Use it.
* tests/shuf/shuf.sh: Add a test case to run 'shuf -i' with varying
numbers of digits to check that the string conversion is correct.
* tests/ls/acl.sh: Check that the gap between the '+' indicator and
the link count is the same whether the listing contains one or
several ACL entries.
https://github.com/coreutils/coreutils/pull/251
Pádraig Brady [Mon, 4 May 2026 14:34:32 +0000 (15:34 +0100)]
ls: exclude newline from consideration in line width
* src/ls.c (calculate_columns): Treat width as inclusive max.
(print_with_separator): Likewise. Also handle commas explicitly,
since they're not catered for by an implicit newline in the count.
* tests/ls/w-option.sh: Adjust exact-fit column tests.
Note this change also makes the existing `ls -w4 -x -T0 a b` test
behave consistently with other output width limits.
Also add the test case from:
https://github.com/coreutils/coreutils/pull/213
* tests/ls/m-option.sh: Add a test case to ensure appropriate
wrapping when trailing comma at the line limit.
* NEWS: Mention the change in behavior.
Pádraig Brady [Mon, 4 May 2026 14:34:01 +0000 (15:34 +0100)]
ls: fix too few display columns edge case
In the edge case where the right most column would
consist of only files taking 1 or 2 cells, we accounted
for 3 cells, which would result in using 1 column too few.
This should have been part of commit v8.24-59-ge71be1292
* src/ls.c (init_column_info): Don't account for separator
in the the final column.
* tests/ls/w-option.sh: Add a test case.
Pádraig Brady [Sun, 3 May 2026 10:28:19 +0000 (11:28 +0100)]
tests: tee: ensure tee is non buffered
* tests/tee/tee.sh: tests/misc/responsive.sh only confirms
responsiveness to lines, so add a test for non line terminated.
https://github.com/coreutils/coreutils/pull/259
Previously the string from strerror would only be printed for some
algorithms:
$ cksum -a sha2 -l 256 /dev/null > /dev/full
cksum: write error: No space left on device
$ cksum -a sysv /dev/null > /dev/full
cksum: write error
This patch fixes it so that the error information is always printed:
$ ./src/cksum -a sha2 -l 256 /dev/null > /dev/full
cksum: write error: No space left on device
$ ./src/cksum -a sysv /dev/null > /dev/full
cksum: write error: No space left on device
* src/cksum.c (output_file): Don't check for a write error here.
(main): Check for it here instead.
* tests/misc/io-errors.sh: Add a 'cksum' invocation for each supported
algorithm.
https://github.com/coreutils/coreutils/issues/258
* src/unexpand.c (unexpand): Use xinmalloc() to gracefully
handle overflow. Also use the runtime locale specific MB_CUR_MAX
rather than the worst case MB_LEN_MAX.
* tests/unexpand/mb.sh: Add a test case that fails in a default
glibc build with either MB_CUR_MAX or MB_LEN_MAX.
* NEWS: Mention the bug fix.
Reported by Michał Majchrowicz.
* src/cut.c: We use the mcel interface to populate these arrays,
so restrict to the mcel supported max. This is more efficient
as generally stateful encodings are not used or supported.
sort: use more dynamic memory allocation with pipes
The default memory allocation with pipes was too passive/static,
resulting in not allocating enough memory to enable threading.
By dynamically reallocating the buffer when reading from
unknown sized inputs we better use available memory and threads.
$ time seq 10000000 -1 0 | sort-old >/dev/null
real 0m16.523s
user 0m16.900s
sys 0m0.167s
$ time seq 10000000 -1 0 | sort-old -S1G >/dev/null
real 0m12.263s
user 0m29.646s
sys 0m0.527s
$ time seq 10000000 -1 0 | sort-new >/dev/null
real 0m12.994s
user 0m31.266s
sys 0m0.716s
It also avoids the overhead of writing to temp files
for modestly sized inputs. For example the following
input would induce interaction with temp storage:
$ seq 125000 | wc -c
763895
* src/sort.c (sort_buffer_size): Rename to ...
(sort_buffer_policy): ... here, and adjust to set
an initial size and limit, rather than just a size.
(fillbuf): Add a POLICY parameter, and use that
to call maybe_growbuf() as needed.
(maybe_growbuf): Return true if POLICY dictates we
should grow the buffer, and try_growbuf() was
able to reallocate the larger buffer.
* tests/sort/sort-buffer-size.sh: Add a new test.
* tests/local.mk: Reference new test.
* NEWS: Mention the improvement.
Related to https://bugs.gnu.org/10877
doc: apply man page formatting suggestions from manpage-l10n
* src/basenc.c: Add (1) to base64 and base32 references.
* src/cksum.c. Likewise for cksum references.
* src/echo.c: Use "bell" in descriptions rather than BEL.
* src/printf.c: Likewise.
* src/id.c: Separate -u,-U,-G so marked up appropriately.
Fixes https://bugs.gnu.org/80904
tests: all: ensure closed stdout is handled appropriately
* tests/misc/io-errors.sh: Add a check to ensure we diagose
writing to closed stdout. Also ensure we exit with failure
in other cases.
* tests/misc/write-errors.sh: Likewise.
Bruno Haible [Fri, 24 Apr 2026 13:36:51 +0000 (15:36 +0200)]
doc: remove redundant "Report translation bugs to" in --help
* configure.ac: Define PACKAGE_L10N_BUGREPORT.
* man/local.mk (run_help2man): Set the IN_HELP2MAN environment variable.
* src/system.h (emit_ancillary_info): Don't emit "Report any translation
bugs to" line; this is already done by emit_bug_reporting_address() in
version-etc.c.
Fixes https://bugs.gnu.org/80886
I noticed a single failure on cfarm29 (Linux 6.12 ppc64le),
where the output was missing:
-tail: directory containing watched file was removed
-tail: inotify cannot be used, reverting to polling
-tail: 'dir/file' has appeared; following new file
* tests/tail/inotify-dir-recreate.sh: Leverage the new tail --debug
output to sync to a point where we know the inotify watches are in
place. Also normalize the file argument quoting a bit.
* src/dd.c (parse_integer): Use iterative rather than recursive parsing,
to avoid potential stack overflow.
* tests/dd/bytes.sh: Add a test case.
https://github.com/coreutils/coreutils/issues/254
* NEWS: Mention the bug fix.
* src/comm.c (usage): Remove mention that FILE1 and FILE2 cannot both be
standard input.
(compare_files): Only close standard input once.
* doc/coreutils.texi (comm invocation): Document the behavior of
'comm - -' which is not portable to all implementations.
* tests/comm/dash-dash.sh: New file.
* tests/misc/comm.pl: Move to tests/comm/comm.pl.
* tests/local.mk (all_tests): Add the new test. Rename the existing
test.
* src/yes.c (splice_write): Always drain what we've written
to an internal pipe, so there is no possibility of vmsplice() blocking.
I.e., be defensive in the case that fcntl() fails, and
our default buffer size (currently 16kiB) is larger than the pipe.
https://github.com/coreutils/coreutils/issues/253
Bruno Haible [Fri, 17 Apr 2026 13:46:19 +0000 (15:46 +0200)]
tests: reinstate logname error verification
* tests/misc/user.sh: Modify the "unshare -U logname" test, so that it
does not fail on glibc versions (< 2.28, >= 2.38) that do a fallback
lookup based on the tty.
* tests/date/date-locale-hour.sh: Just strip the char before the last x,
assuming it's going to be the newline output by `locale`.
dash doesn't support $'' within ${}.
* tests/misc/io-errors.sh: Allow a generic error string on musl since
the first line is emitted immediately instead of being buffered as
expected.
Reported by Bruno Haible.
* m4/jm-macros.m4: AIX has a splice() function for TCP,
so check for vmsplice() instead.
* src/splice.h: Define HAVE_SPLICE if vmsplice available.
Reported by Bruno Haible.
* tests/dd/no-allocate.sh: Run getlimits_ to ensure
we have $SSIZE_MAX etc. available. Also give some buffer
for the configured ulimit to leave space for returns_ to work.
* tests/cp/sparse-perf.sh: Old Centos 7 can give EINVAL
from SEEK_DATA on sparse files being copied from /dev/shm.
Avoid this failure as it's not practical to fix.
* tests/date/date-locale-hour.sh: Ensure `locale date_fmt`
is propagated exactly, even when it contains trailing new lines,
as was seen with Serbian locales on Centos 7.
As noted in https://bugs.gnu.org/9089
ksh gives intermittent ECONNRESET errors with closed pipes.
This can be seen reliably on Linux with:
ksh -c 'yes | (sleep .1; head -n10 >/dev/null)'
* tests/misc/io-errors.sh: Avoid part of test on ksh.
* tests/misc/write-errors.sh: Likewise.
As described in commit v9.10-283-g5cb0cca3b
avoid using ulimit with $SHELL -c, and explict
invocation of the shell like that can require lots of memory,
often due to loading the locale archive.
* tests/basenc/bounded-memory.sh: Avoid $SHELL -c with ulimit.
* tests/cut/bounded-memory.sh: Likewise.
* tests/expand/bounded-memory.sh Likewise.
* tests/pr/bounded-memory.sh Likewise.
* tests/unexpand/bounded-memory.sh Likewise.
* tests/fold/fold-zero-width.sh: Bring the ulimit bound
down to the standard 6M over the determined limit.
* tests/misc/tty-eof.pl: Fix a race that commit v9.10-269-gf312af49a
made more apparent, and resulted in intermittent failure like:
"... (with input) didn't produce expected output".
Now Instead of waiting for overlapping echo and output,
just wait for EOF, and if received, use exp->before()
to inspect the accumulated output.
Verified with:
make -j4 PREFERABLY_POSIX_SHELL=/bin/ksh SUBDIRS=. check
* tests/fold/fold-zero-width.sh: Don't timeout $SHELL -c ...
as the ulimit induces a failure in the subshell depending
on the order of the allocations it does. The main issue is
disparity between the probed ulimit and that needed by $SHELL -c.
Such subshells load the often very large locale archive, thus
if there are any allocations done after the now too low ulimit is set,
then the $SHELL command fails. Note we timeout fold rather than
the whole pipeline so any 124 exit status is propagated.
$ strace -e silence=exit -e trace=unlink,rmdir \
mktemp -d > /dev/full
unlink("/tmp/tmp.ZBuPmS9ZGD") = -1 EISDIR (Is a directory)
rmdir("/tmp/tmp.ZBuPmS9ZGD") = 0
mktemp: write error: No space left on device
In the above invocation we know that we created a directory, so we
should not remove a regular file that must have been created by another
process:
$ strace -e silence=exit -e trace=unlink,rmdir \
./src/mktemp -d > /dev/full
rmdir("/tmp/tmp.hGbME1HmJr") = 0
mktemp: write error: No space left on device
* src/mktemp.c (main): Prefer rmdir and unlink depending on whether we
created a directory or regular file.
* bootstrap.conf (gnulib_modules): Remove the remove module.
* src/cat.c (splice_cat): Don't bother resizing input as it generally
doesn't help perf, and also save an fstat per input. Don't close the
intermediate pipe once created, unless there is an error reading from
it.
* tests/misc/responsive.sh: Test commands that should output immediately
upon receiving input, and that there is no unecessary buffering.
* cfg.mk: Avoid false failure in sc_prohibit_test_backticks.
* tests/local.mk: Reference the new test.
* tests/tty/tty-eof.pl: Remove command specific logic,
and adjust commands to support general input.
Also add cut -b, as cut_bytes has its own read loop.
* tests/date/date.pl: Set the max supported year to INT_MAX.
Most systems support INT_MAX+1900, but mktime() on OpenBSD 7.8
limits the passed tm_year to INT_MAX.
Reported by Bruno Haible.