Commit Graph
31626 Commits
Author SHA1 Message Date
Collin Funk c2a2508c38 test: handle adjacent binary operators
* NEWS: Mention the bug fix.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_test_minus_ao): Exclude
NEWS.
* src/test.c (term): Treat '-a' and '-o' as strings instead of expecting
them to be valid unary operators.
* tests/test/test.pl: Add some test cases.
* tests/test/test-diag.pl: Also test the diagnostics with '-a arg'.
2026-07-26 12:44:01 -07:00
Collin Funk 54f88c7f2e tests: avoid a false ERROR when using overlayfs
* tests/tail/inotify-rotate-resources.sh: Also skip the test on
overlayfs.
2026-07-25 20:33:06 -07:00
Pádraig Brady e79a9f36d8 doc: mention the option of a multi-call binary package
* PACKAGING: Mention the feature, and reference Fedora's
implementation details.
2026-07-25 12:43:21 +01:00
Bruno Haible 56c3c1e5ab doc: add packaging hints for distributions
* PACKAGING: New file.
* Makefile.am (EXTRA_DIST): Add it.
2026-07-25 12:25:16 +01:00
Bruno Haible 44dd71be83 doc: detail dependencies for users and distributions
* DEPENDENCIES: New file, based on gnulib/DEPENDENCIES.
* Makefile.am (EXTRA_DIST): Add it.
* README-install: Reference it.
* README-prereq: Likewise.
2026-07-25 12:24:51 +01:00
Pádraig Brady 1e10be395c doc: tweak recent NEWS entries
* NEWS: Fix recent NEWS entry issues.
2026-07-24 13:35:52 +01:00
Pádraig Brady 1f681f8a72 ls: fix a small mem leak when CLI args have errors
$ valgrind --quiet --leak-check=full --show-leak-kinds=definite \
    src/ls --hyperlink=always foo bar
  ls: cannot access 'foo': No such file or directory
  ls: cannot access 'bar': No such file or directory

    32 bytes in 1 blocks are definitely lost in loss record 3 of 7
    at malloc (vg_replace_malloc.c:447)
    by canonicalize_filename_mode_stk (canonicalize.c:450)
    by canonicalize_filename_mode (canonicalize.c:471)
    by gobble_file.constprop.0 (ls.c:3392)
    by main (ls.c:1765)

* src/ls.c (gobble_file): Call free_ent() before returning.
2026-07-24 13:35:30 +01:00
Pádraig Brady 8f7ed6cf50 maint: refactor stat syscall determination
* init.cfg (+get_stat_syscalls_): Refactor from ...
* tests/ls/stat-free-color.sh: ... here.
* tests/ls/stat-free-symlinks.sh: ... here.
* tests/misc/traversal-missing.sh: ... here.
* tests/shred/fifo.sh: .. here.
2026-07-24 13:19:23 +01:00
Pádraig Brady 30866b30e2 chcon,chgrp,chmod,chown,du,ls: ignore missing files while traversing
* src/fts-missing.h: Add helper routines to determine
if an FTS entry is skippable.  I.e., that is traversed
and not specified on the command line.
* src/chcon.c (process_file): Setup to ignore skippable files.
(change_file_context): Ignore missing files if appropriate.
* src/chmod.c (process_file): Setup to ignore skippable files.
Ignore missing files if appropriate.
(mode_changed): Ignore missing files if appropriate.
* src/chown-core.c (change_file_owner): Setup to ignore skippable files.
Ignore missing files if appropriate.
* src/du.c (process_file): Likewise.
* src/ls.c (print_dir): Ignore missing files if appropriate.
(get_link_name): Likewise.
(gobble_file): Likewise.  Also handle the dangling symlink case.
* src/system.h (ignorable_traversal_errno): Match ENOENT for missing
files.
* tests/chcon/traversal-missing.sh: A new test.
* tests/misc/traversal-missing.sh: Likewise.
* tests/local.mk: Reference the new tests.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/81444
2026-07-24 13:19:23 +01:00
Collin Funk 6e812858bb tests: date: check that weekdays are ignored when given an explicit date
* tests/date/date.pl: Add some test cases.
* tests/date/date-debug.sh: Test the debug output for this case.
2026-07-22 21:52:56 -07:00
Collin Funk 2db599e8b0 tests: wc: test -m in single byte and multi byte locales
* tests/wc/wc.pl ($mb_locale, $single_byte_locale): New variables.
(@mbTests): Add some test cases.
2026-07-22 18:52:55 -07:00
Pádraig Brady 39d955a0ef doc: printf: detail exactly which escapes are supported
* doc/coreutils.texi (echo invocation): Parameterize the escape list.
(printf invocation): Remove the C escape reference as it mentions
\' which we don't support, and doesn't mention \e which we do support
(and GCC also does).  Instead directly present the escape list
as done for the echo command, adjusted accordingly.
2026-07-22 16:20:45 +01:00
Pádraig Brady cedcd913c2 doc: printf: provide usage examples
* src/printf.c (usage): List examples for each supported
conversion specifier.
* doc/coreutils.texi (printf invocation): Likewise.
Addresses https://bugs.gnu.org/81442
2026-07-22 16:20:43 +01:00
Pádraig Brady 952435f079 uptime: remove extraneous space
This make output more consistent with procps.

