oech3 [Sun, 11 Jan 2026 18:14:44 +0000 (18:14 +0000)]
tests: cksum: ensure --check handles I/O errors
* tests/cksum/cksum-c.sh: Use strace to inject EIO upon read(),
and verify it's handled appropriately.
From https://github.com/coreutils/coreutils/pull/167
Pádraig Brady [Sat, 10 Jan 2026 16:37:13 +0000 (16:37 +0000)]
build: support 'dist' and 'syntax-check' targets without libselinux
Following on from commit v9.8-60-g8ba47d09a ...
Without libselinux installed, runcon and chcon stub binaries
will not be built by default. We separate these utilities out
to a separate "not built unless appropriate" class, so that
we can add these to EXTRA_MANS so that the 'check-x-vs-1'
target doesn't fail, and the 'dist' target includes
these man pages.
* build-aux/gen-lists-of-programs.sh: Separate out
build_if_appropriate_progs, and propagate that through
to no_install_progs_default which populates EXTRA_MANS.
* src/local.mk: Separate out build_if_appropriate__progs
for clarity and consistency.
Pádraig Brady [Sun, 11 Jan 2026 12:54:17 +0000 (12:54 +0000)]
build: update gnulib submodule to latest
* gnulib: Update to latest mainly to pull in selinux module fixes.
* NEWS: Mention the build fix to honor --with-selinux building
stub chcon and runcon binaries on systems without libselinux.
Collin Funk [Sat, 10 Jan 2026 05:17:26 +0000 (21:17 -0800)]
cksum: promptly diagnose write errors
* src/cksum.c (output_file, digest_check): Check if standard output has
it's error flag set after printing.
* tests/misc/write-errors.sh: Add a test case that would previously run
forever.
* NEWS: Mention the improvement. Reorder alphabetically.
Collin Funk [Fri, 9 Jan 2026 06:52:33 +0000 (22:52 -0800)]
readlink,realpath: promptly diagnose write errors
The 'readlink' and 'realpath' programs have an uncommon case where they
can run for a very long time. When canonicalizing file names longer than
PATH_MAX, we have to call 'openat' for each directory up the tree until
we reach root which takes a long time. Here is an example of the current
behavior:
$ mkdir -p $(yes a/ | head -n $((32 * 1024)) | tr -d '\n')
$ while cd $(yes a/ | head -n 1024 | tr -d '\n'); do :; \
done 2>/dev/null
$ pwd | tr '/' '\n' | wc -l
32771
$ env time --format=%E readlink -f $(yes . | head -n 5) > /dev/full
readlink: write error: No space left on device
Command exited with non-zero status 1
0:59.72
$ env time --format=%E realpath $(yes . | head -n 5) > /dev/full
realpath: write error: No space left on device
Command exited with non-zero status 1
1:00.32
It is better to exit as soon as there is an error writing to standard
output:
$ env time --format=%E readlink -f $(yes . | head -n 5) > /dev/full
readlink: write error: No space left on device
Command exited with non-zero status 1
0:11.88
$ env time --format=%E realpath $(yes . | head -n 5) > /dev/full
realpath: write error: No space left on device
Command exited with non-zero status 1
0:12.04
* src/readlink.c (main): Check if standard output has it's error flag
set after printing a file name.
* src/realpath.c (process_path): Likewise.
* NEWS: Mention the improvement.
Pádraig Brady [Thu, 8 Jan 2026 14:07:32 +0000 (14:07 +0000)]
cksum: validate options more consistently
We disallow `cksum --tag --check` which is fine,
but the error should be consistent with md5sum,
and less confusing, as it currently mentions
"--binary" and "--text" which weren't specified.
We disallow `cksum --tag --text` which is fine,
but we should also disallow `cksum --text --tag`.
We should honor an explicit --binary (output *)
with this combination of options:
cksum --binary --tag --untagged -a md5 /dev/null
Note this also makes both of `cksum -a md5` and
`cksum --tag -a md5` consistently use binary mode
when reading from a tty on systems like MinGW
where O_BINARY is set.
* src/cksum.c (main): Adjust --text,--binary
and --tag,--untagged option processing.
* tests/cksum/cksum-a.sh: Add test cases.
* tests/cksum/cksum-c.sh: Likewise.
* NEWS: Mention the improvement.
Fixes https://github.com/coreutils/coreutils/issues/163
Pádraig Brady [Wed, 7 Jan 2026 22:50:07 +0000 (22:50 +0000)]
tests: chmod: fix false failure in recent test
* tests/chmod/partial-fail.sh: Test readablility of mode 0 files
independently, to avoid false failure, e.g., when run as root.
Reported by Bruno Haible.
Pádraig Brady [Wed, 7 Jan 2026 20:29:54 +0000 (20:29 +0000)]
tests: tail/overlay-headers.sh: fix various issues
* tests/tail/overlay-headers.sh (cleanup_): Ensure we send SIGCONT
to the tail process, otherwise we would hang if the test is terminated
while the tail process is in stopped state.
(wait4stopped_): A new function to ensure tail is in the stopped state
before we start writing to the monitored files.
Also remove "---disable-inotify" from $fastpoll so we actually
test the inotify code (where supported).
Also remove the timeout(1) wrapper, so we actually suspend tail(1).
Pádraig Brady [Wed, 7 Jan 2026 17:15:28 +0000 (17:15 +0000)]
fmt: interpret -w as an inclusive maximum
This aligns with `fold -w` and BSD `fmt` implementations.
* src/fmt.c (fmt_paragraph): Check len <= max_width.
* tests/fmt/width.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
Addresses part of https://bugs.gnu.org/79497
Collin Funk [Mon, 5 Jan 2026 00:51:09 +0000 (16:51 -0800)]
tests: mktemp: add tests for invalid Unicode options
* init.cfg (bad_unicode): New function, copied from
tests/fold/fold-characters.sh with the NUL removed.
* tests/fold/fold-characters.sh (bad_unicode): Rename to
bad_unicode_with_nul. Reformat long line.
* tests/mktemp/bad-unicode.sh: New test.
* tests/local.mk (all_tests): Add the new test.
Pádraig Brady [Mon, 5 Jan 2026 14:46:33 +0000 (14:46 +0000)]
copy: protect against infinite loop due to pathological race
Consider:
1. In infer_scantype():
- SEEK_DATA returns 0
- hole punched at 0
- SEEK_HOLE returns 0 (now a hole)
- Cache scan_inference->hole_start = 0
2. In lseek_copy():
- data written at 0
- ext_start = 0, use cached hole_start = 0
- ext_len = 0
- now loop doesn't progress
* src/copy-file-data.c (lseek_copy): Apply a more defensive check
to ensure we only use the cached offsets in SCAN_INFERENCE once.
This protects against an infinite loop where an extent (at SRC_POS)
flip flops between data and hole extent while infer_scantype()
and lseek_copy() are inspecting it. I.e. ensure we use SEEK_HOLE
to progress the copy.
Pádraig Brady [Tue, 6 Jan 2026 20:29:45 +0000 (20:29 +0000)]
tests: cp: fix always skipped nfs-removal-race.sh
* tests/cp/nfs-removal-race.sh: This test was invalid since v8.32
as we now use fstatat() rather than stat(). Also since commit v9.0-66-ge2daa8f79 we leverage the errno from open(O_DIRECTORY)
to avoid a stat, so pass --no-target-directory to ensure fstatat()
is called.
Discussed in https://github.com/coreutils/coreutils/pull/161
tests: cp: support glibc 2.33+ in nfs-removal-race test
glibc 2.33 removed __xstat, making stat() a direct symbol. This test
previously only intercepted __xstat, causing it to skip on modern glibc
with 'LD_PRELOAD was ineffective'.
Changes:
- Intercept both __xstat (glibc < 2.33) and stat (glibc >= 2.33)
- Only mark 'preloaded' when stat is called on destination 'd',
ensuring the test verifies cp actually stats the destination
Pádraig Brady [Mon, 5 Jan 2026 21:56:38 +0000 (21:56 +0000)]
ptx: implement -t to change default width to 100
Align the -t implementation with the Heirloom project.
* src/ptx.c (usage): Describe -t, and also mention
the default width is 72 when not used.
* doc/coreutils.texi (ptx invocation): Likewise.
(main): Override the default width if -t is specified.
* tests/ptx/ptx.pl: Add test cases.
* NEWS: Mention the change in behavior.
tests: stty: add require_controlling_input_terminal_ to bad-speed test
The bad-speed test runs 'stty ispeed 9600' without a --file argument,
which requires a controlling terminal. Without it, stty fails early with
'Inappropriate ioctl for device' before reaching cfsetispeed, causing
the test to skip with a misleading 'LD_PRELOAD interception failed'
message.
* tests/stty/bad-speed.sh: Add require_controlling_input_terminal_
to match the other stty tests (stty.sh, stty-pairs.sh, stty-row-col.sh,
stty-invalid.sh) which all require a controlling terminal.
From https://github.com/coreutils/coreutils/pull/160
Pádraig Brady [Sun, 4 Jan 2026 12:45:46 +0000 (12:45 +0000)]
copy: fix possible infinite loop with SEEK_HOLE
Commit v9.8-95-g4c0cf3864 intended to initialize
ext_start to src_pos, as was described at:
https://lists.gnu.org/r/coreutils/2025-11/msg00035.html
However ipos was inadvertently used, which is only
valid the first time through the loop.
* src/copy-file-data.c (lseek_copy): Use scan_inference->hole_start
only with the initial offset passed to lseek_copy().
* NEWS: Mention the bug fix.
Reported at https://github.com/coreutils/coreutils/issues/159
oech3 [Tue, 30 Dec 2025 12:03:11 +0000 (21:03 +0900)]
tests: df: hide /proc without using LD_PRELOAD
* tests/df/no-mtab-status-masked-proc.sh: A new test similar
to no-mtab-status.sh but should work with static builds.
* tests/local.mk: Reference the new test.
https://github.com/coreutils/coreutils/pull/156
Collin Funk [Mon, 29 Dec 2025 03:48:29 +0000 (19:48 -0800)]
tests: env: check that real-time signals can be ignored
* tests/env/env-signal-handler.sh: Test that --ignore-signal with no
options also ignores real-time signals. Test that real-time signals can
be ignored by explicitly listing them.
Collin Funk [Sat, 27 Dec 2025 01:52:58 +0000 (17:52 -0800)]
getlimits: print SIGRTMIN and SIGRTMAX
* src/getlimits.c (SIGRTMIN): Define to zero if signal.h does not define
this constant.
(SIGRTMAX): Define to SIGRTMIN - 1 if signal.h does not define this
constant.
(main): Print SIGRTMIN and SIGRTMAX.
oech3 [Sat, 27 Dec 2025 13:57:30 +0000 (22:57 +0900)]
tests: split: verify operation in the presence of I/O errors
* tests/split/split-io-err.sh: A new test to verify that with I/O
errors, we leave existing files but don't continue.
* tests/local.mk: Reference the new test.
Pádraig Brady [Sat, 27 Dec 2025 16:28:55 +0000 (16:28 +0000)]
tests: check I/O error handling with /dev/full and closed pipes
* tests/misc/io-errors.sh: Verify that all commands diagnose write
errors, and handle a closed pipe appropriately.
* tests/local.mk: Reference the new test.
Pádraig Brady [Sat, 27 Dec 2025 15:48:42 +0000 (15:48 +0000)]
sort: fix SIGPIPE handling
* src/sort.c (main): Don't override handler for SIGPIPE
(which we did since commit v9.9-34-ge63131b32),
since we've explicit handling for SIGPIPE.
Also move ignoring of SIGPIPE until after
--help and --version are processed.
oech3 [Sat, 27 Dec 2025 12:45:31 +0000 (12:45 +0000)]
tests: consolidate csplit-io-err tests
* tests/csplit/csplit-io-err.sh: Replace this LD_PRELOAD test with...
* tests/csplit/csplit-io-err-2.sh: This more general test,
that leverages /dev/full.
* tests/local.mk: Remove tests/csplit/csplit-io-err-2.sh.
Collin Funk [Wed, 24 Dec 2025 05:45:37 +0000 (21:45 -0800)]
dd: don't continue copying when ftruncate fails using seek= and of=
* src/dd.c (main): Reduce the scope of exit_status. Exit immediately if
ftruncate fails.
* tests/dd/fail-ftruncate-fstat.sh: New test.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix.
Collin Funk [Sun, 21 Dec 2025 01:24:17 +0000 (17:24 -0800)]
maint: prefer enums over macros for sources used for multiple programs
* src/chown.h (enum chown_modes): New type.
(CHOWN_CHOWN, CHOWN_CHGRP): Define as an enum instead of a macro.
* src/chown-chgrp.c (chown_mode): Use "enum chown_modes" instead of
"int".
* src/chown-chown.c (chown_mode): Likewise.
* src/ls.h (enum ls_modes): New type.
(LS_LS, LS_MULTI_COL, LS_LONG_FORMAT): Define as an enum instead of a
macro.
* src/ls-dir.c (ls_mode): Use "enum ls_modes" instead of "int".
* src/ls-ls.c (ls_mode): Likewise.
* src/ls-vdir.c (ls_mode): Likewise.
* src/uname.h (enum uname_modes): New type.
(UNAME_UNAME, UNAME_ARCH): Define as an enum instead of a macro.
* src/uname-arch.c (uname_mode): Use "enum uname_modes" instead of
"int".
* src/uname-uname.c (uname_mode): Likewise.
Collin Funk [Sat, 20 Dec 2025 04:38:01 +0000 (20:38 -0800)]
doc: prefer UTF-8 characters in texinfo sources
* doc/coreutils.texi (Introduction): Use ç instead of @,{c}.
(Character arrays): Use ö instead of @"o. Use Ł instead of @L{}.
(Formatting file timestamps): Use ä instead of @"a.
Pádraig Brady [Thu, 18 Dec 2025 23:54:52 +0000 (23:54 +0000)]
doc: split,tac: document $TMPDIR usage
Following commit v9.3-92-g1b86b70dd
$TMPDIR is part of the interface and an important behavioral
characteristic of a command, which should be documented.
Collin Funk [Sat, 13 Dec 2025 07:11:09 +0000 (23:11 -0800)]
doc: dd: document the behavior of conv flags on multibyte characters
* doc/coreutils.texi (dd invocation): Document the behavior of 'dd' on
multibyte characters and some unspecified behavior that will be
documented in a future POSIX release [1].
Collin Funk [Sat, 13 Dec 2025 05:51:30 +0000 (21:51 -0800)]
tests: ls: use a larger file descriptor limit
OpenBSD and Alpine Linux /bin/sh cannot handle a file descriptor limit
of 7.
* tests/ls/recursive.sh: Create 30 directories and use a file descriptor
limit of 20. Don't check the output since we have coverage for that
elsewhere.
Reported by Bruno Haible.
Pádraig Brady [Sat, 6 Dec 2025 13:47:11 +0000 (13:47 +0000)]
build: reduce size of multi-call binary by reusing cksum logic
Map md5sum and sha{1,224,256,385,512} to use cksum logic,
which selects appropriate behavior at runtime, rather than
separate binaries for each closely related utility.
$ size src/coreutils # before
text data bss dec hex filename 1349509 6812 619312 1975633 1e2551 src/coreutils
$ size src/coreutils # after
text data bss dec hex filename 1306933 6748 619152 1932833 1d7e21 src/coreutils
* build-aux/gen-single-binary.sh: Map sha*sum to use cksum.c
* src/cksum.c: Adjust to behave more like sha*sum,
when the algorithm to something other than "crc".
* src/cksum.h: Expose the cksum_algorithm global and enum.
* src/coreutils-md5sum.c: Set cksum_algorithm and call cksum logic.
* src/coreutils-sha1sum.c: Likewise.
* src/coreutils-sha224sum.c Likewise.
* src/coreutils-sha256sum.c Likewise.
* src/coreutils-sha384sum.c Likewise.
* src/coreutils-sha512sum.c Likewise.
* NEWS: Mention the improvement.
Pádraig Brady [Fri, 12 Dec 2025 16:41:36 +0000 (16:41 +0000)]
doc: expand on shell-escape quoting style
* doc/coreutils.texi (quotingStyles): Expand on the advantages
of "shell-escape" quoting, and mention it's the default when
outputting to a tty. Also mention how it's also useful with
LC_ALL=C to further disambiguate output. Also reference the
separate page detailing various considerations and options
for file name quoting. Also move the mention of the default
quoting style to the top of the page where it's more obvious.
Collin Funk [Wed, 10 Dec 2025 05:13:10 +0000 (21:13 -0800)]
maint: install: reduce variable scope
* src/install.c (change_timestamps): Initialize variables where they are
declared.
(need_copy, setdefaultfilecon, get_ids, mkancesdirs_safe_wd, main):
Declare variables where they are used instead of at the start of the
block.
Collin Funk [Wed, 10 Dec 2025 05:05:22 +0000 (21:05 -0800)]
maint: cp: reduce variable scope
* src/cp.c (re_protect): Initialize variables where they are declared.
(make_dir_parents_private, do_copy, main): Declare variables where they
are used instead of at the start of the block.
Pádraig Brady [Tue, 9 Dec 2025 17:07:13 +0000 (17:07 +0000)]
doc: support html post processing in all cases
Previously the html-local make rule only worked for `make html`.
Instead add support for `make doc/coreutils.html` or `make web-manual`
through the use of a makeinfo wrapper.
* doc/local.mk: Move post processing from here to ...
* build-aux/makeinfo-wrapper.sh: ... here.
* cfg.mk: Ensure our wrapper is called with MAKEINFO.
Also pass --no-node-files so redirection html files
are not created for each anchor.
Collin Funk [Tue, 9 Dec 2025 13:17:33 +0000 (13:17 +0000)]
doc: html: fix build with parallel make
* doc/local.mk (html-local): Add html files to prerequisites so they are
generated before 'sed' is invoked. Also interate over the already
populated $(HTMLS) to be more general (to multiple html files),
and more portable (to non GNU make).
Pádraig Brady [Mon, 8 Dec 2025 14:15:00 +0000 (14:15 +0000)]
doc: fix pdf generation
* doc/coreutils.texi: Explicitly supply empty arguments to macros,
as dvi (a required prerequisite to pdf) is more strict in its
handling of macro arguments.
* cfg.mk (sc_texi_ensure_empty_option_args): Add a syntax check,
since this is not verified in the default build.
Reported by Collin Funk.
Collin Funk [Sun, 7 Dec 2025 23:48:15 +0000 (15:48 -0800)]
maint: env: reduce variable scope
* src/env.c (extract_varname, parse_signal_action_params)
(parse_block_signal_params, set_signal_proc_mask)
(list_signal_handling, main): Declare variables where they are used
instead of at the start of the function.
Collin Funk [Sun, 7 Dec 2025 23:27:29 +0000 (15:27 -0800)]
maint: pwd: reduce variable scope
* src/pwd.c (find_dir_entry, robust_getcwd): Declare variables where
they are used.
(logical_getcwd, main): Likewise. Constify the result of getenv, since
the result cannot be modified.
Collin Funk [Sun, 7 Dec 2025 01:19:55 +0000 (17:19 -0800)]
shred: use gethrxtime instead of time
The gethrxtime function uses a monotonic clock if available on the
system. The effect should be unnoticeable since we print --verbose
information every 5 seconds, but is more correct and we already do the
same in 'dd'.
* src/local.mk (src_shred_LDADD): Add $(GETHRXTIME_LIB).
* src/shred.c (dopass): Use xtime_t instead of time_t. Use gethrxtime
instead of time.