1
0
mirror of https://git.savannah.gnu.org/git/coreutils.git synced 2026-10-24 02:08:57 +03:00

31869 Commits

Author SHA1 Message Date
Collin Funk
f188b3cc19 tests: csplit: test the behavior with an empty pattern
* tests/csplit/csplit.sh: Add a test case.
2026-08-31 17:31:08 -07:00
Collin Funk
b7575a9d7b tests: mv: test the behavior of symbolic links to "."
* tests/mv/part-hardlink-symlink.sh: Add a test case.
2026-08-31 17:31:08 -07:00
oech3
e4db330242 tests: dd: support referencing of external test command
* tests/dd/stderr.sh: Use env instead of
$abs_top_builddir for external usage of tests.

Link: https://github.com/coreutils/coreutils/pull/340
2026-08-31 12:43:13 +01:00
Sylvestre Ledru
85857f1eaa tests: date: check that composite specifiers ignore the '-' flag
* tests/date/date.pl: Add tests ensuring that %-D, %-F, %-T, %-R, %-r,
%-x and %-X keep the default padding of their sub-fields, while the
other flags and the field width still apply to the whole expansion.
https://github.com/uutils/coreutils/pull/14163

Link: https://github.com/coreutils/coreutils/pull/339
2026-08-31 12:38:01 +01:00
Pádraig Brady
15b8d8ab82 build: update gnulib submodule to latest
Update specifically to get commit 91c129e9db fixing:

  $ date-before -d '1-2-3' "+[%_D]"
  [02/03/ 1]
  $ date-after -d '1-2-3' "+[%_D]"
  [02/03/01]

* gnulib: Update to latest.
* NEWS: Mention the bug fix.
2026-08-31 12:30:00 +01:00
Pádraig Brady
3f3a822de7 doc: printf: resync format examples in texinfo
* doc/coreutils.text (printf invocation): Sync the issues
fixed in the previous commit to the texinfo examples.
2026-08-30 21:56:29 +01:00
Pádraig Brady
aea70b28be doc: printf: fix typos in format examples
* src/printf.c (usage): Remove redundant quotes.
Change ambiguous quotes. Fix typos in examples.
Quoting changes suggested by Martin D Kealey.
2026-08-29 14:03:37 +01:00
Collin Funk
29933e8a5c tests: misc: test that various commands don't fork
* tests/misc/no-fork.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* tests/misc/stdbuf.sh: Remove a test that is redundant with the new
test.
2026-08-28 22:10:34 -07:00
Sylvestre Ledru
47dfc77774 tests: mv: check cross-device move of dir with hard links and symlink
* tests/mv/part-hardlink-symlink.sh: New test, ensuring that moving a
directory to another file system preserves the contents and the hard
links of its regular files, as well as the symlinks pointing at them.
* tests/local.mk (all_tests): Add it.
https://github.com/uutils/coreutils/pull/14170

Link: https://github.com/coreutils/coreutils/pull/337
2026-08-27 17:00:39 +01:00
oech3
5e011122e5 tests: misc: support referencing of external commands
* tests/misc/close-stdout.sh: Use env instead of
$abs_top_builddir for external usage of tests.

Link: https://github.com/coreutils/coreutils/pull/338
2026-08-27 16:57:33 +01:00
Pádraig Brady
4e53af6577 env: translate -v messages
* src/env.c: These user facing messages should be translated.
2026-08-27 16:40:53 +01:00
Pádraig Brady
d18d3a85be env: ensure all -v messages are quoted
$ env-before -v -u 'B' -S 'A=1 B="\n"' 'true'
split -S:  ‘A=1 B="\\n"’
 into:    ‘A=1’
     &    ‘B=\n’
unset:    B
setenv:   A=1
setenv:   B=

executing: true
   arg[0]= ‘true’

$ src/env-after -v -u 'B' -S 'A=1 B="\n"' 'true'
split -S:  ‘A=1 B="\\n"’
 into:     ‘A=1’
     &     ‘B=\n’
unsetting: ‘B’
setting:   ‘A=1’
setting:   ‘B=\n’
executing: ‘true’
   arg[0]= ‘true’