* src/uptime.c (main): Remove extra space after "up"
when uptime is less than a day.
Fixes https://github.com/coreutils/coreutils/issues/321
2026-07-20 19:46:41 +01:00
Collin Funk 8881342a24 build: reduce size of multi-call binary by reusing true logic
Map 'false' to reuse logic from 'true', instead of creating separate
binaries for each utility.

    $ size src/coreutils-prev
       text    data     bss     dec     hex filename
    1476092    7348 2191936 3675376  3814f0 src/coreutils-prev
    $ size src/coreutils
       text    data     bss     dec     hex filename
    1474612    7348 2191968 3673928  380f48 src/coreutils

* src/local.mk (noinst_HEADERS): Add src/true.h.
(src_false_LDADD): Organize with the rest of the reused programs. Use
$(src_true_LDADD) instead of $(LDADD).
(src_true_SOURCES, src_false_SOURCES): New variables.
* build-aux/gen-single-binary.sh (override_single): Map 'false' to
'true'.
* src/false.c: Remove file.
* po/POTFILES.in: Remove src/false.c.
* cfg.mk (_src): Match src/true-false.c and src/true-true.c.
* src/coreutils-false.c: New file.
* src/true-false.c: Likewise.
* src/true-true.c: Likewise.
* src/true.h: Likewise.
* src/true.c: Include true.h.
(EXIT_STATUS): Always define the macro to use the value of the TRUE_MODE
variable.
(PROGRAM_NAME): Likewise.
* NEWS: Mention the improvement.
2026-07-19 10:53:39 -07:00
Collin Funk 664b8663dd build: reduce size of multi-call binary by reusing test logic
Map the '[' command to which selects appropriate behavior at runtime,
rather than separate binaries for each closely related utility.

    $ size src/coreutils-prev
       text    data     bss     dec     hex filename
    1485188    7348 2191968 3684504  383898 src/coreutils-prev
    $ size src/coreutils
       text    data     bss     dec     hex filename
    1476092    7348 2191936 3675376  3814f0 src/coreutils

