1843 Commits

Author SHA1 Message Date
Pádraig Brady
87219034b7 doc: use TERM=dumb rather than HELP_NO_MARKUP to disable markup
This is a more standard mechanism to disable markup.

* src/system.h (oputs_): Logic change to honor TERM=dumb,
rather than HELP_NO_MARKUP=something.
* doc/coreutils.texi: Adjust the description for --help.
* man/local.mk: Ensure TERM is set to something,
so that man pages have links included.
* man/viewman: Just honor users $TERM.
* tests/misc/getopt_vs_usage.sh: Remove env var complication,
as TERM is unset automatically.
* tests/misc/usage_vs_refs.sh: Likewise.
* NEWS: Adjust the change in behavior note.
2026-01-22 11:42:47 +00:00
Pádraig Brady
28c29d103e stat,tail: sync with latest Linux file systems
* src/stat.c (human_fstype): Add "guest-memfd".
* NEWS: Mention the improvement.
2026-01-21 16:29:03 +00:00
Pádraig Brady
dfeb32f6e2 ls: --hyperlink: switch to more standard delimiters
* src/ls.c (quote_name): Use ST (ESC \) rather than BEL,
as that's the only terminator mentioned in at least
ECMA-48, DEC STD 070, and EK-VT520-RM.
* NEWS: Mention the change in behavior.
* tests/ls/hyperlink.sh: Adjust accordingly.

Suggested by Egmont Koblinger.
2026-01-21 14:05:48 +00:00
Pádraig Brady
7dfe08316d doc: NEWS: describe the --help markup configuration options
* NEWS: Mention build and runtime config options.
2026-01-21 14:05:48 +00:00
Pádraig Brady
331c5f6857 build: update to latest gnulib
* gnulib: Update to latest.
* NEWS: Mention the bug fix.
https://github.com/coreutils/coreutils/issues/176
2026-01-19 17:57:59 +00:00
Pádraig Brady
6b32a0bbde all: with multi-call binary, only process options for known names
Setup
  $ ln -nsf src/coreutils foo

Before
  $ ./foo; echo $?
  foo: unknown program ‘foo’
  Try './foo --help' for more information.
  1
  ./foo --version; echo $?
  coreutils (GNU coreutils) 9.9.172-01993
  0

After
  $ ./foo; echo $?
  coreutils: unknown program 'foo'
  1
  $ ./foo --version; echo $?
  coreutils: unknown program 'foo'
  1

* src/coreutils.c (main): Don't process options if
we don't know they're intended for the multi-call binary.
Otherwise `foo --version` would return true, even though
foo was symlinked to the multi-call binary, but not supported.
* tests/misc/coreutils.sh: Add test cases.
* NEWS: Mention the change in behavior.
2026-01-15 15:54:29 +00:00
Pádraig Brady
495e3528d7 fmt: correctly diagnose read errors
* src/fmt.c (fmt): Pass errno to error() so that
the particular error is diagnosed.
* NEWS: Mention the improvement.
2026-01-13 15:08:03 +00:00
Pádraig Brady
06d228043f paste: support multi-byte delimiters
* src/paste.c (collapse_escapes): This is the central --delimiters
parsing function, so adjust to handle multi-byte chars with
mcel_scanz().  Populate a delimiters length array to support
characters of differing lengths.
(paste_serial): Use the delimiters length array to output
the appropriate delimiter.
(paste_parallel): Likewise.
* tests/paste/multi-byte.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
2026-01-13 14:32:01 +00:00
Pádraig Brady
204dc3bce4 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.
2026-01-11 12:54:17 +00:00
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
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
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
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
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
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
73d3a49f45 maint: run 'make update-copyright' 2026-01-01 10:56:16 -08: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
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
Pádraig Brady
cd52292221 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.
2025-12-13 17:18:47 +00:00
Collin Funk
3c405ae0b6 pinky: promptly diagnose write errors
In some cases 'pinky' could run forever until interrupted:

    $ ln -s /dev/zero ~/.plan
    $ ln -s /dev/zero ~/.project
    $ timeout -v 5 pinky -l collin > /dev/full
    timeout: sending signal TERM to command ‘pinky’

