tests: dd: ensure nocache flag does not fail with pipes
* tests/dd/nocache.sh: Whether fadvise() is called (uutils)
or avoided (GNU), ensure there is no failure when nocache
is only the ancillary operation being requested.
oech3 [Thu, 4 Jun 2026 11:15:40 +0000 (20:15 +0900)]
tests: cat: extract checks for distinct read/write errors
* tests/cat/splice.sh: Move read/error distinction test to ...
* tests/cat/cat-distinct-err.sh: ... here, and augment.
* tests/local.mk: Reference the new file.
Guanqiang Han [Tue, 7 Jul 2026 14:58:43 +0000 (22:58 +0800)]
pr: guard input position update against overflow
* src/pr.c (char_to_clump): Use ckd_add() and report integer overflow.
* tests/pr/options.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/81393
$ src/factor 22486472939460651857
src/factor.c:888:36: runtime error:
index 675 out of bounds for type 'int_least16_t [675]'
* src/factor.c (factor_using_division): Guard the final unrolled block
before reading a subsequent prime.
* tests/factor/factor.pl: Add a test case.
* NEWS: Mention the bug fix.
Problem caught by Coverity analysis.
* doc/coreutils.texi (touch invocation): Use lower case for @var{}.
This is ambiguous for MM and mm, but these are not ambiguous
from the context, so shouldn't cause confusion.
Paul Eggert [Thu, 9 Jul 2026 23:35:32 +0000 (16:35 -0700)]
touch: improve -d documentation
* doc/coreutils.texi (touch invocation):
Describe -d behavior for HH:MM:60 (Bug#81331), as it seems that a
future version of POSIX will bless GNU touch here.
Be clearer about POSIX vs GNU extensions with -d.
* doc/coreutils.texi (mv invocation): Copy most of the -n
description from the cp --no-clobber description.
* src/mv.c (usage): Likewise. Note this explicitly deprectates
the mv -n option as like cp the exit code varies across platforms.
Solaris 11 was seen to silently fail, while Linux/FreeBSD succeed.
Fixes https://bugs.gnu.org/81377
tests: numfmt: check --header does not swallow a following operand
* tests/numfmt/numfmt.pl (header-10): New test verifying that --header,
which only accepts an argument via '=', does not consume a following
operand as its value.
https://github.com/uutils/coreutils/pull/13273
tests: ls: check that an invalid --tabsize is diagnosed
* tests/ls/ls-misc.pl: Add tests, generated by a loop over invalid
values, verifying that a negative (-9), non-numeric (zz), or
fractional (0.5) --tabsize argument is rejected with
"invalid tab size" and exit status 2.
https://github.com/uutils/coreutils/pull/13278
* NEWS: Mention the bug fix.
* src/du.c (main): Prefer ckd_add to check for overflow. Emit an error
if the value is negative.
* tests/du/max-depth.sh: Add a test case for the bug.
tests: nproc: support referencing of external command
* tests/nproc/nproc-quota.sh: Use command -v nproc instead of
$abs_top_builddir for external usage of tests.
Also quote "$nproc" usage, to support spaces in path.
tests: nproc: support more general syscall injection
* tests/nproc/nproc-quota.sh: Prefer strace to LD_PRELOAD,
as it's simpler and supports static executables.
https://github.com/coreutils/coreutils/issues/309
tests: avoid false failure where mknod() can't create sockets
* tests/mv/mv-special-1.sh: Adjust the python probe to more
closely match how copy.c creates sockets, as otherwise we
get a false failure on systems where mknod() fails with S_IFSOCK,
which was seen on Solaris and FreeBSD at least.
* tests/mv/mv-special-2.sh: Adjust similarly as this
was a latent issue on this root only test.
Reported by Bruno Haible.
Pádraig Brady [Thu, 25 Jun 2026 20:03:00 +0000 (22:03 +0200)]
tests: mv: check cross-fs replacement with special files
* tests/mv/mv-special-1.sh: Moving a socket onto an existing file
on another file system must replace that file, and not for example
unlink the destination first and then fail, leaving the user
with neither file.
Sylvestre Ledru [Sat, 27 Jun 2026 09:02:51 +0000 (11:02 +0200)]
tests: shuf: check -o output is preserved when the run fails
A failed shuf invocation should leave an existing output file untouched
rather than truncating it before the failure is detected.
* tests/shuf/shuf.sh: Verify that a missing input file or an unreadable
random source leaves an existing -o file unchanged.
Sylvestre Ledru [Sun, 28 Jun 2026 09:27:19 +0000 (11:27 +0200)]
tests: ls: check C1 control char escaping in UTF-8 quoting
* tests/ls/quoting-utf8.sh: A non-ASCII C1 control character (U+0085
NEL) is not printable, so locale/clocale quoting must octal-escape its
bytes (\302\205) rather than emit them literally. Add a file named
with U+0085 and verify the escaped form for both styles.
gap identified here: https://github.com/uutils/coreutils/pull/13150
Sylvestre Ledru [Sun, 28 Jun 2026 12:27:46 +0000 (14:27 +0200)]
tests: realpath: a trailing slash must not require read permission
A trailing slash only asserts that the operand is a directory. That
is a stat-level check, needing search permission on the parent, not
read permission on the directory itself.
* tests/misc/realpath.sh: Check that a searchable but unreadable
directory still resolves with a trailing slash, with and without -e.
Sylvestre Ledru [Thu, 25 Jun 2026 19:14:00 +0000 (21:14 +0200)]
tests: cp: --remove-destination must honor the same-file check
* tests/cp/same-file.sh: A different spelling of the same path
('foo' vs './foo') must still be detected as the same file, so
--remove-destination refuses instead of unlinking the source.
* src/uniq.c: Include assure.h.
(writeline): Convert the value to a string by hand and use fwrite, which
may be unlocked, instead of printf.
* tests/uniq/uniq-c-width.sh: New test to verify the padding logic.
* tests/local.mk (all_tests): Add the test case.
* NEWS: Mention the improvement.
Collin Funk [Tue, 23 Jun 2026 02:36:47 +0000 (19:36 -0700)]
cksum: remove the ability to use AF_ALG
* gnulib: Update to latest gnulib for commit e191cc8118 (crypto/af_alg:
Deprecate., 2026-06-22).
* NEWS: Mention the removal of the --with-linux-crypto configure option.
* doc/coreutils.texi (Hardware Acceleration): Remove the reference to
--with-linux-crypto and the Linux kernel cryptographic API.
Paul Eggert [Sat, 20 Jun 2026 19:14:55 +0000 (12:14 -0700)]
dd: work around Linux kernel CLOCK_MONOTONIC bug
Problem reported by Sick Pigs (bug#81269).
Ordinarily we’d say “fix the kernel or the hardware”,
but this bug seems widespread and unlikely to be fixed any time soon,
and the workaround is not a lot of trouble.
* src/dd.c (real_start_time): New static var.
(getrealxtime): New static function.
(print_xfer_stats): Use the max of elapsed monotonic and elapsed
real time.
aizu-m [Fri, 19 Jun 2026 06:53:03 +0000 (12:23 +0530)]
wc: fix out-of-bounds read for single-byte wide characters
In legacy CJK locales a single input byte can decode to a wide character
above UCHAR_MAX, e.g. SHIFT-JIS bytes 0xA1..0xDF become U+FF61..U+FF9F.
wc then indexed its 256-entry wc_isprint/wc_isspace tables with that
value and read past their end.
* src/wc.c (wc): Take the byte-indexed fast path only when the decoded
character fits in a byte; wider values fall through to c32width and
c32isspace.
* tests/wc/wc-sjis.sh: New test.
* tests/local.mk (all_tests): Add it.
* NEWS: Mention the fix.
Pádraig Brady [Sat, 13 Jun 2026 14:50:53 +0000 (23:50 +0900)]
tests: nproc: ensure scheduler and OMP_NUM_THREADS are independent
* tests/nproc/nproc-quota-systemd.sh: Explicitly set OMP_NUM_THREADS
to an ignorable value, to ensure scheduler processing is independent.
* tests/nproc/nproc-quota.sh: Likewise for the SCHED_FIFO check.
https://github.com/coreutils/coreutils/pull/290
Collin Funk [Sun, 14 Jun 2026 02:34:51 +0000 (19:34 -0700)]
build: update gnulib submodule to latest
This imports a xstrtol-error change from Gnulib that fixes some error
messages that were not properly escaped when given an invalid integer
argument.
* .gitignore: Add /lib/thread-creators.h which is generated by Gnulib.
* gnulib: Update to the latest commit.
* tests/od/od.pl (@Tests): Add some test cases.
* NEWS: Mention the improvement.
Pádraig Brady [Wed, 10 Jun 2026 06:02:40 +0000 (11:32 +0530)]
cut: fix NUL termination of multi-byte field delimiter
* src/cut.c (delim_bytes): Add a spare byte so a maximum-length
multi-byte delimiter stays NUL terminated for the strstr needle in
find_field_delim. Note in 9.11 this buffer was larger (16 bytes)
and so didn't not have a buffer over-read issue.
(main): Ensure DELIM_BYTES is NUL terminated after each --delimeter.
Also explicitly writing the NUL allows for better testing by
triggering overflow issues in default builds, if the buffer
is not sized correctly.
* NEWS: Mention the bug fix.
* tests/cut/cut.pl: Add test cases.
Reported at https://github.com/coreutils/coreutils/pull/286
aizu-m [Tue, 9 Jun 2026 07:07:06 +0000 (12:37 +0530)]
unexpand: fix heap overflow when a wide blank overshoots a tab stop
* NEWS: Mention the bug fix.
* src/unexpand.c (unexpand): Check if the column is greater or equal to
the next_tab_column.
* tests/unexpand/mb.sh: Add a test case.
https://github.com/coreutils/coreutils/pull/285
Copyright-paperwork-exempt: Yes
Sylvestre Ledru [Sun, 7 Jun 2026 09:43:43 +0000 (11:43 +0200)]
tests: ls: cover two-line --time-style format assignment
* tests/ls/ls-time.sh: Check that with a "FORMAT1 NEWLINE FORMAT2"
--time-style, FORMAT1 is used for non-recent (old) files and FORMAT2
for recent files.
Identified here: https://github.com/uutils/coreutils/issues/12676
Closes https://github.com/coreutils/coreutils/pull/281
Sylvestre Ledru [Sun, 7 Jun 2026 09:54:40 +0000 (11:54 +0200)]
tests: split: reject excessively large suffix lengths
* tests/split/suffix-length.sh: Ensure that a pathologically large
-a/--suffix-length value fails gracefully rather than crashing or
hanging.
https://github.com/uutils/coreutils/pull/12609
Closes https://github.com/coreutils/coreutils/pull/282
Sylvestre Ledru [Sun, 7 Jun 2026 09:58:49 +0000 (11:58 +0200)]
tests: sort: cover punctuation weight in locale collation
* tests/sort/sort-locale.sh: In a UTF-8 locale '-' carries a minimal
(shifted) weight, so 'file1' sorts before 'file-2' even though '-'
precedes '1' in the C/byte order. This is the opposite of the C locale
result, so it also exercises the differs-from-C path.
Identified here: https://github.com/uutils/coreutils/pull/12677
Closes https://github.com/coreutils/coreutils/pull/283
* tests/date/date.pl: Add tests covering a leading day-of-week name,
out-of-range zone minutes, two timezone tokens, a bare sign operand,
a trailing token after an @epoch operand, operand quoting in
diagnostics, and a '+N unit' suffix following a complete time.
* tests/date/date-tz.sh: Add tests covering daylight-saving gap,
and overlap local times.
Closes https://github.com/coreutils/coreutils/pull/284
Collin Funk [Sun, 7 Jun 2026 23:43:50 +0000 (16:43 -0700)]
nohup: port to mingw
* bootstrap.conf (gnulib_modules): Add execvp which as a different
prototype on Windows along with other issues mentioned in the Gnulib
manual.
* src/nohup.c (main): Check if SIGHUP is defined.
Sylvestre Ledru [Sat, 6 Jun 2026 06:11:52 +0000 (08:11 +0200)]
tests: ls: also check a trailing '/.' dereferences a symlink arg
* tests/ls/symlink-slash.sh: A symlink-to-directory argument written as
'symlink/.' denotes the directory itself, just like a trailing slash, so
'ls -l symlink/.' must list the directory contents rather than show the
symlink.
See https://github.com/uutils/coreutils/issues/7873
and https://github.com/uutils/coreutils/issues/6467
https://github.com/coreutils/coreutils/pull/280
Pádraig Brady [Wed, 3 Jun 2026 15:31:39 +0000 (16:31 +0100)]
stat: change default quoting from shell-escape-always to shell-escape
This should not affect programatic parsing, because if you have to parse
the shell style, then the same logic will parse unescaped output.
This is a better default now that --terse uses quoted format by default,
and also the default output format quotes file names by default.
* src/stat.c (getenv_quoting_style): Change the default.
Pádraig Brady [Wed, 3 Jun 2026 15:04:09 +0000 (16:04 +0100)]
stat: honor QUOTING_STYLE in default file name quoting
This is safer to output to terminal with malicious file names,
with multiple lines or control characters etc.
* src/stat.c: Quote the file name in the default output format
in the default quoting style, or as selected with QUOTING_STYLE.
Reported by Michał Majchrowicz and Marcin Wyczechowski.
The previous commit is not sufficient to fix the race,
since I forgot shred now opens with O_NONBLOCK, and so cat may
not be even reading by the time shred's open() returns.
* tests/shred/fifo.sh: Put more robust synchronization in place
along the lines of what we did in commit v9.11-47-ga6ba6a23a,
using a separate fifo_writer_ to ensure the cat is reading,
before shred runs.
Sylvestre Ledru [Mon, 1 Jun 2026 18:00:00 +0000 (20:00 +0200)]
tests: date: check fixed offset is anchored before relative items
A fixed-offset keyword such as 'UTC' must anchor the instant before
relative items are applied, so that '1970-01-01 UTC N seconds' is
exactly N seconds past the epoch even when the local zone observes
DST between the epoch and the result.
* tests/date/date-tz.sh: Add a relative-seconds-across-DST case.
https://github.com/coreutils/coreutils/pull/275
Sylvestre Ledru [Fri, 29 May 2026 22:43:06 +0000 (00:43 +0200)]
tests: cover symlink-cycle detection in chmod/chown -RL
With -L, a recursive chmod/chown follows symlinks while descending;
a symlink pointing back to an ancestor forms a cycle that must be
detected and not descended into forever.
* tests/chmod/symlinks.sh: Add a symlink-cycle case for chmod -RL.
* tests/chown/deref.sh: Likewise for chown -RL.
https://github.com/coreutils/coreutils/pull/274
Sylvestre Ledru [Sat, 30 May 2026 16:03:31 +0000 (18:03 +0200)]
tests: cksum: check truncated digests are flagged as malformed
* tests/cksum/cksum-c.sh: A tagged checksum line with a valid algorithm
but a hex digest of the wrong (truncated) length must be reported as
improperly formatted rather than as a checksum mismatch (FAILED).
See https://github.com/uutils/coreutils/issues/6576
https://github.com/coreutils/coreutils/pull/273
Sylvestre Ledru [Sat, 30 May 2026 12:55:37 +0000 (14:55 +0200)]
tests: chown: check --no-dereference on a symlink to a directory
* tests/chown/basic.sh: Add a case ensuring that "chown
--no-dereference" on a symlink to a directory operates on the link
itself and does not dereference it to change the owner of the target
directory.
https://github.com/coreutils/coreutils/pull/272
Pádraig Brady [Sat, 30 May 2026 11:05:45 +0000 (12:05 +0100)]
maint: document .UR man macro
We currently prefer the 'tty: link' style for representing URIs
in man pages, as this falls back to _not_ displaying the URI
where not supported, whereas the .UR macro generally does fall back
to showing the URI, which has these disadvantages:
- They're long, redundant, and interfere when reading text
- With wrapping enabled with \: in the URI, it can become unclickable
- Without wrapping enabled it interferes in adjacent text justification
Note with groff >= 1.24 (March 2026), the .UR macro results
in OSC 8 hyperlinks being used, and thus the awkward URI is not
displayed.
* man/viewman: Configure groff 1.23 to display .UR macros
with OSC 8 hyperlinks.
Sylvestre Ledru [Sun, 24 May 2026 15:51:11 +0000 (17:51 +0200)]
tests: ls: verify in-group ordering with --group-directories-first
* tests/ls/group-dirs.sh: Check that entries within each group remain
alphabetically sorted, and that equal-size files keep a deterministic
order when combined with --sort=size.
https://github.com/uutils/coreutils/issues/11997
https://github.com/coreutils/coreutils/pull/267
Sylvestre Ledru [Mon, 25 May 2026 17:35:42 +0000 (19:35 +0200)]
tests: sort: check sort -m preserves long lines
* tests/sort/sort-merge.pl: Add 'long-lines' case ensuring that
merging input whose lines exceed the read buffer does not split
lines on buffer boundaries.
https://github.com/coreutils/coreutils/pull/270
Sylvestre Ledru [Fri, 29 May 2026 16:55:48 +0000 (18:55 +0200)]
tests: stat: cover %N escaping of control characters
The default shell-escape quoting style escapes control characters in
file names (e.g. newlines) as $'...' sequences, but no test exercised
this; only the single-quote character was covered.
referenced here: https://github.com/uutils/coreutils/issues/9925
* tests/stat/stat-fmt.sh: Add a case with a file name containing
contiguous and separated newlines.
https://github.com/coreutils/coreutils/pull/271
Collin Funk [Wed, 27 May 2026 02:39:29 +0000 (19:39 -0700)]
printenv: remove unsupported short options from getopt_long
This patch only improves some error messages. Here is the behavior
before the patch:
$ printenv -i
Try 'printenv --help' for more information.
$ printenv -u
printenv: option requires an argument -- 'u'
Try 'printenv --help' for more information.
$ printenv -u a
Try 'printenv --help' for more information.
Here is the behavior after:
$ ./src/printenv -i
./src/printenv: invalid option -- 'i'
Try './src/printenv --help' for more information.
$ ./src/printenv -u
./src/printenv: invalid option -- 'u'
Try './src/printenv --help' for more information.
$ ./src/printenv -u a
./src/printenv: invalid option -- 'u'
Try './src/printenv --help' for more information.
* src/printenv.c (main): Remove 'i' and 'u' from the short options given
to getopt_long.
Pádraig Brady [Mon, 25 May 2026 14:56:34 +0000 (15:56 +0100)]
head,tail: quote name in file headers appropriately
* src/tail.c (write_header): Use quotef() to quote
file names when needed.
* src/head.c (write_header): Likewise.
* tests/head/quote-headers.sh: Add a new test.
* tests/tail/quote-headers.sh: Add a new test.
* tests/local.mk: Reference the new test.
Reported by Michał Majchrowicz.
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