* src/local.mk (noinst_HEADERS): Add src/test.h.
(src___SOURCES): Remove src/lbracket.c. Add src/test.c and
src/test-lbracket.c.
(src_test_SOURCES): New variable.
(src/coreutils.h): Adjust the function name to be
single_binary_main_lbracket instead of single_binary_main__.
* build-aux/gen-single-binary.sh: Likewise. Map '[' to 'test'.
(override_single): Adjust the file name to be coreutils-lbracket.c
instead of coreutils-_.c.
* src/lbracket.c: Remove file.
* cfg.mk (_src): Don't match src/lbracket.c in the regular
expression. Match src/test-lbracket.c and src/test-test.c.
* src/coreutils-lbracket.c: New file.
* src/test-lbracket.c: Likewise.
* src/test-test.c: Likewise.
* src/test.h: Likewise.
* src/test.c: Include test.h.
(LBRACKET): Remove macro.
(PROGRAM_NAME): Use the variable TEST_MODE to determine the program
name.
(main): Use the variable TEST_MODE instead of the LBRACKET macro to
implement behavior specific to '['.
* NEWS: Mention the improvement.
2026-07-18 11:14:46 -07:00
Collin Funk 8bc9a81246 tests: paste: check the delimiter is reset for each file when -s is used
* tests/paste/paste.pl (@Tests): Add a test case.
2026-07-17 21:56:36 -07:00
Pádraig Brady d8d4d2426f maint: avoid a recent syntax check failure
* HACKING: Tweak line length.
2026-07-16 12:28:07 +01:00
Pádraig Brady dbed169835 tests: use more robust cleanup of immutable files
* tests/rm/empty-immutable-skip.sh: Use cleanup_() to
remove the immutable attribute, so that false failures
or stale files do not result from e.g. a killed test run.
2026-07-16 12:28:07 +01:00
Mateusz Nosek b4bc8f361b install: avoid redundant metadata updates with -C
"install -C" (--compare) has always called chown/chmod on the
destination even after determining that copying was unnecessary,
ever since --compare was added in commit v7.0-182-gdac5f12c6.
need_copy() already verifies that the destination's mode, owner, and
group match (and, with --preserve-context, that the SELinux context
matches too) before skipping the copy, so re-applying them is
redundant, and can needlessly fail on a destination that cannot be
chown/chmod'd even though nothing would actually change, e.g. one
marked immutable with chattr +i.

* src/install.c (install_file_in_file): Skip metadata updates
if we already skipped the data, as previous checks ensure
that the metadata is already as required.
* tests/install/install-C-immutable.sh: Add a test.
(based on tests/rm/empty-immutable-skip.sh).
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
2026-07-16 12:28:03 +01:00
Pádraig Brady 09f3fc5f70 doc: reference the github mirror in docs
The github mirror is a common interaction point
for issues and pull requests, so reference it in README and HACKING.
Also update the current size of the repo to be more accurate.

Addresses issue #318
2026-07-15 15:43:20 +01:00
Pádraig Brady e45c9e6c01 doc: install: mention -p may lose some of -C speed benefits
* doc/coreutils.texi (install invocation): Mention that
--preserve-timestamps may lose some of the speed advantages of -C,
due to needing to update timestamps for each build.
2026-07-15 11:34:48 +01:00
Pádraig Brady a4d74bb6df doc: wc: clarify that wc supports character counts
* doc/coreutils.texi: Adjust command summary.
* man/wc.x: Likewise.
Fixes https://bugs.gnu.org/81405
2026-07-14 17:30:29 +01:00
Pádraig Brady c279e1557a tests: dd: fix false failure on NetBSD
* tests/cat/cat-distinct-err.sh: /proc/self/mem fails with EINVAL
on NetBSD, so extract the error from dd for comparison.
Reported by Bruno Haible.
2026-07-14 12:07:07 +01:00
Collin Funk fe186925c7 tests: join: test the behavior when given multiple -e options
* tests/join/join.pl (@tv): Add two test cases.
2026-07-13 22:38:03 -07:00
Pádraig Brady 2653c5c5e2 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.

Link: https://github.com/coreutils/coreutils/pull/276
2026-07-13 17:55:26 +01:00
oech3 a4ecf6cd2f 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.
2026-07-13 17:32:39 +01:00
Sylvestre Ledru fb631c3e6d tests: cut: check byte-wise -c and -b -n in the C locale
* tests/cut/cut.pl: Add cases verifying that in the C locale -c and
-b -n select a single byte instead of decoding a multi-byte sequence.

Link: https://github.com/coreutils/coreutils/pull/316
2026-07-11 09:21:02 +01:00
Guanqiang Han 9342ddbd71 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
2026-07-10 22:19:46 +01:00
Pádraig Brady 36d1a194a9 factor: avoid out-of-bounds prime table access
With an ASAN build we can trigger the issue like:

  $ 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.
