Commit Graph
1281 Commits
Author SHA1 Message Date
Paul Eggert fbc1bbbec1 doc: document "rm -r s/" on symlink s (bug#82259) 2026-11-16 19:28:33 -08:00
Pádraig Brady 67b6801ad3 cksum: use more defensive file name escaping
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.
2026-11-06 23:55:00 +00:00
Pádraig Brady f7f73ac1d8 doc: chroot: say --userspec gives no extra security protection
* doc/coreutils.texi (chroot invocation): State that --userspace and
--groups do not provide any real extra protection when working with
untrusted chroots.
2026-11-06 23:55:00 +00:00
Pádraig Brady 38bdf759e3 doc: ls: mention the default output formats in the man page
Also clarify that -C and -1 only output the file name.

* doc/coreutils.texi (General output formatting): Tweak the -C
description to emphasize that only names are output.
* src/ls.c (usage): Clarify that only names are printed with -1 and -C,
and mention which is the default depending on tty output and
which of ls,dir,vdir is in use.

Link: https://github.com/coreutils/coreutils/issues/405
2026-11-04 12:03:43 +00:00
Pádraig Brady 1704600adc split: make the last specified --{hex,numeric} set the start
Given the FROM argument is interpreted as a different base
for --hex-suffixes and --numeric-suffixes, it makes more
sense for a previous start value to be discarded.

* doc/coreutils.texi: Mention this for --hex-suffixes,
and also mention the FROM argument is interpreted as hex.
* src/split.c (main): Just reset numeric_suffix_start,
and avoid reinterpretation validation.
* tests/split/numeric.sh: Adjust accordingly.
* NEWS: Mention the change in behavior.
2026-11-03 13:28:02 +00:00
Collin Funk aad192543e doc: dircolors: don't assume the shell starts in $HOME
* doc/coreutils.texi (dircolors invocation): Use an absolute path when
checking whether a user's .dircolors file exists in $HOME and when
loading it. Don't define a variable.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-HB2T3LWR.
2026-10-23 19:31:48 -07:00
Collin Funk 479317e6ce doc: dircolors: document reading from standard input
* src/dircolors.c (usage): Note that standard input is read when FILE is
"-".
* doc/coreutils.text (dircolors invocation): Likewise.
2026-10-23 19:31:38 -07:00
Pádraig Brady c543b3e56f doc: pr: improve the description of -a
* doc/coreutils.texi (pr invocation): Avoid the confusing
-COLUMN reference preferring the more standard --columns instead.
Fixes https://bugs.gnu.org/82075
2026-10-19 17:16:13 +01:00
Pádraig Brady 700d8235a3 all: only markup --help when outputting to tty
Since v9.10 (Feb 2026) --help always outputs bold and hyperlinks
even when output was not a tty, as this was thought more useful
with pagers and grep etc.  This change makes the more conservative
choice of only outputting markup to tty so that users who do not
have less setup to display color (-R), or users who enable color
by default in grep, get improved output (though without URLs etc.)

* src/system.h (oputs_): Call isatty() when not
forcing markup with $IN_HELP2MAN.  Also reverse the
double negatives to a more natural form.
* man/local.mk: Remove redundant assignment of $TERM.
* doc/coreutils.texi (common options): Mention that --help markup
requires output to be a tty, and that $IN_HELP2MAN overrides that.
* NEWS: Mention the change in behavior.
2026-10-10 21:02:48 +01:00
Pádraig Brady d454017b5d fold: restrict whole character backspace to -c
With POSIX (and the LI18NUX2000 patch) backspaces back up by 1 column.
This matches terminal output.  Note less(1) and thus grotty(1)
use per character backup accounting for their legacy bold/underline
markup format, so we'll keep --characters to enable that mode if needed.
This also avoids the issue of multiple backspaces
using the width of a single previous character.

* src/fold.c (adjust_column): Without -c,
have backspace back up by 1 column.
* doc/coreutils.texi (fold invocation): Mention that --characters
does per character width backspace accounting.
* tests/fold/fold-characters.sh: Add/Adjust test cases.
* NEWS: Mention the change in behavior.
2026-10-07 12:40:05 +01:00
Pádraig Brady f799b2f48a env,printenv: support --quoting-style to control quoting
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.
2026-09-17 08:52:12 +01:00
Pádraig Brady 782a1e5bc2 env,printenv: only quote when outputting to terminals
To support albeit non-robust but existing use cases like:

  env | grep SPARK_JAVA_OPT_ | sort -t_ -k4 -n |
   sed 's/[^=]*=\(.*\)/\1/g' > java_opts.txt
  readarray -t SPARK_EXECUTOR_JAVA_OPTS < java_opts.txt
  ...
  CMD=("${JAVA_HOME}/bin/java" "${SPARK_EXECUTOR_JAVA_OPTS[@]}" ...)

* src/env.c (main): Restrict quoting to terminals.
* src/printenv.c (main): Likewise.
* tests/env/env.sh: Adjust accordingly.
* tests/misc/printenv.sh: Likewise.
* doc/coreutils.texi: Likewise.

Link: https://github.com/coreutils/coreutils/issues/355
2026-09-17 08:52:12 +01:00
Paul Eggert 3474738f18 doc: File timestamps and POSIX.1-2024
* doc/coreutils.texi (File timestamps):
Update in the light of <https://bugs.gnu.org/13601#46>,
<https://austingroupbugs.net/view.php?id=1997>, and
POSIX.1-2024 Base Specifications 4.12 “File Times Update”.
2026-09-14 10:40:25 -07:00
Collin Funk ea1c2b1787 printenv: don't quote output when given arguments and redirected
* 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'.
2026-08-31 18:15:39 -07: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 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
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
Pádraig Brady e871648b79 env: allow bare --env0-from to round-trip
Support --env0-from reading any environment generated by -0,
irrespective of whether -i is specified.

* src/env.c (set_envvars_from_file): Now that this function
always builds its own vector, support reading entries
without an equals, which are just appended to the existing vector.
* doc/coreutils.texi (env invocation): Adjust accordingly.
* tests/env/env0-from.sh: Likewise.
2026-08-14 18:00:15 +01:00
Pádraig Brady ebbff3d4cb env: implement full round-tripping for -i --env0-from
* src/env.c: Construct environ directly, preserving order, duplicates,
empty entries, and entries without =.  Note non -i mode continues
using system putenv()/unsetenv().
* doc/coreutils.texi: Adjust acordingly.
* tests/env/env0-from.sh: Likewise.
* NEWS: Likewise.
2026-08-14 18:00:15 +01:00
Pádraig Brady adb4d98799 env: support --env0-from to read NUL separated vars from file
* doc/coreutils.texi (env invocation): Document --env0-from.
* src/env.c (set_envvars_from_file): A new function to parse
.*=.*\0 format files and augment the environment with them.
* tests/env/env0-from.sh: Add a new test.
* tests/local.mk: Reference new test.
* NEWS: Mention the new feature.
* THANKS.in: Add Stefan Klinger, who proposed/discussed the change.

Link: https://github.com/coreutils/coreutils/issues/324
2026-08-14 18:00:15 +01: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
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 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 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 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 e45c9e6c01 doc: install: mention -p may lose some of -C speed benefits
* doc/coreutils.texi (install invocation): Mention that
--preserve-timestamps may lose some of the speed advantages of -C,
due to needing to update timestamps for each build.
2026-07-15 11:34:48 +01:00
Pádraig Brady a4d74bb6df doc: wc: clarify that wc supports character counts
* doc/coreutils.texi: Adjust command summary.
* man/wc.x: Likewise.
Fixes https://bugs.gnu.org/81405
2026-07-14 17:30:29 +01:00
Pádraig Brady 51d66f8813 maint: avoid sc-lower-case-var syntax check failure
* doc/coreutils.texi (touch invocation): Use lower case for @var{}.
This is ambiguous for MM and mm, but these are not ambiguous
from the context, so shouldn't cause confusion.
2026-07-10 12:11:19 +01:00
Paul Eggert 9324c5ff4f touch: improve -d documentation
* doc/coreutils.texi (touch invocation):
Describe -d behavior for HH:MM:60 (Bug#81331), as it seems that a
future version of POSIX will bless GNU touch here.
Be clearer about POSIX vs GNU extensions with -d.
2026-07-09 16:36:12 -07:00
Paul Eggert 16d20596e1 doc: ‘mv --update’ has optional [=WHICH]
* doc/coreutils.texi (mv invocation):
‘mv --update’ has an optional WHICH, just like ‘cp --update’.
2026-07-08 13:33:59 -07:00
Pádraig Brady 53926ba7d8 doc: fix description of mv -n
The description of mv --no-clobber got out of sync
between commit v9.1-133-g7a69df889 and v9.4-134-g9907b6f5d

* doc/coreutils.texi (mv invocation): Copy most of the -n
description from the cp --no-clobber description.
* src/mv.c (usage): Likewise.  Note this explicitly deprectates
the mv -n option as like cp the exit code varies across platforms.
Solaris 11 was seen to silently fail, while Linux/FreeBSD succeed.
Fixes https://bugs.gnu.org/81377
2026-07-08 19:03:27 +01:00
Collin Funk c8d75f1f6b cksum: remove the ability to use AF_ALG
* gnulib: Update to latest gnulib for commit e191cc8118 (crypto/af_alg:
Deprecate., 2026-06-22).
* NEWS: Mention the removal of the --with-linux-crypto configure option.
* doc/coreutils.texi (Hardware Acceleration): Remove the reference to
--with-linux-crypto and the Linux kernel cryptographic API.
2026-06-22 19:57:01 -07:00
Pádraig Brady 5ce0a47fcc stat: change default quoting from shell-escape-always to shell-escape
This should not affect programatic parsing, because if you have to parse
the shell style, then the same logic will parse unescaped output.
This is a better default now that --terse uses quoted format by default,
and also the default output format quotes file names by default.

* src/stat.c (getenv_quoting_style): Change the default.
2026-06-04 13:48:09 +01:00
Pádraig Brady 5d3f03b4fb stat: use quoted file names with --terse
* src/stat.c: Use %Qn rather than a bare %n by default,
so output is maintained on a single line for parsing.
2026-06-04 13:48:05 +01:00
Pádraig Brady 49f3b66719 stat: support %Qn format to output quoted file name
%N also outputs the target of a symlink
so support %Qn to give more control over quoted names.

* src/stat.c (print_it): Validate %Qn.
(print_stat): Output quoted file name with %Qn.
(usage): Add %Qn description.
* doc/coreutils.texi (stat invocation): Likewise.
* tests/stat/stat-fmt.sh: Add a test case.
2026-06-04 13:14:27 +01:00
Pádraig Brady 35d7f1f3ef doc: stat: suppress ls specific info
* doc/coreutils.texi (stat invocation): Avoid outputting confusing
info specific to the ls command for QUOTING_STYLE.
2026-06-04 13:14:27 +01:00
Collin Funk 45bbd75fb0 doc: shred: mention unsupported file types
* src/shred.c (usage): Mention the behavior of 'shred' on FIFOs,
sockets, and terminals.
* doc/coreutils.texi (shred invocation): Likewise.
Addresses https://bugs.gnu.org/30177
2026-05-13 20:45:47 -07:00
Pádraig Brady b130ed810e doc: fix typo in chmod example
* doc/coreutils.texi (chmod invocation): s/file/foo/ to match comment,
and previous example.
2026-05-03 10:40:31 +01:00
Collin Funk c5ddd417aa comm: don't close standard input twice
* NEWS: Mention the bug fix.
* src/comm.c (usage): Remove mention that FILE1 and FILE2 cannot both be
standard input.
(compare_files): Only close standard input once.
* doc/coreutils.texi (comm invocation): Document the behavior of
'comm - -' which is not portable to all implementations.
* tests/comm/dash-dash.sh: New file.
* tests/misc/comm.pl: Move to tests/comm/comm.pl.
* tests/local.mk (all_tests): Add the new test. Rename the existing
test.
2026-04-22 19:12:44 -07:00
Pádraig Brady fe00823330 doc: cut: clarify that combining characters are not treated specially
This is for consistency with other implementations and since the
interface separates -b and -c it might in future support -g (graphemes).
Normalizing content with a filter seems like the most appropriate
approach anyway, as there are various normalizations possible including
case etc. rather than baking that into every tool
2026-04-05 13:15:56 +01:00
Pádraig Brady c3e819fadc doc: cut: resintate and expand -d info
* doc/coreutils.texi (cut invocation): Add back the -d description,
and adjust for multi-byte support, and expand on specifying a NUL
delimitier, and detail the behavior when the delimiter matches
the line delimiter.
2026-04-05 13:15:56 +01:00
Pádraig Brady 03a686a456 doc: cut: clarify that -s suppressed lines with only trimmed spaces
* doc/coreutils.texi (cut invocation): State explicitly that
-s --whitespace-delimited=trimmed will suppress lines that
do not have field separating blanks.
2026-04-05 13:15:56 +01:00
Pádraig Brady 2c1ea231ca doc: cut: mention the default -O used with -w
* doc/coreutils.texi (cut invocation): Mention the default
--output-delimiter is a TAB when matching runs of blanks in the input.
2026-04-05 13:15:56 +01:00
Pádraig Brady f5b7d38d13 doc: cut: reorder -s in texi
Keep in alphabetical order.
2026-04-05 13:15:56 +01:00
Pádraig Brady c1d7b492c6 doc: cut: document the -w option
* src/cut.c (usage): Mention blank characters are used to separate.
* doc/coreutils.texi (cut invocation): Likewise.  Also describe
the 'trimmed' argument and the relation to -F.
2026-04-05 13:15:56 +01:00