Commit Graph

1175 Commits

Author SHA1 Message Date
Pádraig Brady
07eedce2d3 doc: update the md5/sha1 "weak hash" advisory
* doc/coreutils.texi: Adjust advisory for md5sum and sha1sum
to include "sha3", and also the more general `cksum -a` interface.
2025-09-04 18:19:15 +01:00
Pádraig Brady
aba9800995 cksum: prefer -a sha2 -l ###, to -a sha###
To make the interface more concise and consistent,
while being backwards compatible.

* src/digest.c (main): Continue to support -a "sha###" but
also support -a "sha2" and treat it like "sha3", except in...
(output_file): ... maintain the legacy tags for better compatability.
* doc/coreutils.texi (cksum invocation): Document the -a sha2 option.
* tests/cksum/cksum-base64.pl: Adjust as per modified --help.
* tests/cksum/cksum-c.sh: Add new supported SHA2-### tagged variant.
* NEWS: Mention the new feature.
2025-09-04 14:49:07 +01:00
Collin Funk
403d82a0bf cksum: add support for SHA-3
* src/digest.c: Include sha3.h.
(BLAKE2B_MAX_LEN): Rename to
DIGEST_MAX_LEN since it is also used for SHA-3.
(sha3_sum_stream): New function.
(enum Algorithm, algorithm_args, algorithm_args, algorithm_types)
algorithm_tags, algorithm_bits, cksumfns, cksum_output_fns): Add entries
for SHA-3.
(usage): Mention that SHA-3 is supported. Mention requirements for
--length with SHA-3.
(split_3): Use DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Determine the
length of the digest for SHA-3. Make sure it is 224, 256, 384, or 512.
(digest_file): Set the digest length in bytes. Use DIGEST_MAX_LEN
instead of BLAKE2B_MAX_LEN. Always append the digest length to SHA3 in
the output.
(main): Allow the use of --length with 'cksum -a sha3'.  Use
DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Make sure it is 224, 256,
384, or 512.
* tests/cksum/cksum-base64.pl (@pairs): Add expected sha3 output.
(fmt): Modify the output to use SHA3-512 since that is the default.
(@Tests): Modify arguments for sha3 to use --length=512.
* tests/cksum/cksum-sha3.sh: New test, based on tests/cksum/b2sum.sh.
* tests/local.mk (all_tests): Add the test.
* bootstrap.conf: Add crypto/sha3.
* gnulib: Update to latest commit.
* NEWS: Mention the change.
* doc/coreutils.texi (cksum general options): Mention sha3 as a
supported argument to the -a option. Mention that 'cksum -a sha3'
supports the --length option. Mention that SHA-3 is considered secure.
2025-09-03 22:29:33 -07:00
Collin Funk
7d0d9658f9 fold: add the --characters option
* src/fold.c: Include mcel.h.
(count_bytes): Remove variable.
(counting_mode, last_character_width): New variables.
(shortopts, long_options): Add the option.
(adjust_column): If --characters is in used account for number of
characters instead of their width.
(fold_file): Use getline and iterate over the result with mcel functions
to handle multibyte characters.
(main): Check for the option.
* src/local.mk (src_fold_LDADD): Add $(LIBC32CONV), $(LIBUNISTRING), and
$(MBRTOWC_LIB).
* tests/fold/fold-characters.sh: New file.
* tests/fold/fold-spaces.sh: New file.
* tests/fold/fold-nbsp.sh: New file.
* tests/local.mk (all_tests): Add the tests.
* NEWS: Mention the new option.
* doc/coreutils.texi (fold invocation): Likewise.
2025-08-22 22:09:50 -07:00
Pádraig Brady
c4df55be7f nproc: honor cgroup v2 CPU quotas
* NEWS: Mention the new feature.
* doc/coreutils.texi (nproc invocation): Mention that
cgroup CPU quotas can limit the reported number.
* gnulib: Update to new nproc gnulib implementation:
https://github.com/coreutils/gnulib/commit/9b07115f4a
2025-08-19 17:24:21 +01:00
Paul Eggert
ae6fd2b4a1 realpath: improve doc and NEWS 2025-08-14 21:08:44 -07:00
Paul Eggert
39eec70f7b tsort: add do-nothing -w option
This is for conformance to POSIX.1-2024
* src/tsort.c: Include getopt.h.
(main): Accept and ignore -w.  Do not bother altering
the usage message, as the option is useless.
* tests/misc/tsort.pl (cycle-3): New test.
2025-08-14 17:35:23 -07:00
Collin Funk
2a092e80e2 realpath: support the -E option required by POSIX
* src/realpath.c (longopts): Add the option.
(main): Likewise.
(usage): Add the option to the --help message.
* tests/misc/realpath.sh: Add a simple test.
* doc/coreutils.texi (realpath invocation): Mention the new option.
* NEWS: Likewise.
2025-08-10 11:41:56 -07:00
Pádraig Brady
192e09042f doc: --base58: add example usage to info
* doc/coreutils.texi (basenc invocation): Add an example
using --base58 to generate a unique ID.  This also demonstrates
compound usage of the basenc command, to convert to/from binary.
2025-08-10 16:21:42 +01:00
Pádraig Brady
02c3d43e3a basenc: add base58 support
A 58 character encoding that:
 - avoids visually ambiguous 0OIl characters
 - uses only alphanumeric characters