2026-07-10 12:12:41 +01:00
Pádraig Brady 51d66f8813 maint: avoid sc-lower-case-var syntax check failure
* 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.
2026-07-10 12:11:19 +01:00
Paul Eggert 9324c5ff4f 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.
2026-07-09 16:36:12 -07:00
Paul Eggert 16d20596e1 doc: ‘mv --update’ has optional [=WHICH]
* doc/coreutils.texi (mv invocation):
‘mv --update’ has an optional WHICH, just like ‘cp --update’.
2026-07-08 13:33:59 -07:00
Pádraig Brady 53926ba7d8 doc: fix description of mv -n
The description of mv --no-clobber got out of sync
between commit v9.1-133-g7a69df889 and v9.4-134-g9907b6f5d

* 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
2026-07-08 19:03:27 +01:00
Sylvestre Ledru 68f15d9128 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

Link: https://github.com/coreutils/coreutils/pull/312
2026-07-06 14:25:59 +01:00
Sylvestre Ledru 440fe62502 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

Link: https://github.com/coreutils/coreutils/pull/311
2026-07-06 14:23:58 +01:00
Collin Funk 165b62de80 du: treat negative --max-depth values as errors
* 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.
2026-07-03 20:29:48 -07:00
oech3 a463a6e6ee 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.

Link: https://github.com/coreutils/coreutils/pull/310
2026-07-03 10:51:57 +01:00
Pádraig Brady d73d2d1b31 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
2026-07-02 11:21:47 +01:00
Pádraig Brady e45a3f6a19 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.
2026-07-02 00:58:18 +01:00
Collin Funk 4c234d7555 tests: csplit: avoid a false failure on NetBSD
* tests/csplit/csplit.sh: Don't run the test if calling read on a
directory file descriptor works.
Reported by Bruno Haible.
2026-06-30 20:04:10 -07:00
Pádraig Brady d2428b1f26 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.

Link: https://github.com/coreutils/coreutils/pull/303
2026-06-30 19:04:23 +01:00
Sylvestre Ledru 970548101e 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.

Link: https://github.com/coreutils/coreutils/pull/304
2026-06-30 18:26:51 +01:00
Sylvestre Ledru 7dd7fd17b9 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

Link: https://github.com/coreutils/coreutils/pull/306
2026-06-30 18:21:36 +01:00
Sylvestre Ledru 9502f05a30 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.

Link: https://github.com/coreutils/coreutils/pull/307
2026-06-30 16:27:15 +01:00
Sylvestre Ledru 0eb2fff613 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.

Link: https://github.com/coreutils/coreutils/pull/302
2026-06-29 20:42:59 +01:00
Collin Funk 52ff9b97fb uniq: avoid locking standard output when printing line counts with -c
This increases throughput on systems with unlocked stdio functions.
E.g., 2.5x in the following case:

    $ timeout 1m taskset 1 shuf -r -i 0-100 \
        | taskset 2 uniq -c \
        | taskset 3 pv -r > /dev/null
    [ 100MiB/s]
    $ timeout 1m taskset 1 shuf -r -i 0-100 \
        | taskset 2 uniq -c \
        | taskset 3 pv -r > /dev/null
    [ 246MiB/s]

* 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.
2026-06-28 19:44:00 -07:00
Collin Funk d7622d8629 tests: csplit: also test a read failure without -k
* tests/csplit/csplit.sh: Adjust the test case added by the previous
commit to also run without the -k option.
2026-06-27 16:14:34 -07:00
Collin Funk cd381f4afd tests: csplit: check for message to standard output after read fails
* tests/csplit/csplit.sh: Add a test case.
2026-06-27 12:48:19 -07:00
Collin Funk 57fe9ecd69 tests: dd: check that files are opened with O_TRUNC
* tests/dd/misc.sh: Add the test case.
2026-06-24 21:08:33 -07:00