* src/env.c: -v is often used to debug spacing issues,
so it's important to quote output.
2026-08-27 16:40:49 +01:00
Pádraig Brady
b9203a123d env: use more abstract -v messages
* src/env.c: These user facing messages should
be more descriptive and abstract.  Also improve alignment.
2026-08-27 15:29:49 +01:00
Collin Funk
5b70089a7b tests: printf: add tests for the %b specifier
* tests/printf/printf-cov.pl ($ESCAPE_CHARS, $ESCAPE_OUTPUT): New
variables derived from the existing 'escape-1' test.
(@Tests): Add some additional escaping tests and test %b.
2026-08-26 21:23:33 -07:00
Collin Funk
1ab303a901 tests: sort: check that non-blank characters aren't treated as blank
* tests/sort/sort.pl (@Tests): Add a few test cases.
2026-08-26 20:19:56 -07:00
oech3
c717ca569b tests: env: support referencing of external env
* tests/env/env-S-script.sh: Use `cmd_exe` instead of
$abs_top_builddir for external usage of tests.

Link: https://github.com/coreutils/coreutils/pull/336
2026-08-26 18:24:20 +01:00
Pádraig Brady
ff91f242fd tests: provide a cmd_exe helper to find a program binary
init.cfg (cmd_exe): Provide a function to find the command under test,
whether in the $PATH or in the standard build directory.
* tests/env/env0-from.sh: Use it instead of `command -v`.
* tests/misc/coreutils.sh: Likewise.
* tests/nproc/nproc-quota.sh: Likewise.
* tests/env/env.sh: Likewise.  Also remove non robust use of sed.
2026-08-26 15:18:08 +01:00
Sylvestre Ledru
f1a5961c12 tests: join: cover a repeated -o
* tests/join/join.pl: Test that the field specs of several -o options
accumulate in order, and that 'auto' applies only when every -o
argument is 'auto'.
Identified here: https://github.com/uutils/coreutils/pull/14070

Link: https://github.com/coreutils/coreutils/pull/335
2026-08-26 12:40:26 +01:00
Sylvestre Ledru
0d14766774 tests: cp: exercise copying with a write-denying umask
* tests/cp/preserve-mode.sh: Ensure that with a umask that removes
the owner write bit, cp still fully writes a freshly created
destination file and gives it the expected mode.
  Missing case identified here:
  https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2164777

Link: https://github.com/coreutils/coreutils/pull/334
2026-08-26 12:37:43 +01:00
Sylvestre Ledru
31634dbc2e tests: stat: check output preceding an invalid directive
* tests/stat/stat-printf.pl: The format is interpreted as it is printed,
so whatever precedes an invalid directive is written before the
diagnostic, and --format adds no trailing newline when it stops early.
The existing err-1 and err-2 cases put the directive at the start of the
format, so nothing covered this.
See https://github.com/uutils/coreutils/issues/14101

Link: https://github.com/coreutils/coreutils/pull/333
2026-08-26 12:12:46 +01:00
Sylvestre Ledru
6127da8050 tests: expand, unexpand: check blank-separated tab lists
parse_tab_stops accepts a comma or any blank as a separator, but the
tests only ever used a comma or a space, so a tab separator was
untested.  unexpand had no coverage of multi-stop lists at all.
Missing case identified here:
https://github.com/uutils/coreutils/pull/14057

* tests/expand/expand.pl (t4a): New test, using tabs as separators.
* tests/unexpand/unexpand.pl (tabs-3, tabs-4, tabs-5, tabs-6): New
tests, for comma-, space- and tab-separated lists and for a leading
separator.

Link: https://github.com/coreutils/coreutils/pull/332
2026-08-26 12:11:19 +01:00
Pádraig Brady
493ed58f21 tests: env: avoid false failure on FreeBSD
Avoid unsetenv() on a non standard environment,
as FreeBSD 14 and 15 at least fail when manipulating
such an environment with unsetenv().

  $ printf 'A=1\0A=2\0foo\0' |
    src/env --env0-from=- src/env foo=bar | grep foo
  foo=bar
  foo

  $ printf 'A=1\0A=2\0foo\0' |
    src/env --env0-from=- src/env -u foo
  env: environment corrupt; missing value for foo
  env: cannot unset ‘foo’: Bad address

  $ printf 'A=1\0A=2\0foo\0' |
    src/env --env0-from=- src/env -u bar
  env: environment corrupt; missing value for foo
  env: cannot unset ‘bar’: Bad address

