1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-11 09:51:56 +02:00
Commit Graph

31035 Commits

Author SHA1 Message Date
Collin Funk
3621ad2f71 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.
2026-01-10 12:42:13 -08:00
Pádraig Brady
a9aad49f26 maint: remove redundant processing in a test
* tests/misc/write-errors.sh: This was a no-op anyway
due to inadequate escaping.  Also document the escaping requirement.
2026-01-10 01:04:33 +00:00
Pádraig Brady
19d2d707f7 du: promptly diagnose write errors
* src/du.c (print_size): Call write_error() if can't flush.
* tests/misc/write-errors.sh: Add a test case.
* NEWS: Mention the improvement.
2026-01-10 01:04:33 +00:00
Pádraig Brady
83f274feaa wc: promptly diagnose write errors
* src/wc.c (write_counts): Call write_error() if any pending errors.
* tests/misc/write-errors.sh: Add a test case.
* NEWS: Mention the improvement.
2026-01-10 01:04:33 +00:00
Collin Funk
b34e329f75 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.
2026-01-08 23:16:06 -08:00
Pádraig Brady
9200747f65 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
2026-01-08 16:14:57 +00:00
Pádraig Brady
9a38863885 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.
2026-01-08 12:08:14 +00:00
Pádraig Brady
e1cbe82cc6 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).

Reported by Bruno Haible on macOS 26
2026-01-08 12:08:14 +00:00
Pádraig Brady
30d296dcb8 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
2026-01-08 12:08:14 +00:00
Sylvestre Ledru
b7613ac8ff tests: date: test parenthesis comment handling
* tests/date/date.pl: Add the check.
2026-01-07 19:58:55 -08:00
Collin Funk
0fcdd37fbd maint: organize mktemp tests in a subdirectory
* tests/misc/mktemp.pl: Moved to tests/mktemp/mktemp.pl.
* tests/local.mk (all_tests): Adjust the file name.
2026-01-06 18:52:48 -08:00
Collin Funk
1f1bce27d7 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.
2026-01-06 18:52:48 -08:00
Pádraig Brady
33bc44e1ba 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.
2026-01-06 20:41:15 +00:00
Pádraig Brady
c43f517e2a 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
2026-01-06 20:35:44 +00:00
Christopher Illarionova
1afe4109f2 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
2026-01-06 18:55:47 +00:00
Pádraig Brady
a3ae4123f9 doc: tr: warn about shell quoting [:classes:]
* src/tr.c (usage): Warn about avoiding shell globbing.
* doc/coreutils.texi (character arrays): Likewise.
Suggested by Daniel Dallos.
2026-01-06 18:41:00 +00:00
Pádraig Brady
7531d3a205 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.
2026-01-05 23:37:49 +00:00
Christopher Illarionova
e1994cd9ac 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
2026-01-05 17:20:54 +00:00
Collin Funk
2e0c328a3b maint: mknod: reduce variable scope
* src/mknod.c (main): Declare variables where they are used instead of
at the start of a block. Prefer signed integers to unsigned integers.
2026-01-04 13:47:01 -08:00
Collin Funk
e4e40b7df6 maint: mkfifo: reduce variable scope
* src/mkfifo.c (main): Declare variables where they are used instead of
at the start of a block.
2026-01-04 13:46:41 -08:00
Pádraig Brady
bd528f9234 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
2026-01-04 20:20:04 +00:00
Pádraig Brady
71e0be29f1 tests: chmod: ensure failure upon partial success
* tests/chmod/partial-fail.sh: Add new test.
* tests/local.mk: Reference new test.
Discussed at https://github.com/uutils/coreutils/issues/9790
2026-01-03 14:45:07 +00:00
oech3
1170bc9489 tests: split: ensure directories not replaced
* tests/split/split-io-err.sh: Add a test case.
From https://github.com/coreutils/coreutils/pull/158
2026-01-03 14:27:55 +00:00
Collin Funk
ae5ceffc13 doc: NEWS: mention du performance improvement on the Lustre file system
Reported by Tim Day <timday@amazon.com> in
<https://bugs.gnu.org/80106>.

