Commit Graph
5619 Commits
Author SHA1 Message Date
Iván Ezequiel Rodriguez 95de5f1372 truncate: don't hang with --reference=FIFO
* NEWS: Mention the fix.
* src/truncate.c (main): Open the reference with O_NONBLOCK.
* tests/truncate/truncate-fifo.sh: Also cover --reference=FIFO.
2026-08-13 22:32:56 -07:00
Arun Bhattacharya 162ddbe972 uname: add -A,--all-labeled to print labeled lines
* doc/coreutils.texi (uname invocation): Describe -A,--all-labeled.
* src/uname.c (main): Accept new option.
(print_element): Also output label if enabled.
* tests/misc/uname-labeled.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.

Link: https://github.com/coreutils/coreutils/issues/313
2026-08-12 15:42:48 +01:00
Sylvestre Ledru 48c4c15e4e tests: numfmt: add checks for overflowing unit sizes
* tests/numfmt/numfmt.pl (@Tests): Add unit-11 and unit-12, ensuring
a --to-unit/--from-unit whose suffix multiplication overflows
uintmax_t is rejected with "invalid unit size" rather than
being wrapped or crashing.

Link: https://github.com/uutils/coreutils/pull/13484

Link: https://github.com/coreutils/coreutils/pull/326
2026-08-12 13:32:12 +01:00
Sylvestre Ledru 47f57665d5 tests: printf,seq: add checks for large field widths and precisions
* tests/printf/printf.sh: Ensure a large field width or precision
produces fully padded output, and that a precision beyond 1000
digits is not truncated.
* tests/seq/seq-precision.sh: Ensure a large format precision is
fully honored.

Link: https://github.com/uutils/coreutils/pull/13460

Link: https://github.com/coreutils/coreutils/pull/325
2026-08-12 13:25:00 +01:00
Collin Funk f5e1fd3126 tests: env,printenv: fix test failures on macOS
* tests/env/env.sh: Filter out __CF_USER_TEXT_ENCODING from the output.
Make the regex more strict.
* tests/misc/printenv.sh: Likewise.
Reported by Bruno Haible.
2026-08-10 19:25:38 -07:00
Sylvestre Ledru f6539191f1 ptx: fix infinite loop with a nullable --word-regexp
'ptx -W "a*"' would never terminate.  SKIP_SOMETHING advanced the cursor
by the length of the match, which is zero when the word regexp matches
the empty string, and no other value in the surrounding loop conditions
changes.  find_occurs_in_text already skips zero length matches, and a
zero length --context-regexp match is rejected outright; only this macro
lacked the forward progress guarantee.

* src/ptx.c (SKIP_SOMETHING): Advance by at least one byte on a zero
length match, as the other branches of the macro already do.
* tests/ptx/word-regex-loop.sh: New test.
* tests/local.mk (all_tests): Reference it.
* NEWS: Mention the fix.

Link: https://github.com/coreutils/coreutils/pull/328
2026-08-10 22:24:21 +01:00
Pádraig Brady e0ae3dc846 tests: env: avoid false failure due to new quoting
* tests/env/env-S.pl: Disable quoting on output
rather than complicate the matching output strings.
2026-08-10 14:32:13 +01:00
Collin Funk 328322ca64 printenv,env: quote problematic variables
* doc/coreutils.texi (printenvAlwaysQuoted): New macro.
(printenv invocation): Use it.
(env invocation): Use it.
* src/printenv.h: New file.
* src/local.mk (noinst_HEADERS): Add it.
(src_env_SOURCES): Likewise. Group with src_printenv_SOURCES.
(src_printenv_SOURCES): New variable.
* src/printenv.c: Include argmatch.h and printenv.h.
(main): Quote printed variable names and values.
* src/env.c: Include argmatch.h and printenv.h.
(main): Quote printed variable names and values.
* tests/misc/printenv.sh: Add test cases.
* tests/env/env.sh: Likewise. Adjust invalid UTF-8 test cases.
* NEWS: Mention the change in behavior.
2026-08-05 21:29:35 -07:00
Collin Funk 6b8c706233 test: dirname: add tests for -z
* tests/misc/dirname.pl (@Tests): Add a few test cases.
2026-08-02 11:24:43 -07:00
Collin Funk 657394655b dirname: quote problematic names on tty
* doc/coreutils.texi (terminalQuoted): New macro.
(readlink invocation, basename invocation, dirname invocation): Use it.
* src/dirname.c (quote_output): New variable.
(main): Quote output when appropriate.
* src/system.h (quoteN_mem): New macro.
* tests/misc/dirname.pl: Add test cases based on the ones added for
basename in commit e897dfd02 (basename: quote problematic names on tty,
2026-07-30). Copy some logic from tests/misc/basename.pl to test the -z
option.
* tests/misc/tty-quoting.sh: Also test dirname.
* NEWS: Mention the improvement.
2026-08-02 11:13:24 -07:00
Pádraig Brady cdfaf73b8f tests: add tests to ensure quoting to tty
* tests/misc/tty-quoting.sh: Add positive test for
basename, du, ls, readlink, and realpath quoting.
* tests/local.mk: Reference the new test.
2026-08-01 13:03:38 +01:00
Pádraig Brady d18b73bb68 du: quote problematic names on tty
* doc/coreutils.texi (readlink invocation): Mention $QUOTING_STYLE
is significant.
* src/du.c (main): Quote output when appropriate.
* tests/du/basic.sh: Add a test case.
* NEWS: Mention the improvement.
2026-08-01 12:38:28 +01:00
Pádraig Brady bc5c99bacf readlink: quote problematic names on tty
* doc/coreutils.texi (readlink invocation): Mention $QUOTING_STYLE
is significant.
* src/readlink.c (main): Quote output when appropriate.
* tests/readlink/rl-1.sh: Add a test case.
* NEWS: Mention the improvement.
2026-08-01 12:38:28 +01:00
Pádraig Brady e897dfd023 basename: quote problematic names on tty
* doc/coreutils.texi (basename invocation): Mention $QUOTING_STYLE
is significant.
* src/basename.c (perform_basename, main): Quote output when
appropriate.
* tests/misc/basename.pl: Add a test case.
* NEWS: Mention the improvement.
2026-08-01 12:38:28 +01:00
Pádraig Brady 05ab72f236 realpath: quote problematic names on tty
* doc/coreutils.texi: Mention $QUOTING_STYLE is significant.
* src/realpath.c (print_relative_path): New function to buffer
relative paths when quoting, and otherwise stream them.
(main): Look up $QUOTING_STYLE when outputting to a tty and
--zero is not specified.
* tests/misc/realpath.sh: Add a test case.
* NEWS: Mention the improvement.
2026-08-01 12:38:28 +01:00
Pádraig Brady 0acbfaf972 ls: protect newlines for non terminal output
Add extra protection for newlines that might be output to log files etc.