* tests/env/env0-from.sh: Use routines internal to env(1)
to manipulate the environment, only delegating the
executed env(1) to adding any implicit environment variables.
Reported by Bruno Haible.
2026-08-26 12:10:22 +01:00
Collin Funk
9c6b27e405 build: update gnulib submodule to latest 2026-08-25 21:51:13 -07:00
Collin Funk
24e485a883 tests: stat: fix a test failure on FreeBSD
* tests/stat/stat-nanoseconds.sh: Don't assume that we can create a file
with timestamps before the epoch.
Reported by Bruno Haible.
2026-08-25 19:34:52 -07:00
Paul Eggert
9068289c95 maint: translate messages from Gnulib
Problem reported by ribbon in:
https://lists.gnu.org/r/coreutils/2026-08/msg00093.html
* configure.ac (GNULIB_TEXT_DOMAIN): Define.
* po/POTFILES.in: Add lib/parse-datetime.y.
2026-08-25 10:24:59 -07:00
Paul Eggert
54120fb722 build: update gnulib submodule to latest
* bootstrap: Update using './bootstrap --bootstrap-sync'.
2026-08-25 10:24:59 -07:00
Collin Funk
e92232687a tests: join: support old perl versions
The following error was seen on a Debian 6.0 virtual machine using perl
5.10.1:

    Bareword found where operator expected at \
      ./tests/join/join.pl line 327, near "tr/_/-/r"
    syntax error at ./tests/join/join.pl line 327, near "tr/_/-/r"
    Execution of ./tests/join/join.pl aborted due to compilation errors.
    FAIL tests/join/join.pl (exit status: 255)

* tests/join/join.pl: Don't use the /r modifier which was not introduced
until perl 5.13.7.
2026-08-23 22:47:19 -07:00
Collin Funk
32f109ca8e tests: pathchk: test the output to standard error for empty file names
* tests/misc/pathchk.sh: Move the existing empty file name tests to a
loop to check some additional options. Check the message printed to
standard error.
2026-08-22 19:55:33 -07:00
Collin Funk
aa0c0de350 tests: stdbuf: check that a child process isn't created
* tests/misc/stdbuf.sh: Add a test case.
2026-08-20 22:56:49 -07:00
Collin Funk
6ac1d0907a tests: sort: check LC_ALL and LC_COLLATE
* tests/sort/sort-locale.sh: Also check LC_COLLATE.

Link: https://github.com/coreutils/coreutils/pull/269
2026-08-20 17:37:01 +01:00
oech3
cfd13b061e tests: dd: replace LD_PRELOAD of fail-ftruncate-fstat.sh by strace
* tests/dd/fail-ftruncate-fstat.sh: Replace LD_PRELOAD by strace
to support static executables.

Link: https://github.com/coreutils/coreutils/pull/330
2026-08-20 16:25:16 +01:00
Sylvestre Ledru
0b8fff44cb tests: stat: check nanosecond precision away from the Epoch
The existing checks all use a timestamp only 67413 seconds after the
Epoch, which a double can still represent exactly to the nanosecond, so
they do not detect a formatter that goes through floating point.  They
also never look at a timestamp before the Epoch, where the fraction has
to be truncated towards minus infinity.

* tests/stat/stat-nanoseconds.sh: Also check %Y, %.Y, %.3Y and %.9Y on a
2026 timestamp and on a timestamp shortly before the Epoch.
Link: https://github.com/uutils/coreutils/pull/13976

Link: https://github.com/coreutils/coreutils/pull/331
2026-08-20 16:15:02 +01:00
Pádraig Brady
3d3022995b maint: avoid -Werror=maybe-uninitialized with gcc -flto -O3
* src/env.c (main): With GCC 16.1 we need to force initialize
to avoid the maybe uninitialized warning.
2026-08-19 21:09:36 +01:00
Pádraig Brady
3abac0e23a doc: cut: show how to efficiently search ASCII blanks with -w
* doc/coreutils.texi (cut invocation): Mention LC_CTYPE=C
restricts the -w field separator set, and is thus more efficient.
2026-08-19 21:09:29 +01:00
Pádraig Brady
224673eba8 build: fix logname systemd linkage
Note there was worry about redundant linking with -lsystemd
when getlogin() is not replaced, however that is mitigated
in general with the --as-needed linker option (the lib-ignore
gnulib module). Tested with:

  ./configure --with-systemd gl_cv_func_getlogin_works=no