After this change it will exit upon failing to write to standard output:

    $ timeout -v 5 ./src/pinky -l collin > /dev/full
    pinky: write error: No space left on device

* src/pinky.c: Include fadvise.h, filenamecat.h, full-write.h, and
ioblksize.h.
(cat_file): New function.
(print_entry): Check if standard output has it's error flag set after
printing a user entry.
(print_long_entry): Likewise. Use the new cat_file function.
* NEWS: Mention the improvement.
2025-12-05 15:42:16 -08:00
Collin Funk
c00a094188 timeout: print the signal number 0 instead of EXIT
POSIX.1-2024 added sig2str but leaves the behavior when called with
signal 0 unspecified. FreeBSD 15.0 does not return the signal name EXIT
like Gnulib's version causing a test failure. This fixes that and
changes the behavior to print 0 instead of EXIT, to avoid confusion when
the program does not exit.

* NEWS: Mention the change.
* src/timeout.c (cleanup): Use snprintf instead of sig2str if the signal
is 0.
* tests/timeout/timeout.sh: Updated the expected output.
2025-12-02 19:16:23 -08:00
Collin Funk
68e39a581a maint: remove note about old NEWS files
* NEWS: Remove mention about old fileutils, textutils, and sh-utils NEWS
files that were removed in commit 2c64bc872 (doc: only distribute 5
years of ChangeLogs, 2017-01-31).
* cfg.mk (old_NEWS_hash): Run 'make update-NEWS-hash'.
2025-11-29 11:56:26 -08:00
Pádraig Brady
fc5c7b2e47 timeout: ensure we terminate command upon abnormal exit
* src/timeout.c (main): Use PR_SET_PDEATHSIG to ensure the
child is terminated even if the parent terminates abnormally.
* tests/timeout/timeout-group.sh: Add a case to ensure sending
SIGKILL results in the termination of the monitored command.
* NEWS: Mention the improvement.
2025-11-29 12:17:27 +00:00
Collin Funk
90856dd867 du: add the short option -A corresponding to --apparent-size
The --apparent-size option to 'du' was added in
coreutils-4.5.8 (2003). FreeBSD 8.0 (2009) added the same functionality
under the short option -A. This long option previously had no short
option, so this patch adds -A to be compatible with FreeBSD.

* NEWS: Mention the new short option.
* doc/coreutils.texi: Document the short option.
* src/du.c (usage): Likewise.
(APPARENT_SIZE_OPTION): Remove definition.
(EXCLUDE_OPTION): Define to CHAR_MAX + 1.
(long_options): Use the -A short option for --apparent-size.
(main): Likewise.
* tests/du/apparent.sh: Test that '-b', '-A -B 1', and
'--apparent-size --block-size 1' function the same.
2025-11-28 14:08:31 -08:00
Pádraig Brady
6b399ad352 build: kill(1), uptime(1): don't install by default
* build-aux/gen-lists-of-programs.sh: kill and uptime are not installed
by arch, debian, fedora, suse at least, so add to disabled list.
Fixes https://github.com/coreutils/coreutils/issues/132
* NEWS: Mention the build change.
2025-11-25 13:45:44 +00:00
Paul Eggert
2199c9003e du,ls: don’t modify getenv strings
Fix du and ls to conform to the POSIX getenv spec,
which says you can’t modify strings returned by getenv
unless you put the string there directly, or used putenv.
This portability bug was found by strict C23 checking
using qualifier-generic functions.
* bootstrap.conf (gnulib_modules): Add xmemdup0.  Sort.
* src/du.c (main):
* src/ls.c (decode_switches):
Don’t modify the string that getenv returns.
Instead, use xmemdup0 if needed, and include xmemdup0.h.
2025-11-23 12:00:09 -08:00
Pádraig Brady
e63131b326 csplit,ls,sort: handle a more complete set of signals
* src/term-sig.h: A new file defining a TERM_SIG array signals.
* src/local.mk: Reference the new file.
* src/csplit.c: Likewise.
* src/sort.c: Likewise.
* src/timeout.c: Likewise.
* src/ls.c: Likewise.  Also handle SIGTSTP separately.
* NEWS: Mention the improvement.
2025-11-22 12:43:28 +00:00
Pádraig Brady
8c24619334 timeout: honor ignored signal dispositions
This behavior was depended on in our trap_sigpipe_or_skip_ helper,
and now that we're handling all terminating signals, we should
consistently honor their ignored signal dispositions.