* doc/coreutils.texi (ls invocation): Expand --literal description.
* src/ls.c (quote_name_buf): Replace '\n' with '?' if appropriate.
* tests/ls/dired.sh: Add a negative test case.
* tests/ls/zero-option.sh: Likewise.
* tests/ls/m-option.sh: Likewise. Also add a positive test case.
* NEWS: Mention the improvement.
2026-08-01 12:38:28 +01:00
Pádraig Brady 04590790d4 ls: with -m, quote names containing commas when appropriate
* src/ls.c (decode_switches): Flag ',' for quoting when needed.
* tests/ls/m-option.sh: Add a test case.
* NEWS: Mention the improvement.
2026-08-01 12:38:28 +01:00
Collin Funk e341208d06 tests: du: test --block-size with thousands separators
* tests/du/block-size.sh (test_unit): Test that the locales thousands
separator is used if we can determine it.
2026-07-31 21:54:29 -07:00
Collin Funk c4bf1d49be tests: du: test --block-size and BLOCK_SIZE
* tests/du/block-size.sh: New file.
* tests/local.mk: Add the test case.
2026-07-28 23:17:13 -07:00
Ayesha Shafique 04befb136a ptx: fix infinite loop with -G and a narrow output width
With GNU extensions disabled, before_max_width can go negative, and
define_all_fields then loops forever trying to shrink the before field
to a width narrower than empty:

  $ printf 'qux\n' | src/ptx -G -w2
  [hangs]

Commit v6.12-96-g773be9eca added a clamp for this, but placed it in
the GNU-extensions branch only.  Move it after that if/else so that
both branches are covered.

* src/ptx.c (fix_output_parameters): Clamp before_max_width for both
the GNU and non-GNU cases.
* tests/ptx/ptx-overrun.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/81507
2026-07-28 12:05:32 +01:00
Collin Funk 114aa7f1b7 tests: join: test the parsing of space separated -o formats
* tests/join/join.pl: Add some test cases.
2026-07-27 21:39:51 -07:00
Pádraig Brady d97c0ffd6b tests: tail: remove redundant inotify config check
* tests/tail/inotify-rotate-resources.sh: This is implicit
in require_inotify_supported_.
2026-07-27 14:25:39 +01:00
Sylvestre Ledru 5b51bb162c tests: expr: exercise the C.UTF-8 locale
* tests/expr/expr-multibyte.pl: Add 'cu' prefixed cases running in
C.UTF-8, which names no language but has a UTF-8 codeset, ensuring
length, index, substr and match still operate on characters there.
Skip them where that locale is unavailable.

Link: https://github.com/coreutils/coreutils/pull/323
2026-07-27 13:52:51 +01:00
Sylvestre Ledru af1ba4244c tests: sort: check byte-wise ordering in the C.UTF-8 locale
* tests/sort/sort-locale.sh: C.UTF-8 has a UTF-8 codeset but the
collation rules of C, so add a case ensuring the ordering there stays
byte-wise rather than following the linguistic rules exercised for
en_US.iso8859-1 and fr_FR.UTF-8 above.

Link: https://github.com/coreutils/coreutils/pull/323
2026-07-27 13:52:51 +01:00
Sylvestre Ledru fc426cc142 tests: ls: cover quoting in the C.UTF-8 locale
The quoting characters and the printability of a multibyte character are
selected by the locale's codeset, not by its language, but no test
covered a locale that has a UTF-8 codeset and no language.

* tests/ls/quoting-utf8.sh: Check that in C.UTF-8 the locale/clocale
styles use the Unicode quotes and that literal/escape/shell-escape pass
a multibyte character through unaltered, whereas the plain C locale
octal-escapes it or replaces it with '?'.

Link: https://github.com/coreutils/coreutils/pull/323
2026-07-27 13:52:51 +01:00
Collin Funk ab6b01f40f tests: prefer require_inotify_supported_ to file system check
* tests/tail/inotify-rotate-resources.sh: Use require_inotify_supported_
instead of require_local_dir_ and the recently added check for
overlayfs.
Suggested by Pádraig Brady.
2026-07-26 16:52:54 -07:00
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 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
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 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 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
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