Commit Graph
31662 Commits
Author SHA1 Message Date
Pádraig Brady fa00eb9979 build: replace printf, snprintf, and sprintf when needed
This avoids the "%.5119Lf" issue on Solaris 11
where an extraneous e+00 is output.
seq uses printf, while numfmt uses snprintf.
I.e. this fixes:

  $ numfmt --to=si --format='%.5119f' 1 | tail -c5
  $ seq -f %.5119f 1 | tail -c5

Note gnulib printf module dependencies were previously discussed at:
https://lists.gnu.org/r/coreutils/2014-11/msg00046.html
https://github.com/coreutils/coreutils/commit/b817f6276

* bootstrap.conf: Depend on {printf,snprintf,sprintf}-posix modules.
2026-08-14 17:47:37 +01:00
Pádraig Brady 34bf6eb5af build: update gnulib submodule to latest
This fixes an extraneous e+00 output on Solaris with:
  $ printf '%.5119Lf' 1 | tail -c4

* gnulib: Update, specifically for commit 9e797dc36b:
printf: Detect %Lf large precision issue on Solaris
2026-08-14 17:47:32 +01:00
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
Iván Ezequiel Rodriguez 50216887b6 stat,tail: recognize nullfs file system type
* src/stat.c (human_fstype): Add "nullfs" (0x4E554C4C).
* NEWS: Mention the improvement.
2026-08-12 13:13:44 +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
Bruno Haible 3e9eaa6d61 doc: document change from --enable-systemd to --with-systemd
* DEPENDENCIES: Mention --with-systemd, not --enable-systemd.
* NEWS: Mention the change.
2026-08-10 21:05:17 +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 d4919e8389 maint: copy: document a member of struct cp_options
* src/copy.h (struct cp_options): Document the src_info member.
2026-08-08 20:30:05 -07:00
Collin Funk 786488adef build: update gnulib submodule to latest 2026-08-08 15:41:41 -07:00
Bruno Haible 8fb8b9b55a maint: document the --with-wtmpdb option
* DEPENDENCIES: Mention wtmpdb.
* NEWS: Mention the effects of --with-wtmpdb.
2026-08-06 20:48:06 -07:00
Collin Funk 6bbdf02185 build: update gnulib submodule to latest 2026-08-06 19:52:35 -07: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 b9ed8168ac maint: ls,stat: factor out getenv_quoting_style
* src/system.h (getenv_quoting_style): Move here from ls.c and stat.c.
* src/ls.c (getenv_quoting_style): Remove.
* src/stat.c (getenv_quoting_style): Remove.  Ensure ARGMATCH is
defined for system.h.
2026-08-01 12:38:28 +01:00
Pádraig Brady 72263e5da7 maint: stat: standardize QUOTING_STYLE handling
* src/stat.c (getenv_quoting_style): Return the selected style.
(initialize_quoting_style): New function, retaining lazy initialization.
(print_statfs, print_stat): Use it.
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 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