Described at:
 - https://tools.ietf.org/html/draft-msporny-base58-03

This implementation uses GMP (or gnulib's gmp fallback).
Performance is good in comparison to other implementations.
For example when using libgmp on an i7-5600U system,
encoding is 530 times faster, and decoding 830 times faster
than the implementation using arbitrary precision ints in cpython 3.13.

Memory use is proportional to the size of input.

Encoding benchmarks:

  $ time yes | head -c65535 | src/basenc --base58 -w0 >file.enc
  real    0m0.018s

  ./configure --quiet --without-libgmp && make -j $(nproc)
  $ time yes | head -c65535 | src/basenc --base58 -w0 >file.enc
  real    0m3.431s

  # dnf install python3-base58
  $ time yes | head -c65535 | base58 >file.enc  # cpython 3.13
  real    0m9.700s

Decoding benchmarks:

  $ time src/basenc --base58 -d <file.enc >/dev/null
  real    0m0.010s

  $ ./configure --without-libgmp && make  # gnulib gmp
  $ time src/basenc --base58 -d <file.enc >/dev/null
  real    0m0.145s

  $ time base58 -d <file.enc >/dev/null  # cpython 3.13
  real    0m8.302s

* src/basenc.c (base_decode_ctx_finalize, base_encode_ctx_init,
base_encode_ctx, base_encode_ctx_finalize): New functions to
provide more general processing functionality.
(base58_{de,en}code_ctx{_init,,_finalize}): New functions to
accumulate all input before calling ...
(base58_{de,en}code): ... the GMP based encoding/decoding routines.
(do_encode, do_decode): Call the ctx variants if enabled.
* doc/coreutils.texi (basenc invocation): Describe the new option,
and indicate the main use case being interactive user use.
* src/local.mk: Link basenc with GMP.
* tests/basenc/basenc.pl: Add test cases.
* NEWS: Mention the new feature.
2025-08-09 22:10:27 +01:00
Paul Eggert
93805484c5 tail: fix unlikely races with >=2 --pids
Also, fix commentary to talk about “nonexistent” rather than
“dead” processes, since the code looks for the former not the
latter and the difference matters for zombies.
* src/tail.c (some_writers_exist): Rename from writers_are_dead,
negate the sense, don’t have a special and counterintuitive case
for !nbpids, remove PIDs found not to exist, and avoid some
though not all unlikely races when kernels reuse PIDs.
(tail_forever): Optimize via blocking I/O even if --pid was used,
so long as all the writers no longer exist.
(tail_forever, tail_forever_inotify): Simplify the writers_dead
logic; there is no need to have a local var to track this, since
we can use pids and nbpids now.
(parse_options): Also free and clear pids if !forever.
2025-08-03 19:48:06 -07:00
Collin Funk
2ff3c65e94 readlink: improve documentation for POSIXLY_CORRECT in --help
* NEWS: Improve wording to not imply POSIXLY_CORRECT=1 readlink -q will
be verbose.
* src/readlink.c (usage): Mention the affect of POSIXLY_CORRECT on
-s (--silent), -q (--quiet), and -v (--verbose) in the help message.
(main): Remove spurious newline added by previous commit.
* doc/coreutils.texi (readlink invocation): Mention that -s (--silent)
and -q (--quiet) are not the default when POSIXLY_CORRECT is set.
2025-08-03 12:33:55 -07:00
Collin Funk
ecd803805d readlink: emit errors when POSIXLY_CORRECT is set
* src/readlink.c (main): Set verbose if the POSIXLY_CORRECT environment
variable is set.
* tests/readlink/readlink-posix.sh: New file.
* tests/local.mk (all_tests): Add it.
* NEWS: Mention the change.
* doc/coreutils.texi (readlink invocation): Document the behavior of
POSIXLY_CORRECT.
2025-08-03 10:55:54 -07:00
Pádraig Brady
69f21c5d46 doc: use consistent references to standard files
* cfg.mk (sc_standard_outputs): A new syntax check to
enforce standard references.
* doc/coreutils.texi: s/stderr/standard error/ etc.
* src/date.c: Likewise.
* src/dd.c: Likewise.
* src/env.c: Likewise.
* src/sort.c: Likewise.
* src/split.c: Likewise.
* src/stty.c: Likewise.
* src/timeout.c: Likewise.
* src/who.c: Likewise.
2025-07-29 11:43:09 +01:00
Bruno Haible
4a3eb45d72 date: update documentation regarding non-Gregorian calendars
* doc/coreutils.texi (Calendars): New section.
2025-07-21 21:18:25 +01:00
Paul Eggert
2ce3fc0c1b doc: update ‘factor’ benchmarks 2025-07-09 17:12:40 -07:00
Paul Eggert
5037ce930c factor: don’t prove primality
Suggested for consideration by Torbjörn Granlund in:
https://lists.gnu.org/r/coreutils/2025-01/msg00000.html
* src/factor.c (PROVE_PRIMALITY): Now defaults to false.
(mp_prime_p): Help the compiler by telling it mpz_prob_prime_p
returns nonnegative.
* tests/factor/create-test.sh (bigprime): Test 2^400 - 593,
since that’s now practical.
* tests/local.mk (factor_tests): Add new test.
2025-07-09 17:12:40 -07:00
Collin Funk
2230933f84 doc: fix a dead link
* doc/coreutils.texi (Block Size): Use an updated link to SI prefixes.
2025-07-05 09:57:29 -07:00
Collin Funk
9cb89ff084 doc: remove outdated TODO/FIXME items
* TODO: Remove note about missing documentation for 'pinky' and '['.
* doc/coreutils.texi: Likewise.
2025-07-02 18:51:02 -07:00
Pádraig Brady
ab21f2e95e doc: remove extraneous double quotes within @samp{}
* doc/coreutils.texi (df invocation): @samp{} items
are suitably quoted already.
2025-07-01 12:02:08 +01:00
Collin Funk
1535ac272e doc: use ``...'' instead of "..."
* doc/coreutils.texi (split invocation): Use ``...'' for quoting text.
(cksum common options): Likewise.
(Control): Likewise.
2025-06-30 19:50:58 -07:00
Collin Funk
2a08ab2bd5 doc: list signals added by POSIX.1-2024
* doc/coreutils.texi (Signal specifications): Mention that POSIX.1-2024
added SIGWINCH.
2025-06-27 22:15:28 -07:00
Collin Funk
cc01e72491 doc: mention that POSIX.1-2024 added dd iflag=fullblock
* doc/coreutils.texi (dd invocation): Document that POSIX.1-2024 added
iflag=fullblock.
2025-06-27 20:10:09 -07:00
Pádraig Brady
7c2729cb58 doc: cksum: --check: improve supported formats description
* doc/coreutils.texi (cksum common options): Reorder and tweak the info
to make it clearer that --check does not support the legacy crc output
from the cksum command.
Reported at https://bugs.debian.org/1108363
2025-06-27 19:50:51 +01:00
Pádraig Brady
44809c3379 od: fix various off-by-one issues with --strings with -N
* src/od.c (dump_strings): There are three related issues here
due to not accounting for the terminating NUL char appropriately.

1. Ensure BUF always has enough space for the terminating NUL.
This avoids CWE-122: Heap-based Buffer Overflow,
where we wrote a single NUL byte directly after the allocated buffer.
I.e., there should be no buffer overflow with:
  printf '%100s' | od -N100 -S1

2. Ensure we support -S == -N (END_OFFSET - STRING_MIN == ADDRESS):
I.e., there should be output with:
  printf '%100s' | od -N10 -S10

3. Ensure we always output a valid address by ensuring
the ADDRESS and I variables are kept in sync.
I.e., this should output address 0000000 not 1777777777777777777777:
  printf '%100s' | od -N10 -S1

As well as fixing these we simplify by using a single loop
to read the data, rather than two.

* doc/coreutils.texi (od invocation): Clarify that -N
implicitly NUL terminates strings.
* tests/od/od-N.sh: Add test cases.
* NEWS: Mention the bug fixes.

Fixes https://bugs.gnu.org/78880
2025-06-24 16:21:00 +01:00
Pádraig Brady
8b05eca972 doc: stty: adjust description of supported speeds
* doc/coreutils.texi (stty invocation): Remove now imprecise
list of speeds given we may now support higher or arbitrary speeds.
Mention that we may support higher or arbitrary speeds.
2025-06-22 15:01:21 +01:00
Paul Eggert
aec89a3e7d tty: better fix for Bug#26371
* src/tty.c (TTY_USAGE): Rename from TTY_FAILURE, since this
is used only for usage failures.  All uses changed.
(TTY_TTYNAME_FAILURE): New constant.
(main): Remove no-longer-needed assignment of ENOENT to errno.
Make status-setting clearer too.
Report an error if ttyname fails even though stdin is a terminal,
instead of silently pretending that stdin is not a terminal.
* tests/tty/tty.sh: Test for this issue.  This should fix Bug#78244.
2025-06-20 12:15:27 -07:00
Pádraig Brady
037b931061 doc: make command synopsis more consistent
* doc/coreutils.texi: Use @dots{} after [OPTION],
to be consistent with man pages.
* src/printenv.c (Usage): Remove unneeded "...".
* src/timeout.c (Usage): Add needed "...",
and also remove redundant [OPTION] only form.
* src/chroot.c (Usage): Likewise.
Fixes https://bugs.gnu.org/78628
2025-06-03 23:11:44 +01:00
Paul Eggert
f1df3e703f doc: mention workaround for combining hex floats with suffixes
* doc/coreutils.texi (hexDuration): Mention the p style exponent trick.
2025-04-07 18:40:29 +01:00
Pádraig Brady
65b694257f doc: mention the edge case of hex durations with 'd' suffix
* doc/coreutils.texi (sleep invocation): Mention that suffixes are
best avoided with hex arguments.
(timeout invocation): Likewise.
* tests/misc/sleep.sh: Ensure 'd' is not interpreted as "day".
2025-04-06 00:07:37 +01:00
Collin Funk
43873a660d maint: ensure that new "make syntax-check"-run sc_codespell passes
* cfg.mk (codespell_ignore_words_list): Ignore false-positives.
(exclude_file_name_regexp--sc_codespell): Skip some file names.
* doc/coreutils.texi (mktemp invocation): Use "alphanumeric" which is
consistent with the rest of the documentation.
* src/expand-common.c: Fix typo.
* src/ls.c: Likewise.
* tests/split/l-chunk-root.sh: Likewise.
2025-04-04 21:14:29 +01:00
G. Branden Robinson
3189c08cb7 doc: fix superscript in Texinfo manual's math
The numeral "3" in the exponent was set at full size on the baseline.
2025-01-18 23:46:52 -08:00
Pádraig Brady
b58e321c8d ls: suppress "Permission denied" errors on NFS
NFS (on Linux 6.12 at least) was seen to return EACCES
from listxattr() for files without read access.
We started using listxattr() in coreutils 9.4.

* src/ls.c (gobble_file): Map EACCES from file_has_aclinfo()
to '?', rather than displaying the error.
* doc/coreutils.texi (ls invocation): Document the '?' flag.
* NEWS: Mention the bug fix.
Addresses https://bugs.gnu.org/74692
2025-01-10 14:46:40 +00:00
Pádraig Brady
5572896137 doc: clarify mv -f operation in texinfo
* doc/coreutils.texi (mv invocation): Be less ambiguous,
in that -f is significant for any replacement operation
on the destination, not just unlinking.
2025-01-06 13:30:27 +00:00
Pádraig Brady
28b176085f maint: update all copyright year number ranges
Update to latest gnulib with new copyright year.
Run "make update-copyright" and then...

* gnulib: Update included in this commit as copyright years
are the only change from the previous gnulib commit.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2025-01-01 09:33:08 +00:00
Paul Eggert
a0c3e5648b date: improve doc for ambiguous formats
Problem reported by Tim Connors <https://bugs.gnu.org/75208>.
* doc/coreutils.texi (Date conversion specifiers):
* src/date.c (usage):
Warn about ambiguous formats like %D.
2024-12-30 11:53:17 -08:00
Pádraig Brady
7e5b6b6f07 kill: with -l,-t list signal 0
The 0 (EXIT) signal is valid as input
(and useful to determine existence of a pid),
so list it along with other signals.

* doc/coreutils.texi (signal specifications): Document 0, "EXIT".
* src/kill.c (list_signals): Start loops at 0, not 1.
* tests/misc/kill.sh: Add a test case.
* NEWS: Mention the change in behavior.
2024-12-23 11:49:10 +00:00
Pádraig Brady
a94929715c cksum: add support for --algorithm=crc32b
$ echo -n '123456789' | cksum --raw -a crc32b | basenc --base16
  CBF43926

* bootstrap.conf: Explicitly depend on the crc module.
* doc/coreutils.texi (cksum): Add "crc32b" as an argument to -a.
* src/cksum.c (crc32b_sum_stream): A new function similar to
crc_sum_stream, but which does not include the length in
the CRC calculation.
* src/cksum.h: Add crc32b_sum_stream prototype.
* src/digest.c: Add "crc32b" as an argument to -a.
* tests/cksum/cksum.sh: Refactor to test both crc and crc32b.
* tests/cksum/cksum-a.sh: Add "crc32b" case.
* tests/cksum/cksum-base64.pl: Likewise.
* tests/misc/read-errors.sh: Likewise.
* NEWS: Mention the new feature.
2024-11-02 19:57:35 +00:00
Collin Funk
ee231019e1 test: add string operators added by POSIX 2024
* src/test.c (binop): Recognize the ">" and "<" operators.
(three_arguments): Likewise.
(binary_operator): Implement the "<" and ">" operators.
(usage): Add operators to --help output.
* tests/test/test.pl (@Tests): Add functionality tests.
* doc/coreutils.texi (test invocation, String tests): Document new
operators.
* NEWS: Mention the new feature.
2024-11-02 14:03:49 +00:00
Collin Funk
0c670beed9 stty: adjust --help to match POSIX 2024
* src/stty.c (usage): Mark cols, rows, and size as standardized by
POSIX.
* doc/coreutils.texi (Special): Likewise.
2024-11-01 12:49:50 +00:00
Pádraig Brady
f4fbc1a9f9 timeout: add -f and -p short options as per POSIX 2024
* src/timeout.c: Support -f and -p short options, corresponding to
--foreground and --preserve-status respectively.  This adds
compatability with POSIX 2024 and OpenBSD.
(usage): Separate translations, and reorder the option descriptions.
* doc/coreutils.texi (timeout invocation): Adjust accordingly,
and also reorder the option descriptions alphabetically.
* tests/timeout/timeout.sh: Also test short option variants.
2024-10-30 12:49:26 +00:00
Lukáš Zaoral
2606f5a043 doc: ls: fix regression in -k description
The description of -k regressed in coreutils 9.0

* doc/coreutils.texi (ls invocation): Fix incomplete paragraph
describing -k introduced by a mistake in commit v8.32-180-g1625916a1.
2024-10-02 22:26:59 +01:00
Pádraig Brady
5cecd703e5 printf: add indexed argument support
* src/printf.c (print_formatted): Add support for %i$ indexed args.
* tests/printf/printf-indexed.sh: Add a new file of test cases.
* tests/local.mk: Reference the new test file.
* doc/coreutils.texi (printf invocation): Mention how mixed
processing of indexed and sequential references are supported,
unlike the printf(2) library function.
* NEWS: Mention the new (POSIX:2024) feature.
Addresses https://bugs.gnu.org/73068
2024-09-13 17:29:02 +01:00
Pádraig Brady
84f8202287 ls: add support for explicit file name sorting
Support overriding previous sorting options
with an explicit --sort=name option.

* doc/coreutils.texi (ls invocation): Document the new option.
* src/ls.c (usage): Likewise.
(sort_args): Add the "name" entry, and sort to be consistent
with the ordering presented in --help.
* tests/ls/ls-time.sh: Add test cases.
* NEWS: Mention the new feature.
Suggested by: Tzvetelin Katchov
2024-08-11 20:40:15 +01:00
Pádraig Brady
296cc3ed96 doc: printf %b: clarify octal processing
* src/printf.c: Remove redundant comment.
State explicitly that the leading 0 is the exception
from normal escape processing.  Remove a full stop for consistency.
* doc/coreutils.texi (printf invocation): Add a reference
to C99 string escapes since these are not mentioned
in the referenced glibc printf info. Also explicitly state
the leading 0 exception.  Also use NNN rather than OOO
to be consistent with the --help documentation.
Also remove and extraneous '\' and fix grammar in the info
regarding the ninth bit.
Addresses https://bugs.gnu.org/72657
2024-08-11 15:11:03 +01:00
Pádraig Brady
bead5b05d0 doc: reference 'dircolors invocation' from ls --color info
* doc/coreutils.texi: Reference how to configure colors,
from the ls --color description.
2024-08-04 10:58:31 +01:00
Pádraig Brady
50e85d4812 doc: remove 'proposed' in regard to $'' descriptions
$'' is POSIX standard syntax as of POSIX.1-2024, as per:
https://www.austingroupbugs.net/view.php?id=249

* doc/coreutils.texi (quotingStyles): Remove 'proposed'.
* src/printf.c: Likewwise.
Reported at https://bugs.debian.org/1074776
2024-07-03 00:01:53 +01:00
Pádraig Brady
72588b2915 doc: document the c-maybe quoting style
* doc/coreutils.texi (ls invocation): Document the "c-maybe"
--quoting-style, which was added as an option in 2008.
Reported at https://bugs.debian.org/1074334
2024-06-26 23:17:12 +01:00
Paul Eggert
9290066de0 ls: improve sorting doc
Problem reported by Dan Jaobson (Bug#71171).
* doc/coreutils.texi: Clarify that directory entries are sorted,
not command-line arguments.
* src/ls.c (usage): Be less chatty about -U and
about --group-directories-first.
2024-05-24 08:43:32 -07:00
Pádraig Brady
adb6338bb5 doc: sort: give example for sorting on the last field
* doc/coreutils.texi (sort invocation): Give a DSU example
for sorting names which may have a variable number of fields.
Addresses https://bugs.gnu.org/70532
2024-04-23 21:29:33 +01:00