* NEWS: Mention the change in behavior, especially in regard
to shell background jobs.
* src/timeout.c (sig_needs_handling): A new helper that return TRUE,
for --signal, SIG_ALRM, or non ignored signals.
(cleanup_install): Filter handled signals with the helper.
(block_cleanup_and_chld): Likewise.
* tests/timeout/timeout-group.sh: Adjust to use the now required
`env --default-signal=...` wrapper to reset (auto) ignored signals.
Also change the termination signal from SIGINT to SIGUSR1
to generalize the test signals not specially handled by the shell,
and newly handled by timeout(1).
* tests/timeout/timeout.sh: Add a test case for SIGPIPE
to ensure the ignored signal disposition is honored.
2025-11-22 08:49:20 +00:00
Pádraig Brady
d0a51c614d timeout: handle all terminating signals
* src/timeout.c (term_sig): A new global list of all signals
whose default disposition is to terminate the process.
(install_cleanup): Iterate over the TERM_SIG list, rather than
installing the handler for a specific subset.
(block_cleanup_and_chld): Likewise.
* tests/timeout/timeout.sh: Add a test case for SIGPIPE.
* NEWS: Mention the bug fix.
2025-11-21 12:12:28 +00:00
Pádraig Brady
59d9f05ef7 build: support --enable-single-binary=hardlinks
* Makefile.am: Use ln rather than $(LN_S) for hardlinks.
* configure.ac: Accept --enable-single-binary=hardlinks.
* man/local.mk: In hardlink mode, explicitly add the
hardlink creation rule to mandeps.  Given the automake
generated dependency chain, this ensures that the hardlinks
are created _after_ the multicall binary, with `make all`
or `make check` etc.
* src/local.mk: Define the new src/coreutils_hardlinks rule,
and only depend on src/coreutils_{symlinks,shebangs} if
in those modes, so that hardlinks are created _after_
the multicall binary, and other link types before.
* NEWS: Mention the new feature.
Addresses https://github.com/coreutils/coreutils/issues/129
2025-11-19 14:38:27 +00:00
Pádraig Brady
d611bcbfff tail: add --debug to report the --follow implementation
* doc/coreutils.texi (tail invocation): Describe --debug.
* src/tail.c (tail_forever, tail_forever_inotify): Output
which --follow implementation is being used.
* tests/tail/debug.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2025-11-17 13:55:12 +00:00
Pádraig Brady
f8137811d9 wc: fix missing documentation for the --debug option
* doc/coreutils.texi (wc invocation): Desscribe --debug.
* src/wc.c (usage): Likewise.
* NEWS: Mention the bug fix.
2025-11-16 17:18:03 +00:00
Pádraig Brady
6f265b515e md5sum: fix --text with the MSYS2 runtime
Note the use of "rt" is non-standard, but we're restricting
its use here to systems that define O_BINARY, which should
invariably support "rt" mode.

* src/digest.c (): Where significant, explicitly use "rt" mode
with --text, as MSYS2 defaults to binary mode for fopen'd files
(though not for standard streams).
* NEWS: Mention the bug fix.
Fixes https://github.com/coreutils/coreutils/issues/123
2025-11-12 14:11:27 +00:00
Pádraig Brady
f7be1e51a3 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2025-11-10 13:54:30 +00:00
Pádraig Brady
0ae5bdc7a8 version 9.9
* NEWS: Record release date.
2025-11-10 13:21:59 +00:00
Collin Funk
fc93a44bbe nice: clamp the niceness correctly on GNU/Hurd
* NEWS: Mention the bug fix.
* src/nice.c (MIN_ADJUSTMENT): Set to 0 on the Hurd with glibc ≤ 2.42.
(MAX_ADJUSTMENT): Set to (2 * NZERO - 2) on the Hurd with glibc ≤ 2.42.
(main): Clamp the niceness to be greater or equal to MIN_ADJUSTMENT and
less than or equal to MAX_ADJUSTMENT.
* tests/nice/nice.sh: Add some tests for the Hurd's ranges.
2025-11-09 18:48:34 -08:00
Pádraig Brady
07cd38ef66 gnulib: update to latest
* NEWS: Mention the nproc build fix for older Android.
2025-11-05 18:39:06 +00:00
Collin Funk
0830838609 tests: date: check that write errors are promptly diagnosed
This improvement is due to changes to Gnulib's fprintftime module.