* NEWS: Mention the Build-related fix.
Reported at https://bugs.debian.org/1129960
2026-08-19 13:41:49 +01:00
Collin Funk
b98f6d8c53 tests: prefer unified diffs when printing test failures
* tests/Coreutils.pm (_compare_files): Use 'diff -u' instead of
'diff -c'.
2026-08-18 22:12:31 -07:00
Collin Funk
ffa26f0c2f tests: df: check that -k and -m are supported
* tests/df/df-output.sh: Check that the block size is correct when using
-k and -m.
2026-08-18 19:41:33 -07:00
Pádraig Brady
554d2cdc6f tests: improve searchability for fail= logs
* init.cfg (retry_delay_): Avoid the string "fail="
as it is very useful to search for that in logs to
pinpoint the failing part of a test script.
2026-08-18 12:36:03 +01:00
Pádraig Brady
ab9deb9e89 maint: change inappropriate uses of unreachable()
Change some uses of unreachable() to affirm(false),
so that we would get an abort in normal builds.
This is safer than unreachable() which results in undefined behavior.
See commit v9.8-27-ge661c7a52 for a real case of this.

Uses of unreachable() should be provably unreachable, and trivially so.
Trivial cases: e.g. after error(NON_ZERO, ...) etc,
or a fully handled switch on enum (proved with -Wswitch-enum).

Note unreachable() can be defined to exit with -funreachable-traps,
but it's better to use standard build options and distinguish the
different classes of "unreachable" in code.  Also clang (22) doesn't
seem to support the -funreachable-traps option.

Note we prefer affirm to abort, since it has better diagnostics in the
normal case and better performance with -DNDEBUG.
and prefer affirm to assert, as it allows for better static
checking when compiling with -DNDEBUG.
Neither of these apply to affirm(false),
but we avoid assert for consistency.

* gl/lib/mbbuf.h: s/unreachable/affirm(false)/.
* src/copy-file-data.c: Likewise.
* src/copy.c: Likewise.
* src/cut.c: Likewise.
* src/ls.c: Likewise.
* src/numfmt.c: Likewise.
* src/od.c: Likewise.
* src/stdbuf.c: Likewise.
* src/sync.c: Likewise.
* src/tr.c: Likewise.
* src/tsort.c: Likewise.
* src/wc.c: Likewise.
2026-08-18 12:25:21 +01:00
Pádraig Brady
4db299e8ae build: suppress warnings to add pure or const attributes
The particular trigger for disabling this now was
changing copy_debug_string() from using unreachable()
to assert() will incorrectly induce gcc 16.1 to suggest
adding __attribute(pure) even though this static function
may have side effects like aborting the program.
Note given the current use of copy_debug_string(),
that would likely be OK to allow common subexpression elimination,
however "pure" also allows for calls to be removed entirely
depending on usage of the function (as noted in the bug url below).
Therefore it's safer to avoid all this until at least
the compiler bug below is addressed.

* configure.ac: Remove -Wsuggest-attribute={pure,const}.
These are currently innacurate and dangerous.
See https://gcc.gnu.org/PR115237
2026-08-18 12:25:21 +01:00
Collin Funk
659a945217 maint: prefer xreallocarray when reallocating an array
* src/set-fields.c (set_fields): Prefer xreallocarray which will check
for unlikely overflows when multiplying the number of elements by the
size of the element.
2026-08-17 19:56:30 -07:00
Collin Funk
aea03eb917 tests: cp: avoid a false failure when built with --disable-xattr
* tests/cp/capability.sh: Check that --preserve=xattr fails when
extended attributes cannot be copied. Check that --preserve=all creates
the copy successfully even if extended attributes cannot be copied.
2026-08-17 19:05:01 -07:00
Collin Funk
120093d94b stdbuf: improve error messages for invalid -i, -o, -e arguments
This adjusts the error messages to be a bit more descriptive. Here are
the previous errors:

  $ LC_ALL=C src/stdbuf-prev -o1a true
  stdbuf-prev: invalid mode '1a'
  $ LC_ALL=C src/stdbuf-prev -oa true
  stdbuf-prev: invalid mode 'a'
  $ LC_ALL=C src/stdbuf-prev -o1Z true
  stdbuf-prev: invalid mode '1Z': Value too large for defined data type

