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

1975 Commits

Author SHA1 Message Date
Pádraig Brady
38aaf5e611 all: quote more user originated strings
* src/csplit.c: Quote arbitrary strings for clarity/safety.
* src/dircolors.c: Likewise.
* src/env.c: Likewise.
* src/split.c: Likewise.
* src/uniq.c: Likewise.
* tests/env/env-S.pl: Adjust accordingly.
* NEWS: Mention the improvement.
2026-10-23 14:08:24 +01:00
Pádraig Brady
4c4f2f55c3 basenc: fix incorrect base32hex input validation
* src/basenc.c (base32hex_decode_ctx_wrapper): Ensure we don't
accept base32 only characters for base32hex.
* tests/basenc/basenc.pl: Ensure negative base32hex tests have the
appropriate number of characters to test character validation
rather than just input size validation.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-EP1XO2G4.
2026-10-22 13:54:39 +01:00
Collin Funk
b919020cf5 factor: fix suffix validation on large integers
* src/factor.c (strtouuint): Return LONGINT_OVERFLOW only if all of the
characters are digits; otherwise, return LONGINT_INVALID.
* tests/factor/factor.pl: Add two test cases.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-IZ8PFQ7Q.
2026-10-21 20:00:43 -07:00
Pádraig Brady
6b9d96c694 build: update the gnulib submodule to latest
* gnulib: Update.
* NEWS: Mention the $GLIBC_TUNABLES improvement.
2026-10-21 17:49:20 +01:00
Pádraig Brady
218f81d978 stty: consistently honor the last specified speed
stty currently fails like:

  $ stty 9600
  $ saved=$(stty -g)
  $ stty 19200 "$saved"  # Sets 9600 but reports failure
  stty: 'standard input': unable to perform all requested operations

Whereas these work fine:

  $ stty 19200 9600
  $ stty "$saved" 19200

* NEWS: Mention the bug fix.
* src/speedgen (cbaud_to_speed): Determine the speed
from the control flag encoding.
* src/stty.c (recover_mode): If no separate speed specified,
update the speed from the specified control flags.
* tests/stty/stty-save-speed.sh: Add test cases.
2026-10-21 12:54:34 +01:00
Pádraig Brady
60e7bf4121 stty: support save/restore of speeds not encoded in control flags
Note this changes the output format of -g.
POSIX states that the -g format only needs to be compatible
with the stty implementation that produced it.
However we improve compatibility on Linux by only outputting
the explicit speeds when they're not encoded in the control flags.

* NEWS: Mention the change in behavior.
* src/stty.c (display_recoverable): Output the speeds if needed.
(recover_mode): Read the speeds if present.
* tests/stty/stty-save-speed.sh: Add a new test.
* tests/local.mk: Reference the new test.

Link: https://github.com/coreutils/coreutils/issues/384
2026-10-21 12:46:48 +01:00
Collin Funk
f8ba084b3f stty: don't treat baud rates of (speed_t) -1 as invalid
* src/stty.c (struct speed_desc): New type, used to differentiate
between errors and (speed_t) -1.
(last_ibaud, last_obaud): Define variables as struct speed_desc instead
of speed_t.
(check_speed): Adjust uses of last_ibaud and last_obaud to their new
definitions.
(set_speed): Likewise. Use a struct speed_desc as the argument instead
of speed_t. Check for its validity using the valid member instead of
whether it is equal to (speed_t) -1.
(apply_settings): Use struct speed_desc instead of speed_t to store the
result of string_to_baud. Check for its validity using the valid member
instead of whether it is equal to (speed_t) -1.
(string_to_baud): Adjust the function to return a struct speed_desc
instead of speed_t.
* src/speedgen (value_to_baud): Likewise.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/issues/383
2026-10-19 18:23:56 -07:00
Collin Funk
1d5142dc09 all: use the basename of argv[0] for the comm value in the single binary
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.
2026-10-18 09:43:44 -07:00
Collin Funk
4886391906 doc: NEWS: mention the --enable-single-binary=symlinks comm value fix
* NEWS: Mention that the program name instead of argv[0] is used when
calling prctl (PR_SET_NAME, ...).
2026-10-16 21:16:10 -07:00
Pádraig Brady
292bd77de7 stty: fix incorrectly accepting empty speeds
* src/stty.c (string_to_baud): Disallow empty speeds.
* tests/stty/stty-invalid.sh: Add checks.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/issues/380
2026-10-14 18:07:23 +01:00
Iván Ezequiel Rodriguez
6ab90e2010 tail: improve scalability of follow-by-name directory events
Replace the O(N) scan of watched names on each directory inotify event
with a Hash_table keyed by (parent_wd, basename), addressing the
long-standing FIXME in tail_forever_inotify.