* NEWS: Mention the improvement after gnulib commit 578b8d7dc5.
2026-01-02 19:29:11 -08:00
Collin Funk
3424ae3efa build: update gnulib submodule to latest
* bootstrap: Update using './bootstrap --bootstrap-sync'.
* tests/sample-test: Adjust to use the single most recent year.
2026-01-01 20:50:59 -08:00
Collin Funk
bdb6148fdc maint: prefer c_isblank to an equivalent macro
* src/cksum.c (ISWHITE): Remove macro.
(bsd_split_3, algorithm_from_tag, split_3): Use c_isblank instead of
ISWHITE.
2026-01-01 19:10:30 -08:00
Collin Funk
9cdeeea7c2 tests: df: don't depend on bash
* tests/df/no-mtab-status-masked-proc.sh: Invoke $SHELL instead of
'bash'.
2026-01-01 19:07:51 -08:00
Collin Funk
73d3a49f45 maint: run 'make update-copyright' 2026-01-01 10:56:16 -08:00
Sylvestre Ledru
cd08aa2056 tests: mv: check broken symlink cross-filesystem move
Identified here:
<https://github.com/uutils/coreutils/issues/8586>

* tests/mv/mv-special-2.sh: Add the check.
2026-01-01 13:43:15 +00:00
oech3
92a93c445b 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
2026-01-01 13:18:51 +00:00
oech3
3f0ab90497 tests: add LD_PRELOAD free alternative for nproc-quota.sh
* tests/nproc/nproc-quota-systemd.sh: Add a new root test.
* tests/local.mk: Reference the new test.
2026-01-01 12:24:50 +00:00
oech3
6a2a781efd tests: extend csplit-io-err.sh for directory
* tests/csplit/csplit-io-err.sh: Add a test case
to ensure a directory is _not_ replaced.
2026-01-01 11:50:07 +00:00
Sylvestre Ledru
75e314a11a tests: du: check -l (--count-links) without -a flag
Identified here:
<https://github.com/uutils/coreutils/issues/9871>

* tests/du/hard-link.sh: Add the check.
2025-12-31 00:01:51 +00:00
Collin Funk
d3f0c72902 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.
2025-12-29 21:26:22 -08:00
Collin Funk
d45598f237 tests: kill: check that real-time signals are listed
* tests/misc/kill.sh: Call getlimits_. Check for RTMIN and RTMAX in the
output of 'kill -l' if the system defines SIGRTMIN and SIGRTMAX.
2025-12-27 21:48:42 -08:00
Collin Funk
7e1b4f76d3 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.
2025-12-27 17:03:39 -08:00
Collin Funk
1902c97d67 maint: commit-msg: add 'getlimits' as a supported tag
* scripts/git-hooks/commit-msg (@valid): Add getlimits.
2025-12-27 17:03:39 -08:00
oech3
0ffd9a1812 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.
2025-12-27 16:55:53 +00:00
Pádraig Brady
e10205bab2 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.
2025-12-27 16:55:48 +00:00
Pádraig Brady
6382388da8 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.
2025-12-27 16:27:43 +00:00
oech3
1b467784fb 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.
2025-12-27 12:48:57 +00:00
oech3
60f48bbda6 tests: csplit: check writing to /dev/full
* tests/csplit/csplit-io-err-2.sh: Add a new test.
* tests/local.mk: Reference new test.
2025-12-26 14:59:39 +00:00
Collin Funk
b12593d124 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.
2025-12-25 15:16:57 -08:00
Pádraig Brady
7c1bc64d38 doc: document the date(1) bug with empty format directives
* NEWS: Mention the bug fix.
2025-12-25 14:30:59 +00:00
Pádraig Brady
78c8447a98 build: update gnulib to latest 2025-12-25 14:25:58 +00:00
Collin Funk
18405cb51a tests: date: improve locale tests
* tests/date/date-locale-hour.sh: Test that the default format of 10
random supported locales is the same as 'locale date_fmt'.
2025-12-24 18:41:34 -08:00
Pádraig Brady
95044cb5ea tests: avoid false failure due to ulimit on aarch64
* tests/cut/cut-huge-range.sh: Add an extra 1MiB headroom,
which was seen with aarch64.
Reported at https://bugzilla.redhat.com/2424302
2025-12-22 17:12:48 +00:00
Pádraig Brady
e34734cdf9 maint: tests/cut/cut-huge-range.sh: remove stale comment
* tests/cut/cut-huge-range.sh: expr supports bignums,
so remove stale comment relating to previous non expr adjustment.
2025-12-22 15:24:07 +00:00
Pádraig Brady
955dfdafa2 numfmt: fix dropped custom suffix when failing to parse
* src/numfmt.c (process_suffixed_number): Restore custom suffix
upon failure to parse number.
* tests/numfmt/numfmt.pl: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.debian.org/1094581
2025-12-22 13:17:37 +00:00
Collin Funk
1313c24056 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.
2025-12-20 17:25:32 -08:00