Here are the new errors:

  $ LC_ALL=C src/stdbuf -o1a true
  stdbuf: invalid suffix in -o argument '1a'
  $ LC_ALL=C src/stdbuf -oa true
  stdbuf: invalid -o argument 'a'
  $ LC_ALL=C src/stdbuf -o1Z true
  stdbuf: -o argument '1Z' too large

* src/stdbuf.c: Include xstrtol-error.h.
(parse_size): Return the error from xstrtoumax. Prefer ckd_add to check
for overflow.
(main): Prefer xstrtol_fatal to a custom error message.
2026-08-17 19:04:59 -07:00
Pádraig Brady
fce42ec790 tests: env: fix false failure in recent --env0-from test
* tests/env/env0-from.sh: Make independent from implicit env vars,
like __CF_USER_TEXT_ENCODING etc.  Also improve test by,
making independent of location of env(1) under test, and
using textual output where possible to ease test debugging.
2026-08-18 00:38:52 +01:00
Collin Funk
6fd17a6715 mv: emit warnings when copying extended attributes fails with ENOTSUP
* src/copy.c (copy_reg, copy_interal): Don't change the exit status if
copying extended attributes fails and we are 'mv'.
* src/copy.h (struct cp_options): Update some commentary.
* src/mv.c (cp_option_init): Enable require_preserve_xattr in the
cp_options struct.
* tests/cp/cp-mv-enotsup-xattr.sh: Check that the error is emitted when
'mv' is built with extended attribute support.
* doc/coreutils.texi (mv invocation): Mention that all errors are
emitted, but do not modify the exit status.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/13601
2026-08-16 20:09:19 -07:00
Collin Funk
d458e11b2c tests: cp,mv,install: check for data loss with an empty backup suffix
* tests/misc/empty-backup-suffix.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-08-15 18:52:54 -07:00
Collin Funk
25e7da3f26 maint: prefer inline functions to maros
These macros evaluate their arguments more than once, so using them
while incrementing a pointer, for example, would introduce bugs.

* src/octhexdigits.h (isoct, fromoct, fromhex): Define as an inline
function instead of a macro.
2026-08-15 14:09:04 -07:00
Collin Funk
967b1a3d65 maint: stdbuf: pacify -Wanalyzer-out-of-bounds
Analyzer mistakenly reports that the CSWTCH lookup table can overflow
here since it cannot infer the value of C from the previously called
switch statement in main. See:
<https://gcc.gnu.org/bugzilla/PR126885>.

* src/stdbuf.c (optc_to_fileno): Add a default label with a call to
unreachable.
2026-08-14 22:04:58 -07:00
Pádraig Brady
5408133505 tests: printf: remove redunant check
* tests/printf/printf.sh: We're checking .70000,
so no point also checkint .1000
2026-08-14 18:15:50 +01:00
Pádraig Brady
21d87c1262 env: use argz for NUL delimited parsing
argz is provided by glibc/gnulib,
simplifies the code a bit, and is about 15% faster,
mainly due to strlen() scanning per entry rather
than per byte scanning:

  $ src/printf 'USUAL_%1$d=%1$032d\0' $(seq 30000) > env.0
  $ hyperfine -N 'src/env'{,-argz}' -i --env0-from=env.0 true'

  src/env-argz -i --env0-from=env.0 true ran
    1.17 ± 0.27 times faster than src/env -i --env0-from=env.0 true

* .gitignore: Ignore generated lib/argz.h.
* bootstrap.conf (gnulib_modules): Add argz.
* src/env.c: Include <argz.h>.
(set_envvars_from_file): Use argz_count() and argz_next().
(set_raw_environment_from_file): Use argz_count() and argz_extract().
2026-08-14 18:00:15 +01:00