Keep ownership consistent with wd_to_name: parent_by_name is created
only for Follow_name and returned to the caller, so fallback paths can
return without local hash cleanup.

Hash basenames with hash_string() and mix in parent_wd, matching the
existing gnulib helper rather than a hand-rolled string hash.

Matching cost for N directory events that each compare against N names
(illustrative host timings of the scan vs hash lookup alone):

  N=1000:  ~0.018s -> ~0.000s
  N=5000:  ~0.39s  -> ~0.000s
  N=10000: ~1.5s   -> ~0.000s

End-to-end recreate storms remain largely file-system bound on this
host; the hash removes the quadratic name-matching CPU from that path.

* src/tail.c (parent_name_hasher, parent_name_comparator): New.
(tail_forever_inotify): Build and use parent_by_name; return it to the
caller.
(main): Free parent_ht when non-NULL.
* tests/tail/inotify-parent-hash.sh: Require notification mode; cover
multiple names in one directory and the same basename in two
directories.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
2026-10-13 14:33:22 +01:00
Pádraig Brady
445105045d build: consolidate smack avoidance to --without-libsmack
configure accepted (and needed) both --without-libsmack
and --disable-libsmack specified, to fully disable support.

* gl/modules/smack: Require gl_FUNC_ACL_ARG so we
use a consistent and single --without-libsmack option.
This also better aligns with --without-selinux.
* NEWS: Mention the Build-related change.
2026-10-13 11:32:44 +01:00
Pádraig Brady
402bce6637 ls: fix missing ACL indicators or capability colors
On systems where the security context reports as unsupported,
and we encountered a file without ACLs, no further lookups
would be performed.  Introduced in commit v9.5-156-gb857d66b5.
This fix is along similar lines as commit v9.6-40-gcb2abbac7.

* src/ls.c (file_has_aclinfo_cache): Don't mark file system as
unsupported if there might be ACLs or capabilities present.
* tests/ls/acl-cache.sh: Add a new test.
* tests/local.mk: Reference the new test.
* tests/ls/acl.sh: Add a check.
* NEWS: Mention the bug fix.
2026-10-13 11:32:41 +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
a40b8d1191 tr: accept undocumented -u for FreeBSD / macOS compat
* src/tr.c (main): Accept -u to set stdout to unbuffered.
* NEWS: Mention the new feature.

Link: https://github.com/coreutils/coreutils/issues/374
2026-10-10 21:02:40 +01:00
Collin Funk
9c7cf20c3c doc: NEWS: mention the fix from the previous commit
* NEWS: Mention the crash when invoking various programs --help option
when configured with --disable-bold-man-page-references and
--disable-manual-url.
2026-10-08 21:17:26 -07:00
Pádraig Brady
f23566441f basenc: improve base58 encoding performance without gmplib
$ ./configure --without-libgmp --quiet
  $ dd bs=64k count=1 if=/dev/urandom of=58.in

  $ time src/basenc-before --base58 58.in >/dev/null
  real	0m6.588s

  $ time src/basenc-after --base58 58.in >/dev/null
  real	0m3.463s