* NEWS: Mention the improvement.
* src/getlimits.c (OFF64_T_MAX, OFF64_T_MIN): New macros.
(main): Print them.
* tests/misc/write-errors.sh: Call getlimits_. Add a date invocation.
2025-11-03 17:05:57 -08:00
Paul Eggert
c9425336f4 doc: squashfs issue to be squashed in Linux 6.18 2025-11-03 11:33:38 -08:00
Pádraig Brady
cf08d2d3b1 build: reduce explicit dependencies on macOS CoreFoundation
* src/local.mk: Revert v9.7-322-gc2e1816a5, instead relying
on the more focused v9.8-79-g532cd66af.  When built with
--disable-nls on macOS this will result in only some commands
being linked with INTL_MACOSX_LIBS, thus resulting in env(1)
at least not setting a __CF_USER_TEXT_ENCODING envirnoment variable.
2025-11-01 15:07:15 +00:00
Pádraig Brady
64b8fdb5b4 copy: don't avoid copy-offload upon SEEK_HOLE indicating non-sparse
* src/copy-file-data.c (infer_scantype): Fall back to a plain copy
if SEEK_HOLE indicates non-sparse, as zero copy avoids copy offload.
This was seen with transparently compressed files on OpenZFS.
* tests/cp/sparse-perf.sh: Add a test case even though it might
only trigger on compressed file systems that don't support reflink.
* NEWS: Mention the bug fix.
Addresses https://github.com/coreutils/coreutils/issues/122
2025-11-01 11:24:59 +00:00
Collin Funk
58a66cf3fd timeout: use fork and execvp instead of posix_spawn
* NEWS: Remove timeout from the list of programs that use posix_spawn.
* bootstrap.conf (gnulib_modules): Remove posix_spawnattr_setsigmask.
* src/timeout.c: Don't include spawn.h.
(main): Use fork and execvp instead of posix_spawn.

This reverts commit dac96ce3e3a2424919fea6a17978b6e91e575d86.
2025-10-31 19:57:36 -07:00
Pádraig Brady
eff5f82e92 doc: NEWS: mention that sort --compress=script needs a shebang
* NEWS: Mention that we don't fall-back to executing /bin/sh <script>
for malformed scripts that don't start with #!..., or any executable
that returns ENOEXEC in general.
2025-10-31 14:21:16 +00:00
Pádraig Brady
b294aff3fe sort: fix silent exit upon SIGPIPE from --compress-program
* src/sort.c (main): Ignore SIGPIPE so we've more control over
how we handle for stdout and compression programs.
(sort_die): Handle EPIPE from stdout and mimic a standard SIGPIPE,
otherwise reverting to a standard exit(SORT_FAILURE);
* tests/sort/sort-compress-proc.sh: Add a test case.
* NEWS: Mention the bug fix.
2025-10-29 19:03:23 +00:00
Collin Funk
dac96ce3e3 timeout: use the more efficient posix_spawn to invoke the command
* NEWS: Mention the improvement. Consolidate the posix_spawn
improvements into one item.
* bootstrap.conf (gnulib_modules): Add posix_spawnattr_setsigmask.
* src/timeout.c: Include spawn.h.
(main): Setup signals using a posix_spawnattr_t object. Use posix_spawn
instead of fork and execvp.
2025-10-27 16:54:45 -07:00
Pádraig Brady
8ba47d09a3 build: don't build chcon or runcon unless selinux is available
The build can be force enabled with --with-selinux and vice versa.

* build-aux/gen-lists-of-programs.sh: Move chcon and runcon
to the list of optional programs.
* configure.ac: Only enable chcon and runcon if selinux.h is available.
* NEWS: Mention the Build-related change.
Fixes https://github.com/coreutils/coreutils/issues/121
2025-10-27 16:57:39 +00:00