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".
* .gitignore: Add /lib/fenv.h to ignore list.
* tests/timeout/timeout-parameters.sh: Use a sleep length of 10s
to be consistent with the pattern where we use this larger time
when it does not slow down a test, but also provides protection
against a hung test, and better avoidance of false failures due
to races on very loaded systems. Also fix the setting of FAIL.
* tests/timeout/timeout-large-parameters.sh: Remove duplicated test.
Paul Eggert [Sat, 5 Apr 2025 07:58:22 +0000 (00:58 -0700)]
timeout: round timeouts up
This handles timeouts like 16777216.000000001 correctly;
formerly the subsecond part of that timeout was ignored.
* bootstrap.conf (gnulib_modules): Add fenv-rounding, signbit.
* src/local.mk (src_timeout_LDADD): Append $(FENV_ROUNDING_LIBM).
* src/timeout.c: Include fenv.h, math.h.
Don’t include xstrtod.h, as xstrtod’s checking now gets in the way.
(parse_duration): Round up when calling cl_strtod.
Check for -1e-1000. Don’t double-round 1e-9.
* tests/timeout/timeout-parameters.sh: Test for -0.1,
-1e-1000, 1e-1000.
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.
tests: fix false failure with multi-byte thousands separators
* tests/sort/sort-h-thousands-sep.sh: sv_SE defaults to UTF-8
on macOS 18, so avoid the test for multi-byte separators.
Fixes https://bugs.gnu.org/77509
Pádraig Brady [Sun, 30 Mar 2025 14:16:54 +0000 (15:16 +0100)]
ls: suppress ENOENT errors when reading ACL info
* src/ls.c (gobble_file): Indicating unknown ACL info with '?'
suffices for the edge case of a file being removed while reading,
or older cygwin when reading through dangling symlinks.
Reported by Corinna Vinschen.
Pádraig Brady [Thu, 20 Mar 2025 18:40:01 +0000 (18:40 +0000)]
ls: fix crash on systems with SELinux but without xattr support
This was seen on termux on Android with ./configure --disable-xattr
where listxattr() and getxattr() returned ENOTSUP.
Then the valid security context obtained by file_has_aclinfo()
was discounted, and problematically then freed multiple times.
Reported at https://github.com/termux/termux-packages/issues/23752
* src/ls.c (file_has_aclinfo_cache): Only discount the returned
acl info when all components are defaulted due to being unsupported.
Pádraig Brady [Sat, 15 Mar 2025 12:54:38 +0000 (12:54 +0000)]
dircolors: add vt220 as a color capable terminal
This isn't strictly historically accurate
but most practical these days, especially since
systemd uses this as its default TERM type.
See https://github.com/coreutils/coreutils/issues/96
Grisha Levit [Fri, 7 Feb 2025 01:56:46 +0000 (20:56 -0500)]
build: fix LIBCRYPTO_SONAME value with config cache
* configure.ac (LIBCRYPTO_SONAME): Store library name in cache so we
do not end up with an empty value for it when a cache file is used.
The configure variable name is changed from utils_cv_dlopen_libcrypto
to utils_cv_libcrypto_soname.
Lukáš Zaoral [Mon, 24 Feb 2025 09:36:35 +0000 (10:36 +0100)]
who: fix -m with guessed tty names
* who.c (scan_entries): Account for guessed tty names (e.g.
'sshd pts/1') from the readutmp module when using the systemd backend.
* bootstrap.conf (gnulib_modules): Add str_endswith.
* News: Mention the bug fix.
Addresses https://bugzilla.redhat.com/2343998
Paul Eggert [Wed, 19 Feb 2025 04:09:10 +0000 (20:09 -0800)]
du: update debug option setup
Current Gnulib arranges for fts debugging if GNULIB_FTS_DEBUG
is defined, so key off that rather than off DU_DEBUG.
* src/du.c (fts_debug): Remove decl, as Gnulib does this now.
(FTS_CROSS_CHECK): Remove; all uses removed.
(FTS_DEBUG) [!GNULIB_FTS_DEBUG]: Remove.
(long_options) [GNULIB_FTS_DEBUG]: Add a ---debug option.
(du_files): Call fts_cross_check only if fts_debug and GNULIB_FTS_DEBUG.
(main): Set fts_debug if GNULIB_FTS_DEBUG, not DU_DEBUG.
Paul Eggert [Wed, 19 Feb 2025 04:09:10 +0000 (20:09 -0800)]
maint: omit function defn extern
* src/chown-core.c, src/copy.c, src/cp-hash.c, src/csplit.c:
* src/expand-common.c, src/find-mount-point.c, src/force-link.c:
* src/group-list.c, src/iopoll.c, src/operand2sig.c:
* src/show-date.c, src/wc_avx2.c:
Omit unnecessary ‘extern ’ at the start of function defns.
This is less wordy, makes it a bit easier to grep for issues such
as the missing consistency checking in cksum.
Paul Eggert [Wed, 19 Feb 2025 04:09:10 +0000 (20:09 -0800)]
cksum: check API better
* src/cksum_avx2.c, src/cksum_avx512.c, src/cksum_pclmul.c:
* src/cksum_vmull.c:
Include cksum.h instead of copying its decls/includes by hand.
This is a better way to ensure consistency among defns and uses.
Paul Eggert [Wed, 19 Feb 2025 04:09:10 +0000 (20:09 -0800)]
cksum: minor crctab generation cleanups
* src/cksum.c [CRCTAB]: Include only config.h and stdio.h,
to simplify the crctab-generating code.
[!CRCTAB]: Do not include stdint.h or stdio.h, as cksum.h does it now.
(BIT, r, crc_remainder, main) [CRCTAB]: Use unsigned int, not
uint_fast32_t or uint32_t, as this is good enough for GNU where
unsigned int is guaranteed to be at least 32 bits, and this way we
needn’t worry about mismatches between %08x formats and uint_fast32_t.
(main) [CRCTAB]: Prefer more-local decls. Do not output
unnecessary directives to include stdint.h or stdio.h.
No need for ‘return EXIT_SUCCESS;’ nowadays.
* src/crctab.c: Regenerate.
Paul Eggert [Fri, 14 Feb 2025 21:10:02 +0000 (13:10 -0800)]
cat: fix plain ‘cat’ bug
* src/cat.c (main): Do not fail with plain ‘cat’ where input and
output are both /dev/tty, if the output happens to have O_APPEND set.
Problem reported by lilydjwg <https://bugs.gnu.org/76255>.
Also, don’t report an error if the seek position is at or after EOF,
even if O_APPEND is set.
Pádraig Brady [Wed, 5 Feb 2025 12:41:45 +0000 (12:41 +0000)]
doc: remove extraneous new lines in some man pages
* local.mk: Add the --loose-indent option, which results in help2man
avoiding extraneous new lines in expr.1, id.1, numfmt.1, shred.1,
tail.1, and timeout.1.
Fixes https://bugs.gnu.org/74107
Pádraig Brady [Wed, 5 Feb 2025 12:00:22 +0000 (12:00 +0000)]
doc: sync help2man to latest version
* man/help2man: sync changes to commit 8fe02612
The main change here is to Use \f(CR for monospace text
when using groff in troff mode.
Previously \f(CW was used, but that's not portable.
Paul Eggert [Mon, 3 Feb 2025 06:09:09 +0000 (22:09 -0800)]
maint: pacify ‘gcc -Wswitch-enum’
I thought of a way to pacify -Wswitch-enum without much trouble.
Either add all the enums, or if that’s too verbose use ‘switch (+E)’
to indicate to the reader that there need not be a case for
every enum value. Since this approach improves static checking,
make the change everywhere and check it with -Wswitch-enum.
* configure.ac: Compile with -Wswitch-enum if it works and
--enable-gcc-warnings. No need to remove -Wswitch-default
since Gnulib no longer adds it.
* src/chmod.c (describe_change):
* src/chown-core.c (describe_change):
* src/copy.c (copy_debug_string, copy_debug_sparse_string):
* src/df.c (decode_output_arg, get_dev):
* src/du.c (main):
* src/factor.c (print_factors):
* src/head.c (diagnose_copy_fd_failure):
* src/ls.c (time_type_to_statx, calc_req_mask)
(decode_line_length, get_funky_string, parse_ls_color)
(gobble_file, print_long_format):
* src/split.c (main):
* src/sync.c (sync_arg):
* src/tr.c (is_char_class_member):
* src/wc.c (main):
Add switch cases to pacify -Wswitch-enum.
* src/copy.c (copy_debug_string, copy_debug_sparse_string):
Add unreachable () for unreachable cases.
* src/digest.c (main):
* src/od.c (decode_one_format):
* src/tr.c (get_next, get_spec_stats):
switch (E) → switch (+E).
* src/digest.c (main):
* src/tr.c (get_next):
Omit unnecessary ‘default: break;’ that merely pacified GCC,
as the new pacification style is better.
* src/ls.c (decode_line_length):
Add default unreachable case to prevent warning that function
might not return a value.
(gobble_file): Distinguish DEREF_NEVER from unreachable cases.
Pádraig Brady [Wed, 29 Jan 2025 11:33:25 +0000 (11:33 +0000)]
doc: ls: clarify --format options
* src/ls.c (usage): Use parentheses to be less ambiguous as
to what are WORDs and equivalent short options. This is also
consistent with the description of --sort and --indicator-style.
Fixes https://bugs.gnu.org/75916
Pádraig Brady [Tue, 28 Jan 2025 18:31:48 +0000 (18:31 +0000)]
doc: support --with-packager-bug-reports
* src/system.h (emit_ancillary_info): Output
PACKAGE_PACKAGER_BUG_REPORTS if the build is configured
--with-packager-bug-reports.
Reported by Bruno Haible.
Pádraig Brady [Wed, 22 Jan 2025 17:55:25 +0000 (17:55 +0000)]
sort: drop "note" from a --debug message
* src/sort.c (key_warnings): Remove "note " from the start
of a usually informational message, as this simplifies translation.
* tests/sort/sort-debug-warn.sh": Adjust accordingly.
Fixes https://bugs.gnu.org/75763
Collin Funk [Mon, 20 Jan 2025 05:15:35 +0000 (21:15 -0800)]
maint: tests: remove duplicate uses of 'my' in Perl
* tests/env/env-S.pl (cf): Remove uses of 'my' after the variable has
been declared.
* tests/factor/factor.pl (t): Likewise.
* tests/misc/fold.pl (prog): Remove duplicate assignment.
Pádraig Brady [Mon, 20 Jan 2025 15:21:58 +0000 (15:21 +0000)]
tests: remove use of unprotected 'set'
* cfg.mk (sc_prohibit_bare_set): A new syntax check to
ensure we protect use of set with '--', so that args
beginning with '-' are not interpreted as options,
and if no args are present, all existing args are cleared.
* tests/cp/symlink-slash.sh: Add -- to unprotected use of set.
* tests/ls/ls-time.sh: Likewise.
* tests/ls/symlink-slash.sh: Likewise.
* tests/mkdir/perm.sh: Likewise.
* tests/mkdir/selinux.sh: Likewise.
* tests/mkdir/smack-no-root.sh: Likewise.
* tests/mkdir/smack-root.sh: Likewise.
* tests/mv/part-hardlink.sh: Likewise.
* tests/nice/nice.sh: Likewise.
* tests/stty/stty-row-col.sh: Likewise.
Pádraig Brady [Fri, 17 Jan 2025 17:29:34 +0000 (17:29 +0000)]
ls: fix crash with --context
* src/ls.c (main): Flag that we need to stat()
if we're going to get security context (call file_has_aclinfo_cache).
(file_has_aclinfo_cache): Be defensive and only lookup the device
for the file if the stat has been performed.
(has_capability_cache): Likewise.
* tests/ls/selinux-segfault.sh: Add a test case.
* NEWS: Mention the bug fix.
Reported by Bruno Haible.
Pádraig Brady [Wed, 15 Jan 2025 22:43:18 +0000 (22:43 +0000)]
tests: head: avoid false failure on some systems
* tests/head/head-c.sh: Pass a more similar operation
to get_min_ulimit_v_, so we get a more appropriate limit.
This was seen to be significant with CheriBSD.
Pádraig Brady [Wed, 15 Jan 2025 22:08:07 +0000 (22:08 +0000)]
yes: avoid failure on CHERI protected systems
* src/yes.c (main): Don't reuse the argv array as CHERI's
capability bounds do not allow for that, failing like:
$ yes $(seq 156) | head -n1
In-address space security exception (core dumped)
Pádraig Brady [Wed, 15 Jan 2025 16:12:49 +0000 (16:12 +0000)]
tests: avoid ERRORs with no mntent.h
* tests/df/skip-duplicates.sh: Just skip this test if we fail
to build the shared lib. This fails on Solaris 11 at least
due to no HAVE_MNTENT_H. Note HAVE_SYS_MNTENT_H does not
suffice for this wrapper code.
* tests/df/no-mtab-status.sh: Likewise.
Pádraig Brady [Wed, 15 Jan 2025 15:13:00 +0000 (15:13 +0000)]
tests: avoid slow ulimit -v behavior
* init.cfg (ulimit_supported_): skip_ if the ulimit -v
takes too long, which was seen with bash 5.2 on Solaris 11,
where fork() returned EAGAIN under memory constraints,
and bash retried for about 16 seconds.
(get_min_ulimit_v_): Break early if skipped.
* tests/misc/write-errors.sh: Be more conservative and
skip on failure to determine min ulimit.
Pádraig Brady [Tue, 14 Jan 2025 21:14:50 +0000 (21:14 +0000)]
tests: tail: avoid failure on Solaris 11
* tests/tail/tail-c.sh: On Solaris 11, tail -c 4096 /dev/urandom,
will induce an lseek(,-4096,SEEK_END) which returns -4096 without
setting errno, and a subsequent read() then gives EINVAL.
Since tailing the end of a psuedo device is an edge case,
we just verify that we don't spin reading the device forever.
Paul Eggert [Wed, 15 Jan 2025 03:44:01 +0000 (19:44 -0800)]
cksum: port to Oracle Developer Studio 12.6
* src/cksum.c (cksum_fp_t): New typedef.
(pclmul_supported, avx2_supported, avx512_supported)
(vmull_supported): Return this new type instead of bool.
All callers changed. That way, callers do not need to
refer to functions like cksum_avx512 that might not
exist on this platform. Although GCC optimizes such
references away, the C standard does not require this
optimization.
Paul Eggert [Mon, 13 Jan 2025 18:43:06 +0000 (10:43 -0800)]
ls: readdir errno fixes
* src/ls.c (print_dir): Fix bug: file_failure can set errno to
something other than EOVERFLOW but the code assumed it didn’t.
Also, omit ENOENT bug workaround with glibc 2.3 and later,
for consistency with Gnulib.
Pádraig Brady [Mon, 13 Jan 2025 16:37:06 +0000 (16:37 +0000)]
tail: fix regression in open() flags used
* src/tail.c (tail_file): Fix precedence issue introduced
in commit v9.5-231-g177fcec66 so that we pass correct flags to open().
Effectively this meant we would have dropped the O_BINARY flag
on windows, since O_RDONLY is generally 0.
Issue spotted by coverity.
Pádraig Brady [Sun, 12 Jan 2025 21:36:33 +0000 (21:36 +0000)]
all: fix program name with --enable-single-binary=shebangs
* gnulib: Pick up gnulib commit f11caad4fd which ensures
we diagnose the actual utility name, and not just "coreutils"
when in single binary mode. This adjustment is required
since gnulib commit 959152ba37 which enforced use of gnulib's
error() once verror is used, and gnulib's error() always
outputs the base name of the command, which the new gnulib
commit now keeps up to date.
Pádraig Brady [Sun, 12 Jan 2025 12:44:37 +0000 (12:44 +0000)]
tests: make misc/write-errors.sh immune to default signal disposition
* tests/misc/write-errors.sh: Reset SIGPIPE to the default (terminate)
disposition, so that the test doesn't erroneously fail due to an
ignored SIGPIPE in the test environment.
Pádraig Brady [Sat, 11 Jan 2025 20:32:20 +0000 (20:32 +0000)]
ls: fix inaccurate indication of ACLs on NFS
* gnulib: Update to latest to pick up gnulib commit 05c63bc908
which ensures accurate determination of the presence of NFSv4 ACLs.
* NEWS: Adjust accordingly.
Related to https://bugs.gnu.org/74692
Pádraig Brady [Thu, 9 Jan 2025 19:29:01 +0000 (19:29 +0000)]
csplit: avoid extraenous output files given empty input
* src/csplit.c (get_first_line_in_buffer): Don't exit here
upon empty input, rather indicate no input in the return
to let callers handle in a more consistent fashion.
* NEWS: Mention the bug fix.
* tests/csplit/csplit.sh: Add a test case.
Reported by Daniel Hofstetter.
Pádraig Brady [Wed, 8 Jan 2025 21:46:05 +0000 (21:46 +0000)]
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
Pádraig Brady [Fri, 18 Oct 2024 12:40:13 +0000 (13:40 +0100)]
tail: honor --pid with fifos
* src/tail.c (tail_file): Open files with O_NONBLOCK
if we might need async processing.
(pipe_bytes): Ignore EAGAIN read() errors.
(pipe_lines): Likewise.
* tests/tail/pid-pipe.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Reported by Berhard Voelker.
Pádraig Brady [Mon, 6 Jan 2025 15:48:02 +0000 (15:48 +0000)]
cp,mv: decouple --update from -f,-i,-n options
* src/copy.h: Change update member from bool to enum.
* src/copy.c: s/interactive == I_ALWAYS_NO/update == UPDATE_NONE_FAIL/;
s/interactive == I_ALWAYS_SKIP/update == UPDATE_NONE/;
s/update/update == UPDATE_OLDER/;
* src/install.c: Init with UPDATE_ALL, rather than false.
* src/cp.c: Likewise. Simply parse -f,-i,-n to x.interactive,
and parse --update to x.update.
* src/mv.c: Likewise.
* tests/cp/cp-i.sh: Add a test case where -n --update -i
honors the --update option, which would previously have been
ignored due to the preceding -n.
Pádraig Brady [Sun, 12 May 2024 11:21:19 +0000 (12:21 +0100)]
cp,mv: ensure -i,f are not overridden by -u
Since coreutils 9.3 we had --update={all,older} override -i.
In coreutils 9.5 this was expanded to -u
(to make it consistent with --update=older).
This patch reinstates things so that -i combines with -u instead.
I.e. have -i be protective, rather than selective (like -u).
The -f option of mv is similarly adjusted in this patch,
so now --update does not override any of -f,-i,-n.
* NEWS: Mention the bug fix.
* src/cp.c (main): Don't have -u disable prompting.
* src/mv.c (main): Likewise.
* tests/cp/cp-i.sh: Add a test case for -i.
* tests/mv/update.sh: Likewise.
* tests/mv/i-3.sh. Add a test case for -f.
Fixes https://bugs.gnu.org/70887
Pádraig Brady [Mon, 6 Jan 2025 13:01:47 +0000 (13:01 +0000)]
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.
Pádraig Brady [Wed, 1 Jan 2025 09:14:56 +0000 (09:14 +0000)]
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.
Pádraig Brady [Mon, 30 Dec 2024 22:48:14 +0000 (22:48 +0000)]
numfmt: don't require a suffix with --from=iec-i
* src/numfmt.c (simple_strtod_human): Only look for 'i'
after detecting a suffix.
* tests/misc/numfmt.pl: Add a test case.
* NEWS: Mention the bug fix.
Reported at https://bugs.debian.org/1091758
Paul Eggert [Mon, 30 Dec 2024 19:38:56 +0000 (11:38 -0800)]
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.
Paul Eggert [Mon, 30 Dec 2024 18:45:54 +0000 (10:45 -0800)]
maint: ISDIGIT → c_isdigit
* gl/lib/strnumcmp-in.h (ISDIGIT):
* src/system.h (ISDIGIT): Remove. All uses replaced by c_isdigit,
with appropriate inclusions of c-ctype.h. This is more regular,
and is more portable to existing (but unlikely) platforms where
INT_MAX == UINT_MAX.
Pádraig Brady [Sat, 21 Dec 2024 12:54:59 +0000 (12:54 +0000)]
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.
Pádraig Brady [Fri, 20 Dec 2024 14:28:11 +0000 (14:28 +0000)]
tail: always fail when followed files become inaccessible
* src/tail.c (tail_forever): Without --retry, exit with failure
status like we do for the inotify case (since v8.11-15-g61de57cd2).
This is also consistent with the failure exit if no file was
accessible at tail startup.
* tests/tail/follow-stdin.sh: Tweak due to earlier exit.
* tests/tail/follow-name.sh: Test with and without inotify.
* NEWS: Mention the bug fix.
Pádraig Brady [Wed, 18 Dec 2024 12:39:47 +0000 (12:39 +0000)]
cksum: update to pclmul optimized crc32b from gnulib
* bootstrap.conf: Depend on crc-x86_64 rather than crc.
* gnulib: Update to latest.
* src/cksum.c (crc32b_sum_stream): Add --debug info.
* NEWS: Mention the performance improvement.