* src/basenc.c (base58_encode): Remove an affirm that is very expensive
in the minigmp implementation.  Essentially the same affirm was done
at the start of the function anyway.
* NEWS: Mention the improvement (including the impending similar
mpz_sizeinbase() removal from mini-gmp).
2026-10-08 13:45:41 +01:00
Paul Eggert
c3709a88f2 wc: fix buffer boundary calculations
Problem reported by Scott Orme (Bug#82013).
* src/wc.c (wc): Fix calculations of file sizes vs page size
vs block size.
2026-10-07 23:26:45 -07: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
e7d10e546a fold: fix backspace accounting after TAB
* src/fold.c (adjust_column): Ensure BS goes back
1 column after a TAB.
* tests/fold/fold-characters.sh: Add test cases.
* NEWS: Mention the bug fix.
2026-10-07 12:40:05 +01:00
Pádraig Brady
1af1bbf33b fold: fix backspace handling with multi-cell characters
* src/fold.c (adjust_column): Clamp the column decrement to 0.
* tests/fold/fold-characters.sh: Add a test case.
* NEWS: Mention the bug fix.
2026-10-07 12:40:05 +01:00
Ismail Ramzi
b9776257e8 chroot: prefer the in-chroot primary group with --userspec=USER
* src/chroot.c (main): When the primary group was inferred from the
uid outside the chroot, let a successful getpwuid() inside the chroot
replace it, as is already done for the uid and supplemental groups.
Previously the gid found outside persisted, so for example
'chroot --userspec=alice NEWROOT' ran with alice's uid from NEWROOT
but alice's gid from the host.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/pull/363
2026-10-07 12:33:14 +01:00
Pádraig Brady
b64df1ef3d all: fix U+0085 (next line) being considered a separator
cut, expand, fold, join, numfmt, unexpand, uniq, on non-GLIBC platforms
treated the \u0085 (next line) character as a blank character.

src/system.h (c32isvertspace): Include 0x0085 so c32issep() excludes it.
Also split out to ...
(c32isnewline): ... a new function, in case we need to
consider unicode newlines in isolation in future.
* tests/unexpand/mb.sh: Add a test case to both ensure
processing of \u0085 characters does not overflow a buffer,
and that those characters are not treated as separators.
* NEWS: Mention the fix.

Link: https://github.com/coreutils/coreutils/pull/361
2026-10-03 23:31:54 +01:00
Ismail Ramzi
52e5694f41 unexpand: fix heap overflow on negative-width whitespace
* src/unexpand.c (unexpand): Clamp a negative c32width() to 1 when
accumulating a blank, matching the sibling non-blank path and expand
and fold.  A separator whose display width is negative (e.g. U+0085
where c32issep() accepts it) left 'column' un-advanced, so the pending
blank buffer, sized for one byte of advance per blank, grew without
bound.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/pull/361
2026-10-03 23:31:49 +01:00
Pádraig Brady
3aae63af9a wc: optimize ASCII and UTF8 character counting
Generate ASCII and UTF-8 data:
  $ yes $(yes eeeaae | head -n10K | paste -s -d,) | head -n10K > ll.in
  $ yes $(yes éééááé | head -n9 | paste -s -d,) | head -n1M > mb.in

ASCII is 14x faster:
  $ time src/wc-before -m < ll.in
  real	0m1.801s
  $ time src/wc-after -m < ll.in
  real	0m0.123s

UTF-8 is 7x faster:
  $ time src/wc-before -m < mb.in
  real	0m1.399s
  $ time src/wc-after -m < mb.in
  real	0m0.189s

* src/wc.c (wc): Use the u8_count() routine like cut(1),
to optimize counting valid UTF-8 characters.
* tests/wc/wc.pl: Add a test case.
* NEWS: Mention the improvement.
2026-10-03 15:47:15 +01:00
Pádraig Brady
5ef76b9ac8 wc: fix handling of multi-byte chars spanning buffers
Commit v9.4-43-ga6064bb86 introduced this edge case
in handling multi-byte characters spanning the input buffer.

* src/wc.c (wc): Ensure we include the bytes previously read
but as yet unprocessed.
* tests/wc/mb-non-utf8.sh: Add a new test for miscounted GB118030 chars.
* tests/local.mk: Reference the new test.
* tests/wc/wc.pl: Add a new check for word count with a
UTF-8 space spanning a buffer boundary.
* NEWS: Mention the bug fix.
2026-10-03 15:47:15 +01:00
Pádraig Brady
0bbf12284a doc: NEWS: mention readlink also had an infinite loop bug
* NEWS: Mention the readlink and realpath options
that trigger the infinite loop bug.
2026-09-29 20:35:50 -07:00
Pádraig Brady
d97b6827c7 cut: -f -w: optimize no delimiters in uni-byte locales
Increases throughput when no delimiters found by up to 15x.

  $ yes | head -n10M > sl.in

  $ time LC_ALL=C src/cut-before -f10 -w sl.in >/dev/null
  real	0m0.171s

  $ time LC_ALL=C src/cut-after -f10 -w sl.in >/dev/null
  real	0m0.011s

* src/cut.c (cut_fields_bytesearch): Also add a byte search
shortcut for the -w case in uni-byte locales.
2026-09-29 13:34:32 +01:00
Pádraig Brady
45cdd85366 cut: -c: optimize extracting the start of a line
Performance was tested with GCC 16 on an i7-5600U with
CFLAGS='-march=native -O3 -flto' with the following setup:

$ yes | head -n10M > sl.in
$ yes $(yes eeeaae | head -n10K | paste -s -d' ') | head -n10K > llw.in
$ yes $(yes eeeaae | head -n9 | paste -s -d' ') | head -n1M > asw.in
$ yes $(yes éééááé | head -n9 | paste -s -d$'\xe2\x80\x83') |
   head -n1M > mbw.in

for type in sl llw asw mbw; do
  cat $type.in >/dev/null;
  for imp in '-before' '-after'; do
    echo ============ "${imp:-base}" $type ==============;
    for d in -c; do
      fields='-f1 -f10 -f100'
      test "$d" = "-c" && { fields='-c1 -c10 -c100000'; d=''; }
      for f in $fields; do
        for loc in C.UTF-8; do
          # Skip -b for UTF-8 as no different
          test "$loc" = C.UTF-8 && echo "$f" | grep -q -- -b \
           && continue
          # Skip multi-byte delimiter for C and not allowed
          test "$loc" = C && test $(echo -n "$d" | wc -c) -ge 4 \
           && continue
          bin=src/cut${imp}
          LC_ALL=$loc $bin $f $d /dev/null 2>/dev/null &&
          hyperfine --warmup=2 -m2 -M6 \
           "LC_ALL=$loc $bin $f $d $type.in >/dev/null" ||
          printf 'Benchmark 1: %s\n  unsupported\n\n' \
           "LC_ALL=$loc $bin $f $d $type.in >/dev/null"
        done;
      done;
    done;
  done;
done

After a little post-processing of the results, we get:

-- src/cut-before

| command       |       sl |      llw |      asw |      mbw |
| ------------- | -------- | -------- | -------- | -------- |
| UTF8 -c1      |  60.7 ms |  1.244 s | 123.5 ms | 515.2 ms |
| UTF8 -c10     |  39.3 ms |  1.248 s | 127.4 ms | 526.0 ms |
| UTF8 -c100000 |  39.4 ms |  1.242 s | 121.4 ms | 514.3 ms |

-- src/cut-after

| command       |       sl |      llw |      asw |      mbw |
| ------------- | -------- | -------- | -------- | -------- |
| UTF8 -c1      |  70.9 ms | 105.5 ms |  27.0 ms |  47.6 ms |
| UTF8 -c10     |  55.7 ms | 105.7 ms |  48.2 ms | 126.8 ms |
| UTF8 -c100000 |  55.2 ms |  1.596 s | 158.8 ms | 555.1 ms |

* src/cut.c (cut_characters_mode): Shortcut the line delimiter
search if finished processing characters.
* tests/cut/cut.pl: Add a test case.
2026-09-29 13:34:00 +01:00
Collin Funk
b66f3e4e27 realpath: fix an infinite loop when resolving symbolic links
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.
2026-09-25 20:32:56 -07:00
Pádraig Brady
49efaeaaab tail: without inotify, ensure prompt output
This was seen with a NetBSD failure in the pipe-f2.sh test
due to it clearing the EOF indication on a fifo, and thus
blocking in the subsequent read.  That was discussed at:
https://lists.gnu.org/r/coreutils/2026-04/msg00129.html
https://bugs.gnu.org/81923
Note the NetBSD issue may be addressed in NetBSD 12 as
discussed in the bug above.

This is more defensive/consistent in the case
where a subsequent read on a file blocks.
We might be operating on non fifos after all.

* src/tail.c (tail_forever): Flush output before we might block.
* tests/tail/pipe-f2.sh: Test non inotify path on all platforms.
* NEWS: Mention the improvement.
2026-09-25 15:17:08 +01:00
Pádraig Brady
a5052b771f build: replace distributed gzipped sources with zstandard
zstd compressed sources are less than half the size
of gzip coompressed sources, so are a better secondary
distribution format in addition to xz.

* README-prereq: Remove gzip, Add zstd.
* bootstrap.conf (buildreq): Likewise.
Bump automake version check to 1.16.2 (released 2020).
* configure.ac (AM_INIT_AUTOMAKE): Disable gz, add dist-zstd.
Bump automake version requirement to 1.16.2.
* cfg.mk: Use compression level 18, and multi-threading.
* NEWS: Mention the change.
2026-09-25 13:19:24 +01:00
Pádraig Brady
c12f1296e0 od: halve the memory used when not suppressing duplicates
* src/od.c (dump): Only use a single memory block
when there is no need to compare against the previous block.
2026-09-21 14:59:36 +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
738bd25727 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2026-09-14 16:30:16 +01:00
Pádraig Brady
c0f8514d98 version 9.12
* NEWS: Record release date.
2026-09-14 15:55:07 +01:00
Ismail Ramzi
25792e3763 ls: fix use-after-free reading LS_COLORS ln=target
parse_ls_color stores color_indicator[C_LINK].string as a pointer into
the color_buf buffer, then frees color_buf on the unparsable-value path.
The "ln=target" check after the parse loop still read that freed buffer,
e.g. with LS_COLORS='ln=target:x'.  Skip it on the failure path, where
color output is disabled anyway and the buffer is gone.
* src/ls.c (parse_ls_color): Return after freeing color_buf on failure,
so the color_indicator[C_LINK] check only runs when the buffer is live.
* tests/ls/color-symlink-target.sh: New test.
* tests/local.mk (all_tests): Add it.
* NEWS: Mention the fix.

Link: https://github.com/coreutils/coreutils/pull/352
2026-09-14 03:07:54 +01:00
Pádraig Brady
7f973c4e83 stat,tail: recognize failfs file system type
* src/stat.c (human_fstype): Add "failfs" (0x4641494C).
* NEWS: Mention the improvement.
2026-09-07 18:15:24 +01:00
Pádraig Brady
bff0e5412d build: sort: explicitly tag libcrypto dependency
This adds an ELF note as per the UAPI Group's .note.dlopen spec:

  $ readelf -p .note.dlopen src/sort
  String dump of section '.note.dlopen':
    [     4]  y
    [     a]  |@FDO
    [    10]  [{"feature":"random-sort",
                "description":"Support for random sorting",
                "priority":"required",
                "soname":["libcrypto.so.3"]}]

* bootstrap.conf: Add sd-dlopen.
* src/sort.c (DLOPEN_LIBCRYPTO && HAVE_OPENSSL_MD5): Add an ELF note
with SD_ELF_NOTE_DLOPEN() so that packagers can determine the libcrypto
dependency, needed when --random-sort is specified.
* NEWS: Mention the Build-related change.
2026-09-06 23:16:55 +01:00
Collin Funk
b2fc0baf2c doc: NEWS: fix mismatched quotation marks
* NEWS: Use '...' instead of '...`.
2026-09-04 13:57:55 -07:00
Pádraig Brady
71419a36f7 cut: -w: optimize extracting the start of a line
There were no significant performance changes from the test cases
in commit a325c9978, but adding additional whitespace delimited cases
shows significant improvement.  Below, with -f1, typical space delimited
input shows 4x more throughput, while the long line test shows 17x more.

Performance was tested with GCC 16 on an i7-5600U with
CFLAGS='-march=native -O3 -flto' with the following setup:

$ yes | head -n10M > sl.in
$ yes $(yes eeeaae | head -n10K | paste -s -d' ') | head -n10K > llw.in
$ yes $(yes eeeaae | head -n9 | paste -s -d' ') | head -n1M > asw.in
$ yes $(yes éééááé | head -n9 | paste -s -d$'\xe2\x80\x83') |
   head -n1M > mbw.in

for type in sl llw asw mbw; do
  cat $type.in >/dev/null;
  for imp in '-before' '-after'; do
    echo ============ "${imp:-base}" $type ==============;
    for d in -w; do
      fields='-f1 -f10 -f100'
      test "$d" = "-b" && { fields='-b1 -b10 -b100'; d=''; }
      test "$d" = "-c" && { fields='-c1 -c10 -c100'; d=''; }
      for f in $fields; do
        for loc in C.UTF-8; do
          # Skip -b for UTF-8 as no different
          test "$loc" = C.UTF-8 && echo "$f" | grep -q -- -b \
           && continue
          # Skip multi-byte delimiter for C and not allowed
          test "$loc" = C && test $(echo -n "$d" | wc -c) -ge 4 \
           && continue
          bin=src/cut${imp}
          LC_ALL=$loc $bin $f $d /dev/null 2>/dev/null &&
          hyperfine --warmup=2 -m2 -M6 \
           "LC_ALL=$loc $bin $f $d $type.in >/dev/null" ||
          printf 'Benchmark 1: %s\n  unsupported\n\n' \
           "LC_ALL=$loc $bin $f $d $type.in >/dev/null"
        done;
      done;
    done;
  done;
done

After a little post-processing of the results, we get:

-- src/cut-before

| command         |       sl |      llw |      asw |      mbw |
| --------------- | -------- | -------- | -------- | -------- |
| UTF8 -f1 -w     |  96.2 ms |  1.916 s | 190.6 ms | 906.5 ms |
| UTF8 -f10 -w    | 104.6 ms |  1.921 s | 187.7 ms | 845.6 ms |
| UTF8 -f100 -w   | 104.4 ms |  1.916 s | 187.4 ms | 846.4 ms |

-- src/cut-after

| command         |       sl |      llw |      asw |      mbw |
| --------------- | -------- | -------- | -------- | -------- |
| UTF8 -f1 -w     |  88.7 ms | 112.4 ms |  43.5 ms | 146.3 ms |
| UTF8 -f10 -w    |  95.2 ms | 114.4 ms | 193.5 ms | 848.4 ms |
| UTF8 -f100 -w   |  94.8 ms | 130.6 ms | 194.4 ms | 848.1 ms |

* src/cut.c (scan_mb_line_end): A new function to skip
to EOL once we have exhausted the field selection.
(cut_fields_mb_any): Only skip after recognizing a field delimiter.
* tests/cut/cut.pl: Add test cases.
* tests/cut/mb-non-utf8.sh: Likewise.
* NEWS: Mention the improvement.
2026-09-04 21:10:45 +01:00
Paul Eggert
1ee46ac2c9 cp: ioctl+FICLONE EIO now fails without fallback
Problem reported by Pádraig Brady (bug#81776#16).
* src/copy.c (handle_clone_fail): Be more cautious if
ioctl+FICLONE failed with EIO; do not fall back to read+write,
even if --reflink=auto is in effect.
2026-09-03 00:57:54 -07:00
Paul Eggert
be8600bb24 cp: treat EDQUOT etc. like ENOSPC
Assume that XFS allocation groups can also fail with EDQUOT etc.,
so treat those failures like ENOSPC.
* src/copy.c (is_terminal_error): Remove; no longer used.
(handle_clone_fail): Remove DEST_DESC arg; no longer needed.
All uses changed.  Simplify by acting as if is_terminal_error
always returns false.  Change "!= 0" to "< 0" when either will do
for a syscall, as a matter of convention.
2026-09-02 12:40:16 -07:00
Pádraig Brady
51d40b1ab1 cp,install,mv: try a standard copy if clone fails with ENOSPC
reflinking can fail due to failure to allocate metadata,
while a standard copy may succeed.

* src/copy.c (is_terminal_error): Remove ENOSPC from the list.
Fixes https://bugs.gnu.org/81776
2026-09-02 19:25:42 +01:00
H. Peter Anvin
409225d662 stty: handle kernel speed encoding variations
eq_mode(), which is used to determine if tcsetattr() was successful,
failed unnecessarily after speed setting under certain circumstances:

1. the kernel MAY round the speed to the nearest supported value,
   so allow a variation of +/- 1/4 bit time per character from
   what was originally requested.

2. There MAY be more than one internal binary encoding of a specific
   speed (e.g. on Linux). On systems where that information
   affects c_cflag, this may introduce inconsistencies;
   filter out the known speed-related flags in c_cflag.

3. It is undefined in POSIX if cfsetispeed (..., 0) is retained or
   normalized across tcsetattr () ... tcgetattr ().
   If cfgetispeed () returns 0, compare the output speed instead.

* src/stty.c (eq_mode): Mask of some of the speed related bits
to avoid checking them for exact equality.
(speed_matches): A new helper to apply the more lenient matching
of requested and resulting speeds.
* NEWS: Mention the bug fix.
2026-09-01 19:12:42 +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
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
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
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
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