Similarly to commit v9.10-115-gb3fe24213, which applied
the same quoting mechanism to --check operation,
also quote file names when generating checksums to tty.
This change gives these advantages:
1. Avoids dumping arbitrary data to vulnerable terminals
2. Avoids visual deception with ansi codes with unknown file names
3. More secure if users copy and paste file names from output
* doc/coreutils.texi (sum invocation): Mention the tty quoting
and reference the details from ...
(cksum output modes): Describe the two forms of quoting used.
* tests/misc/tty-quoting.sh: Add test cases.
* NEWS: Mention the improvement.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-Z25BP6MW.
* src/dircolors.c (syntax): New global variable.
(append_quoted): Escape '!' if we are using 'csh' syntax to prevent
history substitution.
(main): Remove the syntax variable that was made global.
* tests/misc/dircolors.pl (@Tests): Add a test case.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-SFBDLZ6V.
Add docs and tests for the recent gnulib strftime fixes.
* tests/misc/strftime.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fixes.
Fixes https://bugs.gnu.org/82130
* src/selinux.c (restorecon_private): Open the file with O_NOCTTY and
O_NONBLOCK.
* tests/misc/selinux.sh: Add a test case.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-L5GJ7M7X.
* init.cfg (single_binary_build_): An abstraction to check
if the current build is a functional --enable-single-binary build.
(require_safe_builddir_): Also add an abstraction to check for
whitespace in $abs_top_builddir.
* tests/misc/proc-self-comm.sh: Just warn about a non functional
dispatch binary.
* tests/install/basic-1.sh: Use the abstraction which is more accurate
when a stub src/coreutils binary is present.
Also fix up an incorrect skip_ edge case.
* tests/misc/responsive.sh: Use require_safe_builddir_.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/exec-bad-unicode.sh: Clarify a comment.
* tests/misc/proc-self-comm.sh: Quote variables that contain the current
working directory, which may contain spaces. Don't set symlink_cat to a
multi-argument command invocation. Set the path before executing it.
Reported by Bruno Haible.
This preserves any program name transformations, e.g., when
--program-prefix=g is used as a configuration option, unlike commit
ef874ed6c (all: set /proc/self/comm to the program name in the single
binary, 2026-10-17).
* src/coreutils.c (launch_program): Use the last component of argv[0]
when setting the comm value using prctl (PR_SET_NAME, ...).
* tests/misc/proc-self-comm.sh: When using
--enable-single-binary=shebangs, test that the comm value preserves any
program name transformations, e.g., --program-prefix=g.
* NEWS: Adjust the NEWS entry to refer to last component of argv[0]
instead of the program name.
Suggested by Pádraig Brady.
This tests the fix introduced by commit ee9b9aff8 (all: set
/proc/self/comm to the program name in the single binary, 2026-10-17).
* tests/misc/proc-self-comm.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* tests/misc/exec-bad-unicode.sh: Avoid stdbuf running non instrumented
binaries, because the LD_PRELOADED libstdbuf.so may then get link errors
due to it not linking with the sanitizer runtime, and neither does
a non instrumented binary. So instead of running $SHELL, avoid the
issue by running our echo binary directly, which should provide
the sanitizer lib. Using our built binary in the shebang also
implicitly checks for problematic whitespace in the path.
* tests/misc/tty-quoting.sh: Since commit v9.12-10-g782a1e5bc,
env(1) calls isatty() and thus induces another ioctl()
which causes the test to skip. The env(1) is redundant anyway
as strace will avoid shell builtins, so just remove the redundant
env calls.
Without this change, this test would fail during 'make distcheck', for
example.
* tests/misc/exec-bad-unicode.sh: Skip the test if $abs_top_builddir has
spaces or special characters.
* cfg.mk (_tb_misc): Also match tests/misc/exec-bad-unicode.sh.
Reported by Bruno Haible.
* tests/misc/no-fork.sh: Use an "unused" placeholder
so runcon is invoked with the correct number of arguments
where `id -Z` doesn't return anything.
This is needed since commit v9.12-53-g8555a51f2
* tests/misc/realpath.sh: Test the flags supported by 'realpath' that
would previously infinite loop before commit b66f3e4e2 (realpath: fix an
infinite loop when resolving symbolic links, 2026-09-25). Test an
invocation which would avoid the infinite loop by not touching the file.
Reported by Brian Foster in:
<https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/2161155>
* gnulib: Update to get commit b18879b9ed (canonicalize: Fix a missing
check for symlink loops., 2026-09-25)
* tests/misc/realpath.sh: Add a call to getlimits_. Add a test case.
* NEWS: Mention the bug fix.
E.g. with podman we get default SELinux context mount options
for /dev/shm and /, resulting in all files getting context like
the following when created:
security.selinux="system_u:object_r:container_file_t:s0:c458,c677"
However you can't explicitly set that xattr:
$ touch file
$ setfattr -n "security.selinux" \
-v "system_u:object_r:container_file_t:s0:c458,c677" file
setfattr: file: Operation not supported
* tests/mv/part-symlink.sh: Avoid the issue. Note this is new
since v9.12 as mv now warns about xattr ENOTSUP failures.
* tests/misc/xattr.sh: Avoid the issue (which would have
existed before v9.12).
Quoting is currently only enabled by default when writing to terminals,
but it is usually desired to constrain the output format for processing.
E.g. for processing by a shell you can now:
env --quoting-style=shell-escape | grep ^FOO
We use an option rather than reyling on $QUOTING_STYLE so
that $QUOTING_STYLE is restricted to be user config for terminals
and does not impact redirected processing.
Also it avoids an extra getenv() call if not outputting to tty.
* src/env.c (main): Parse --quoting-style and use that for the output
format for all outputs.
* src/printenv.c (main): Likewise.
* doc/coreutils.texi (env invocation): Describe --quoting-style.
(printenv invocation): Likewise.
* tests/env/env.sh: Reinstate testing of various output modes.
* tests/misc/printenv.sh: Likewise.
* NEWS: Mention the new feature. Also mention the change from
the previous commit not done there so that builders would have
a clean patch against the previous release.
`strace -e tee true` will run the tee command on cygwin,
rather than filtering for the tee syscall.
Reported by Bruno Haible on Cygwin 2.9.0
* init.cfg: Use -e trace=foo where foo might be a command,
so that strace probes will fail rather than invoke foo on Cygwin.
* tests/cat/cat-distinct-err.sh: Likewise.
* tests/cat/splice.sh: Likewise.
* tests/ls/no-cap.sh: Likewise.
* tests/misc/yes.sh: Likewise.
* tests/mv/atomic.sh: Likewise.
* tests/mv/atomic2.sh: Likewise.
* tests/nproc/nproc-quota.sh: Likewise.
* tests/pwd/pwd-long.sh: Likewise.
* tests/stty/stty.sh: Likewise.
* tests/tail/debug.sh: Likewise.
* tests/tail/inotify-only-regular.sh: Likewise.
* src/printenv.c (main): Make sure quoting is disabled when we have
arguments and standard output is not a terminal.
* tests/misc/printenv.sh: Adjust single argument test cases. Add
multiple argument test cases.
* tests/misc/tty-quoting.sh: Add test cases to check if isatty is used.
* doc/coreutils.texi (printenvAlwaysQuoted): Remove macro.
(printenv invocation): Describe the adjusted quoting behavior.
(env invocation): Move the text from printenvAlwaysQuoted here since it
is no longer used for 'printenv'.
* 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.
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/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.
* 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
* 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.
* 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.
* 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.
* 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.