* 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.
* 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.
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.
* 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
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
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.
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.
* 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.
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
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
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.
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
* 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.
* 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.
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.
* 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.
* 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
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.
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.
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().