]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
2 years agobuild: update to latest gnulib
Pádraig Brady [Mon, 27 Feb 2023 12:00:24 +0000 (12:00 +0000)] 
build: update to latest gnulib

* NEWS: Mention the fts fix to avoid the following assert
in rm on mem pressure:
  Program terminated with signal SIGSEGV, Segmentation fault.
    at ../lib/cycle-check.c:60
    assure (state->magic == CC_MAGIC);
* gnulib: Update to the latest to pick up fts commit f17d3977.

2 years agotests: avoid hang in new test
Pádraig Brady [Sun, 26 Feb 2023 18:10:41 +0000 (18:10 +0000)] 
tests: avoid hang in new test

* tests/rm/empty-inacc.sh: Ensure we're not reading from stdin
when we're relying on no prompt to proceed.  Also change the
file being tested so that a failure in one test doesn't impact
following tests causing a framework failure.

2 years agotests: avoid gdb on macOS
Pádraig Brady [Fri, 24 Feb 2023 15:40:37 +0000 (15:40 +0000)] 
tests: avoid gdb on macOS

gdb was seen to hang intermittently on macOS 12.
Also gdb requires signing on newer macOS systems:
https://sourceware.org/gdb/wiki/PermissionsDarwin
So restrict its use on macOS systems for now.

* tests/rm/r-root.sh: Skip on darwin systems.
* tests/tail-2/inotify-race.sh: Restrict the test to
inotify capable systems to avoid the hang with some gdbs.
* tests/tail-2/inotify-race.sh: Likewise.

2 years agocp,install,mv: --debug: output debug info when reflinking
Pádraig Brady [Fri, 24 Feb 2023 15:15:20 +0000 (15:15 +0000)] 
cp,install,mv: --debug: output debug info when reflinking

* src/copy.c (copy_reg): Always check whether to output debug info.
(emit_debug): Restrict output with `cp --attributes-only`.

2 years agotests: determine if SEEK_HOLE is enabled
Pádraig Brady [Thu, 23 Feb 2023 20:28:51 +0000 (20:28 +0000)] 
tests: determine if SEEK_HOLE is enabled

Upcomming gnulib changes may disable SEEK_HOLE
even if the system supports it, so dynamically
check if we've SEEK_HOLE enabled.

* init.cfg (seek_data_capable_): SEEK_DATA may be disabled in the build
if the system support is deemed insufficient, so also use `cp --debug`
to determine if it's enabled.
* tests/cp/sparse-2.sh: Adjust to a more general diagnostic.
* tests/cp/sparse-extents-2.sh: Likewise.
* tests/cp/sparse-extents.sh: Likewise.
* tests/cp/sparse-perf.sh: Likewise.

2 years agocp,install,mv: add --debug to explain how a file is copied
Pádraig Brady [Fri, 17 Feb 2023 13:46:13 +0000 (13:46 +0000)] 
cp,install,mv: add --debug to explain how a file is copied

How a file is copied is dependent on the sparseness of the file,
what file system it is on, what file system the destination is on,
the attributes of the file, and whether they're being copied or not.
Also the --reflink and --sparse options directly impact the operation.

Given it's hard to reason about the combination of all of the above,
the --debug option is useful for users to directly identify if
copy offloading, reflinking, or sparse detection are being used.

It will also be useful for tests to directly query if
these operations are supported.

The new output looks as follows:

  $ src/cp --debug src/cp file.sparse
  'src/cp' -> 'file.sparse'
  copy offload: yes, reflink: unsupported, sparse detection: no

  $ truncate -s+1M file.sparse

  $ src/cp --debug file.sparse file.sparse.cp
  'file.sparse' -> 'file.sparse.cp'
  copy offload: yes, reflink: unsupported, sparse detection: SEEK_HOLE

  $ src/cp --reflink=never --debug file.sparse file.sparse.cp
  'file.sparse' -> 'file.sparse.cp'
  copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE

* doc/coreutils.texi (cp invocation): Describe the --debug option.
(mv invocation): Likewise.
(install invocation): Likewise.
* src/copy.h: Add a new DEBUG member to cp_options, to control
whether to output debug info or not.
* src/copy.c (copy_debug): A new global structure to
unconditionally store debug into from the last copy_reg operations.
(copy_debug_string, emit_debug): New functions to print debug info.
* src/cp.c: if ("--debug") x->debug=true;
* src/install.c: Likewise.
* src/mv.c: Likewise.
* tests/cp/debug.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Thu, 23 Feb 2023 19:18:32 +0000 (11:18 -0800)] 
build: update gnulib submodule to latest

2 years agodoc: chgrp,chmod,chown: state --reference always dereferences
Pádraig Brady [Thu, 23 Feb 2023 15:22:14 +0000 (15:22 +0000)] 
doc: chgrp,chmod,chown: state --reference always dereferences

* src/chgrp.c (usage): State that --reference always
dereferences symbolic links.
* src/chmod.c (usage): Likewise.
* src/chown.c (usage): Likewise.
Fixes https://bugs.gnu.org/61720

2 years agodoc: fix some spelling mistakes
ChuanGang Jiang [Tue, 21 Feb 2023 14:18:52 +0000 (14:18 +0000)] 
doc: fix some spelling mistakes

* doc/coreutils.texi: s/functionalty/functionality/,
   s/sychronize/synchronize/, s/millsecond/millisecond/
   s/paramter/parameters/
* init.cfg: s/parmeters/parameters/
* scripts/build-older-versions/README.older-versions: s/vesion/version/
* tests/misc/env-S-script.sh: s/paramaters/parameters/
Fixes https://bugs.gnu.org/61681

2 years agomaint: avoid -Wmaybe-uninitialized warning from GCC13
Pádraig Brady [Tue, 21 Feb 2023 16:14:44 +0000 (16:14 +0000)] 
maint: avoid -Wmaybe-uninitialized warning from GCC13

* src/copy.c (infer_scantype): Always set scan_inference.ext_start,
as per commit 6c03e8fb which was inadvertently reverted by d374d32c.

2 years agotests: initialize a variable
Jim Meyering [Mon, 20 Feb 2023 16:37:18 +0000 (08:37 -0800)] 
tests: initialize a variable

* tests/rm/interactive-once.sh (write_prot_msg1): Initialize it,
so an envvar setting cannot perturb the test.

2 years agorm: --dir (-d): fix bugs in handling of empty, inaccessible directories
Jim Meyering [Mon, 6 Feb 2023 17:01:55 +0000 (09:01 -0800)] 
rm: --dir (-d): fix bugs in handling of empty, inaccessible directories

* src/remove.c (prompt, rm_fts): In the dir-handling code of both of
these functions, relax a "get_dir_status (...) == DS_EMPTY" condition
to instead test only "get_dir_status (...) != 0", enabling flow control
to reach the prompt function also for unreadable directories. However,
that function itself also needed special handling for this case:
(prompt): Handle empty, inaccessible directories properly,
deleting them with -d (--dir), and prompting about whether to delete
with -i (--interactive).
* tests/rm/empty-inacc.sh: Add tests for the new code.
Reported by наб <nabijaczleweli@nabijaczleweli.xyz> in
bugs.debian.org/1015273
* NEWS (Bug fixes): Mention this.

2 years agotests: port chmod/setgid.sh to macOS 12
Paul Eggert [Sat, 18 Feb 2023 21:29:41 +0000 (13:29 -0800)] 
tests: port chmod/setgid.sh to macOS 12

* tests/chmod/setgid.sh: Try all the groups you’re a member of,
in case id -g returns 4294967295 (nogroup) which is special
and does not let you chgrp a file to it.

2 years agotests: port better to macOS group numbers
Paul Eggert [Sat, 18 Feb 2023 21:27:45 +0000 (13:27 -0800)] 
tests: port better to macOS group numbers

* init.cfg (groups): Port better to macOS 12, where
group 4294967295 (nogroup) is special: you can be a member
without being able to chgrp files to the group.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 18 Feb 2023 20:02:11 +0000 (12:02 -0800)] 
build: update gnulib submodule to latest

2 years agocp: fclonefileat security fix + CLONE_ACL + fixups
Paul Eggert [Fri, 10 Feb 2023 21:34:54 +0000 (13:34 -0800)] 
cp: fclonefileat security fix + CLONE_ACL + fixups

* src/copy.c: Some changes if HAVE_FCLONEFILEAT && !USE_XATTR.
(fd_has_acl): New function.
(CLONE_ACL): Default to 0.
(copy_reg): Use CLONE_NOFOLLOW to avoid races like CVE-2021-30995
<https://www.trendmicro.com/en_us/research/22/a/
analyzing-an-old-bug-and-discovering-cve-2021-30995-.html>.
Use CLONE_ACL if available and working, falling back to cloning
without it if it fails due to EINVAL.
If the only problem with fclonefileat is that it would create the
file with the wrong timestamp, or with too few permissions,
do that but fix the timestamp and permissions afterwards,
rather than falling back on a traditional copy.

2 years agomaint: fix some typos in comments
ChuanGang Jiang [Fri, 10 Feb 2023 15:41:33 +0000 (15:41 +0000)] 
maint: fix some typos in comments

* NEWS: s/commmand/command/
* cfg.mk: Adjust old_NEWS_hash with `make update-NEWS-hash`.
* src/expand-common.c: s/specifed/specified/
* src/pr.c: s/e.g/e.g./
* tests/misc/comm.pl: s/ouput/output/
Fixes https://bugs.gnu.org/61405

2 years agocp: simplify infer_scantype
Paul Eggert [Fri, 10 Feb 2023 03:10:47 +0000 (19:10 -0800)] 
cp: simplify infer_scantype

* src/copy.c (infer_scantype): Do not set *SCAN_INFERENCE
when returning a value other than LSEEK_SCANTYPE.
This is just minor refactoring; it simplifies the code a bit.
Callers are uneffected.

doc: document --preserve=mode better

2 years agotail: improve --follow=name with single non regular files
Pádraig Brady [Wed, 1 Feb 2023 20:41:31 +0000 (20:41 +0000)] 
tail: improve --follow=name with single non regular files

* src/tail (tail_forever): Attempt to read() from non blocking
single non regular file, which shouldn't block, but also
read data even when the mtime doesn't change.
* NEWS: Mention the improvement.
* THANKS.in: Thanks for detailed testing.

2 years agotail: fix support for -F with non seekable files
Pádraig Brady [Mon, 30 Jan 2023 21:44:10 +0000 (21:44 +0000)] 
tail: fix support for -F with non seekable files

This was seen to be an issue when following a
symlink that was being updated to point to
different underlying devices.

* src/tail.c (recheck): Guard the lseek() call to only
be performed for regular files.
* NEWS: Mention the bug fix.

2 years agocksum: add --raw option to output a binary digest
Pádraig Brady [Fri, 3 Feb 2023 16:34:18 +0000 (16:34 +0000)] 
cksum: add --raw option to output a binary digest

--raw output is the most composable format, and also is a
robust way to discard the file name without parsing (escaped) output.

Examples:

  $ cksum --raw -a crc "$afile" | basenc --base16
  4ACFC4F0

  $ cksum --raw -a crc "$afile" | basenc --base2msbf
  01001010110011111100010011110000

  $ cksum --raw -a sha256 "$bfile" | basenc --base32
  AAAAAAAADHLGRHAILLQWLAY6SNH7OY5OI2RKNQLSWPY3MCUM4JXQ====

* doc/coreutils.texi (cksum invocation): Describe the new feature.
* src/digest.c (output_file): Inspect the new RAW_DIGEST global,
and output the bytes directly if set.
* src/cksum.c (output_crc): Likewise.
* src/sum.c (output_bsd, output_sysv): Likewise.
* tests/misc/cksum-raw.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.

2 years agobuild: uptime: avoid issues on systems without utmp.h
Pádraig Brady [Sun, 5 Feb 2023 13:51:20 +0000 (13:51 +0000)] 
build: uptime: avoid issues on systems without utmp.h

* src/uptime.c (print_uptime): Following gnulib commit 9041103
HAVE_UTMP_H will always be defined.  Therefore key on whether
the utmp.ut_type member is present.
* boottime.m4 (GNULIB_BOOT_TIME): Assume utmp.h is present.

2 years agomaint: use alignasof, not stdalign
Paul Eggert [Sat, 4 Feb 2023 22:42:21 +0000 (14:42 -0800)] 
maint: use alignasof, not stdalign

* .gitignore: Update accordingly.
* bootstrap.conf (gnulib_modules): Replace obsolescent stdalign
with alignasof.
* gl/modules/randread (Depends-on): Depend on alignasof, not stdalign.

2 years agomaint: prefer https: to git:
Paul Eggert [Sat, 4 Feb 2023 19:53:50 +0000 (11:53 -0800)] 
maint: prefer https: to git:

The idea is to defend against some adversary-in-the-middle attacks.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 4 Feb 2023 18:16:06 +0000 (10:16 -0800)] 
build: update gnulib submodule to latest

2 years agomaint: avoid line length syntax check failure
Pádraig Brady [Fri, 3 Feb 2023 16:42:01 +0000 (16:42 +0000)] 
maint: avoid line length syntax check failure

* src/cp.c: Adjust source line to be <= 80 chars.

2 years agotests: fix exit status check in cp -u test
Pádraig Brady [Fri, 3 Feb 2023 16:37:26 +0000 (16:37 +0000)] 
tests: fix exit status check in cp -u test

* tests/cp/preserve-link.sh: This should have been part
of commit v9.1-134-g01503ce73.

2 years agocksum: accept new option: --base64 (-b)
Jim Meyering [Sat, 21 Jan 2023 02:09:26 +0000 (18:09 -0800)] 
cksum: accept new option: --base64 (-b)

* src/digest.c [HASH_ALGO_CKSUM]: Include "base64.h"
[HASH_ALGO_CKSUM] (base64_digest): New global.
[HASH_ALGO_CKSUM] (enum BASE64_DIGEST_OPTION): New enum.
[HASH_ALGO_CKSUM] (long_options): Add "base64".
(valid_digits): Rename from hex_digits, now taking an input length argument.
Adjust callers.
(bsd_split_3): Rename arg from hex_digits to digest.
Add new *d_len parameter for length of extracted digest.
Move "i" declaration down to first use.
(split_3): Rename arg from hex_digits to digest.
Add new *d_len parameter for length of extracted digest.
Instead of relying on "known" length of digest to find the following
must-be-whitespace byte, search for the first whitespace byte.
[HASH_ALGO_CKSUM] (output_file): Handle base64_digest.
[HASH_ALGO_CKSUM] (main): Set base64_digest.
[HASH_ALGO_CKSUM] (b64_equal): New function.
(hex_equal): New function, factored out of digest_check.
(digest_check) Factored part into b64_equal and hex_equal.
Rename local hex_digest to digest.
* tests/misc/cksum-base64.pl: Add tests.
* tests/local.mk (all_tests): Add to the list.
* cfg.mk (_cksum): Define.
(exclude_file_name_regexp--sc_prohibit_test_backticks): Exempt new test.
(exclude_file_name_regexp--sc_long_lines): Likewise.
* doc/coreutils.texi (cksum invocation): Document it.
(md5sum invocation) [--check]: Mention digest encoding auto-detect.
* NEWS (New Features): Mention this.

2 years agodoc: document --preserve=mode better
Paul Eggert [Tue, 31 Jan 2023 21:52:39 +0000 (13:52 -0800)] 
doc: document --preserve=mode better

* doc/coreutils.texi: Spruce up cp --preserve=mode doc.

2 years agocp: improve --preserve usage doc
Paul Eggert [Tue, 31 Jan 2023 18:39:43 +0000 (10:39 -0800)] 
cp: improve --preserve usage doc

* src/cp.c (usage): Improve description of --preserve.

2 years agocp,mv: skipping due to -u is success, not failure
Paul Eggert [Tue, 31 Jan 2023 17:24:43 +0000 (09:24 -0800)] 
cp,mv: skipping due to -u is success, not failure

This reverts the previous change, so that when a file
is skipped due to -u, this is not considered a failure.
* doc/coreutils.texi: Document this.
* src/copy.c (copy_internal): If --update says to skip,
treat this as success instead of failure.
* tests/mv/update.sh, tests/cp/slink-2-slink.sh:
Revert previous change, to match reverted behavior.

2 years agocp,ln,mv: when skipping exit with nonzero status
Paul Eggert [Tue, 31 Jan 2023 16:46:21 +0000 (08:46 -0800)] 
cp,ln,mv: when skipping exit with nonzero status

* NEWS, doc/coreutils.texi: Document this.
* src/copy.c (copy_internal):
* src/ln.c (do_link): Return false when skipping action due to
--interactive or --no-clobber.
* tests/cp/cp-i.sh, tests/cp/preserve-link.sh:
* tests/cp/slink-2-slink.sh, tests/mv/i-1.pl, tests/mv/i-5.sh:
* tests/mv/mv-n.sh, tests/mv/update.sh:
Adjust expectations of exit status to match revised behavior.

2 years agotests: cksum: fix test to include more cases
Pádraig Brady [Mon, 30 Jan 2023 19:29:38 +0000 (19:29 +0000)] 
tests: cksum: fix test to include more cases

* tests/misc/cksum-c.sh: Fix typo which caused part
of the test data to be ignored.

2 years agodigest.c: remove a duplicate variable
Jim Meyering [Mon, 30 Jan 2023 16:33:10 +0000 (08:33 -0800)] 
digest.c: remove a duplicate variable

* src/digest.c (digest_check): Locals n_misformatted_lines and
n_improperly_formatted_lines were declared and set/incremented
identically. Remove declaration of the latter. Use the other instead.

2 years agobuild: avoid spurious failures due to lack of EGREP definition
Jim Meyering [Sat, 21 Jan 2023 01:54:28 +0000 (17:54 -0800)] 
build: avoid spurious failures due to lack of EGREP definition

* configure.ac: Use AC_PROG_EGREP, since many doc and test rules
use $EGREP.
* cfg.mk (sc_tests_list_consistency): Use grep -E, not $(EGREP) here.

2 years agotests: ensure we fail if mv --no-copy crashes
Pádraig Brady [Fri, 27 Jan 2023 19:46:52 +0000 (19:46 +0000)] 
tests: ensure we fail if mv --no-copy crashes

* tests/mv/no-copy.sh: Honor `make syntax` check
and use the `returns_ 1 ...` pattern.

2 years agomv: new option --no-copy
Paul Eggert [Fri, 27 Jan 2023 18:59:13 +0000 (10:59 -0800)] 
mv: new option --no-copy

Wishlist item from Mike Frysinger (Bug#61050).
* src/copy.c (copy_internal):
Do not fall back on copying if x->no_copy.
* src/copy.h (struct cp_options): New member no_copy.
* src/mv.c (NO_COPY_OPTION): New constant.
(long_options, usage, main): Support --no-copy.
* tests/mv/no-copy.sh: New test.
* tests/local.mk (all_tests): Add it.

2 years agomaint: add lib/error.h to .gitignore
Pádraig Brady [Tue, 17 Jan 2023 22:38:40 +0000 (22:38 +0000)] 
maint: add lib/error.h to .gitignore

* .gitignore: Add /lib/error.h as suggested by sc_gitignore_missing
as a result of gnulib change 2886cca8.

2 years agodoc: csplit: more accurate --elide-empty-files help
Pádraig Brady [Tue, 17 Jan 2023 21:31:31 +0000 (21:31 +0000)] 
doc: csplit: more accurate --elide-empty-files help

* src/csplit.c (usage): Use "suppress" rather than "remove"
when describing -z so it's more apparent that the effect
is a particular numbered file is not created, rather than
being removed later.  I.e., don't suggest -z may induce
gaps in file numbering.
Reported at https://bugs.debian.org/1029103

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 14 Jan 2023 01:33:58 +0000 (17:33 -0800)] 
build: update gnulib submodule to latest

* m4/xattr.m4: Remove.  This file is now autogenerated by 'bootstrap',
since it's now in Gnulib.  (I did this part by hand.)

2 years agocopy: copy_file_range: handle ENOENT for CIFS
Pádraig Brady [Sat, 7 Jan 2023 16:10:01 +0000 (16:10 +0000)] 
copy: copy_file_range: handle ENOENT for CIFS

* src/copy.c (sparse_copy): Fallback to standard copy upon ENOENT,
which was seen intermittently across CIFS file systems.
* NEWS: Mention the bug fix, though qualify it as an "issue"
rather than a bug, as coreutils is likely only highlighting
a CIFS bug in this case.
Fixes https://bugs.gnu.org/60455

2 years agomaint: update .gitignore
Paul Eggert [Sat, 7 Jan 2023 23:50:27 +0000 (15:50 -0800)] 
maint: update .gitignore

* .gitignore: Add confdefs*, conftest* (temporaries built
by ‘configure’).

2 years agomaint: adjust to Gnulib macro renaming
Paul Eggert [Sat, 7 Jan 2023 23:49:48 +0000 (15:49 -0800)] 
maint: adjust to Gnulib macro renaming

* src/local.mk (LDADD, copy_ldadd, remove_ldadd, src_sort_LDADD)
(src_test_LDADD, copy_ldadd, src_date_LDADD, src_ginstall_LDADD)
(src_ln_LDADD, src_ls_LDADD, src_mktemp_LDADD, src_pr_LDADD)
(src_tac_LDADD, src_touch_LDADD, src_dd_LDADD, src_sleep_LDADD)
(src_sort_LDADD, src_tail_LDADD, src_sort_LDADD, LDADD):
Adjust to recent Gnulib changes.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 7 Jan 2023 23:34:31 +0000 (15:34 -0800)] 
build: update gnulib submodule to latest

2 years agocopy: immediately fail with transient reflink errors
Pádraig Brady [Mon, 2 Jan 2023 13:07:41 +0000 (13:07 +0000)] 
copy: immediately fail with transient reflink errors

* src/copy.c (handle_clone_fail): A new function refactored
from copy_reg() to handle failures from FICLONE or fclonefileat().
Fail with all errors from FICLONE, unless they're from the set
indicating the file system or file do not support the clone operation.
Also fail with errors from fclonefileat() (dest_dest < 0)
if they're from the set indicating a transient failure for the file.
(copy_ref): Call handle_clone_fail() after fclonefileat() and FICLONE.
(sparse_copy): Call the refactored is_CLONENOTSUP()
which is now also used by the new handle_clone_fail() function.
* NEWS: Mention the bug fix.  Also mention explicitly
the older --reflink=auto default change to aid searching.
* cfg.mk: Adjust old_NEWS_hash with `make update-NEWS-hash`.
Fixes https://bugs.gnu.org/60489

2 years agoall: further adjustments for new Ronna, Quetta SI prefixes
Pádraig Brady [Fri, 6 Jan 2023 13:13:54 +0000 (13:13 +0000)] 
all: further adjustments for new Ronna, Quetta SI prefixes

* src/dd.c (parse_integer): Support Q,R suffixes.
* src/od.c (main): Likewise.
* src/split.c (main): Likewise.
* src/stdbuf.c (parse_size): Likewise.
* src/truncate.c (main): Likewise.
* src/sort.c (specify_size_size): Likewise.
Also line length syntax check fix.
* tests/misc/numfmt.pl: Adust top end large number checks
to the new largest values.
* doc/coreutils.texi (numfmt invocation): Add a numfmt example.
* NEWS: Tweak to aid searchability.

2 years agonumfmt: add support for new SI prefixes
Paul Eggert [Thu, 5 Jan 2023 19:42:51 +0000 (11:42 -0800)] 
numfmt: add support for new SI prefixes

* src/dd, src/head.c, src/od.c, src/sort.c, src/stdbuf.c, src/tail.c:
(usage):
* src/system.h (emit_size_note):
Mention new SI prefixes.
* src/du.c (main):
* src/head.c (head_file):
* src/numfmt.c (suffix_power, suffix_power_char, prepare_padded_number):
* src/shred.c (main):
* src/sort.c (unit_order):
* src/tail.c (parse_options):
Support new SI prefixes.
* src/numfmt.c (MAX_ACCEPTABLE_DIGITS): Increase to 33.
(zero_and_valid_suffixes, valid_suffixes): New constants,
with new SI prefixes.
(valid_suffix, unit_to_umax): Use them.
(prepare_padded_number): Diagnose "999Q" instead of "999Y".
* tests/misc/numfmt.pl, tests/misc/sort.pl:
Adjust tests to match new max.

2 years agols: adjust to Gnulib renaming
Paul Eggert [Thu, 5 Jan 2023 19:42:51 +0000 (11:42 -0800)] 
ls: adjust to Gnulib renaming

* src/local.mk (src_ls_LDADD): In Gnulib,
LIB_HAS_ACL was renamed to FILE_HAS_ACL_LIB.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Thu, 5 Jan 2023 19:42:51 +0000 (11:42 -0800)] 
build: update gnulib submodule to latest

2 years agomaint: avoid grep warning in sc_prohibit_test_minus_ao
Bernhard Voelker [Tue, 3 Jan 2023 08:11:28 +0000 (09:11 +0100)] 
maint: avoid grep warning in sc_prohibit_test_minus_ao

Newer grep(1) complains:
  $ make sc_prohibit_test_minus_ao
  /usr/bin/grep: warning: * at start of expression
  prohibit_test_minus_ao

* cfg.mk (exclude_file_name_regexp--sc_prohibit_test_minus_ao): Fix
expression inroduced in v8.24-120-g3205bb178, and narrow down the file
pattern to the 'doc/' directory.

2 years agodoc: copy: mention the reinstated I/O size constraints
Pádraig Brady [Mon, 2 Jan 2023 23:16:07 +0000 (23:16 +0000)] 
doc: copy: mention the reinstated I/O size constraints

* NEWS: Mention the change in behavior re block size multiples
to support unusual devices with this constraint.
* src/copy.c (copy_reg): Likewise.

2 years agocopy: fix possible over allocation for regular files
Paul Eggert [Sun, 20 Nov 2022 03:04:36 +0000 (19:04 -0800)] 
copy: fix possible over allocation for regular files

* bootstrap.conf (gnulib_modules): Add count-leading-zeros,
which was already an indirect dependency, since ioblksize.h
now uses it directly.
* src/ioblksize.h: Include count-leading-zeros.h.
(io_blksize): Treat impossible blocksizes as IO_BUFSIZE.
When growing a blocksize to IO_BUFSIZE, keep it a multiple of the
stated blocksize.  Work around the ZFS performance bug.
* NEWS: Mention the bug fix.
Problem reported by Korn Andras at https://bugs.gnu.org/59382

2 years agomaint: update all copyright year number ranges
Pádraig Brady [Sun, 1 Jan 2023 14:50:15 +0000 (14:50 +0000)] 
maint: update all copyright year number ranges

Update to latest gnulib with new copyright year.
Run "make update-copyright" and then...

* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Manually update copyright year,
until we fully sync with gnulib at a later stage.
* tests/sample-test: Adjust to use the single most recent year.

2 years agobuild: update gnulib submodule to latest
Pádraig Brady [Sun, 1 Jan 2023 13:39:25 +0000 (13:39 +0000)] 
build: update gnulib submodule to latest

mainly to get updated copyright year

* tests/init.sh: Sync with gnulib

2 years agostty: fix off by one column wrapping on output
Pádraig Brady [Sat, 31 Dec 2022 17:03:39 +0000 (17:03 +0000)] 
stty: fix off by one column wrapping on output

* src/stty.c (wrapf): Adjust the comparison by 1,
to account for the space we're adding.
* tests/misc/stty.sh: Add a test case.
* NEWS: Mention the fix.
Reported in https://bugs.debian.org/1027442

2 years agocopy: attempt copy offload with sparse files by default
Pádraig Brady [Fri, 30 Dec 2022 19:34:27 +0000 (19:34 +0000)] 
copy: attempt copy offload with sparse files by default

This was seen to vastly improve performance
on NFS 4.2 systems by allowing server side copies,
with partially sparse files (avidemux generated mp4 files).

* src/copy.c (lseek_copy): Also set hole_size to 0,
i.e. enable copy_file_range(), with --sparse=auto (the default),
to enable copy offload in this case, as we've strong signal
from SEEK_DATA that we're operating on actual data and not holes here.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/60416

2 years agowc: fix regression determining file size
Pádraig Brady [Wed, 28 Dec 2022 14:04:19 +0000 (14:04 +0000)] 
wc: fix regression determining file size

* src/wc.c (wc): Use off_t rather than size_t
when calculating where to seek to, so that
we don't seek to a too low offset on systems
where size_t < off_t, which would result in
many read() calls to determine the file size.
* tests/misc/wc-proc.sh: Add a test case
sufficient for 32 bit systems at least.
* NEWS: Mention the bug fix.
Reported at https://bugs.debian.org/1027101

2 years agomaint: avoid recent syntax check failure
Pádraig Brady [Thu, 29 Dec 2022 14:14:11 +0000 (14:14 +0000)] 
maint: avoid recent syntax check failure

* tests/cp/proc-short-read.sh: Adjust so shorter lines.

2 years agodoc: improve doc of du with CoW etc
Paul Eggert [Mon, 26 Dec 2022 18:34:48 +0000 (10:34 -0800)] 
doc: improve doc of du with CoW etc

Problem reported by Krzysztof Żelechowski (Bug#60335).
* doc/coreutils.texi (du invocation): Reword.

2 years agodoc: improve du --threshold wording
Paul Eggert [Mon, 26 Dec 2022 17:39:16 +0000 (09:39 -0800)] 
doc: improve du --threshold wording

* doc/coreutils.texi (du invocation): Reword.

2 years agotests: accommodate bogomips capitalizations
Paul Eggert [Mon, 26 Dec 2022 17:01:37 +0000 (09:01 -0800)] 
tests: accommodate bogomips capitalizations

* tests/cp/proc-short-read.sh: Kernel on ARMv7 Processor rev 3 (v7l)
spells it "BogoMIPS", so allow any capitalization.  Patch from
Zach van Rijn in <https://bugs.gnu.org/60339>.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 6 Dec 2022 18:45:06 +0000 (10:45 -0800)] 
build: update gnulib submodule to latest

2 years agodoc: timezone -> time zone
Paul Eggert [Tue, 6 Dec 2022 18:40:28 +0000 (10:40 -0800)] 
doc: timezone -> time zone

2 years agodoc: improve date -I doc
Paul Eggert [Tue, 6 Dec 2022 02:42:19 +0000 (18:42 -0800)] 
doc: improve date -I doc

Suggested by Marc Chantreux (bug#59827).
* doc/coreutils.texi (Options for date):
Give formats for -I, like we already do for --rfc-3339.

2 years agobuild: fix missing inclusion of poll.h on macOS
Dennis Williamson [Mon, 5 Dec 2022 14:30:35 +0000 (14:30 +0000)] 
build: fix missing inclusion of poll.h on macOS

* src/tail.c: Following on from commit v9.1-55-g324c188cf
also include poll.h for __APPLE__, which was seen to be required
on macOS 11.6

2 years agodoc: tee: make -p decription more complete
Pádraig Brady [Mon, 28 Nov 2022 22:39:19 +0000 (22:39 +0000)] 
doc: tee: make -p decription more complete

* doc/coreutils.texi (tee invocation): Give a more
cohesive description of the -p option, and how
it differs from the default operation.

2 years agoscripts: commit-msg: recognize Git cut_lines
Arsen Arsenović [Sun, 20 Nov 2022 11:25:12 +0000 (12:25 +0100)] 
scripts: commit-msg: recognize Git cut_lines

This prevents spurious failures from happening when someone sets
commit.verbose or passes -v to commit.

2 years agodoc: more dash fixes
Paul Eggert [Tue, 15 Nov 2022 18:55:23 +0000 (10:55 -0800)] 
doc: more dash fixes

* doc/coreutils.texi, doc/sort-version.texi: Prefer on "x -- y" to
"x---y" in prose, as the result is more readable in Emacs.
Fix some instances of unescaped ‘-’ that should be minus, not
hyphen. Fix some other instances that should be en dash.  No
spaces around en dash when it’s a range.

2 years agomaint: fix cfg.mk comment
Paul Eggert [Tue, 15 Nov 2022 18:51:47 +0000 (10:51 -0800)] 
maint: fix cfg.mk comment

* cfg.mk (sc_texi_long_option_escaped): Fix comment.

2 years agotests: make SIGPIPE trap checking more robust
Pádraig Brady [Tue, 15 Nov 2022 13:57:47 +0000 (13:57 +0000)] 
tests: make SIGPIPE trap checking more robust

* init.cfg (trap_sigpipe_or_skip_): A subshell with ignored SIGPIPE
was seen to not terminate, on Solaris 11 at least.
So protect with a timeout(1).

2 years agomaint: avoid new grep -q syntax-check failures
Pádraig Brady [Tue, 15 Nov 2022 13:27:57 +0000 (13:27 +0000)] 
maint: avoid new grep -q syntax-check failures

* cfg.mk: Exclude NEWS from the check.
* init.cfg: s/grep -q/grep >/dev/null/.
* tests/ls/hyperlink.sh: Likewise.
* tests/ls/symlink-quote.sh: Likewise.

2 years agomaint: avoid misquoting of some --long-options in texi
Pádraig Brady [Tue, 15 Nov 2022 11:54:58 +0000 (11:54 +0000)] 
maint: avoid misquoting of some --long-options in texi

* cfg.mk (sc_texi_long_option_escaped): A new check to
avoid future instances of this.
* doc/coreutils.texi (Common options): Rearrange this menu
to be less repetitive in each description, and avoid long lines.
Addresses https://bugs.gnu.org/59262

2 years agodoc: fix markup
Paul Eggert [Tue, 15 Nov 2022 03:08:19 +0000 (19:08 -0800)] 
doc: fix markup

Problem reported by Antonio Diaz Diaz (bug#59262).
* doc/coreutils.texi: Use markup in menus to prevent
‘--’ from turning into an em dash, and to be more
consistent.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 15 Nov 2022 03:00:06 +0000 (19:00 -0800)] 
build: update gnulib submodule to latest

2 years agodoc: printf: make "java" encoding example more standard
Pádraig Brady [Fri, 28 Oct 2022 13:40:28 +0000 (14:40 +0100)] 
doc: printf: make "java" encoding example more standard

Note using iconv(1) rather than recode(1) is not appropriate
for this example, as the required functionality is only
available on libiconv's iconv implementation, which is
not installed on most systems.

* doc/coreutils.texi (printf invocation): Use env rather than
/usr/local/bin for the printf command.  Escape '%' so more robust.
Also use a locale that exists on modern systems.

2 years agodoc: move description of printf options to better location
Pádraig Brady [Thu, 27 Oct 2022 17:38:14 +0000 (18:38 +0100)] 
doc: move description of printf options to better location

* doc/coreutils.texi (printf invocation): Move the description
of accepted options from the middle of the unicode discussion.

2 years agoprintf: with \U, support all valid unicode points
Pádraig Brady [Thu, 27 Oct 2022 14:17:07 +0000 (15:17 +0100)] 
printf: with \U, support all valid unicode points

Previously this was restricted to the C99 universal character subset,
which restricted most values <= 0x9F, as that simplifies the C lexer.
However printf(1) doesn't need this restriction.
Note also the bash builtin printf already supports all values <= 0x9F.

* src/printf.c (main): Relax the restriction on points <= 0x9F.
* doc/coreutils.texi (printf invocation): Adjust description.
* tests/misc/printf-cov.pl: Adjust accordingly.  Add new cases.
* NEWS: Mention the change in behavior.
Reported at https://bugs.debian.org/1022857

2 years agodoc: basenc: reference from base{32,64} docs
Pádraig Brady [Wed, 26 Oct 2022 11:47:38 +0000 (12:47 +0100)] 
doc: basenc: reference from base{32,64} docs

* doc/coreutils.texi (base32 invocation): Reference basenc
to improve discoverability.
(base64 invocation): Likewise.
* man/base32.x: Likewise.
* man/base64.x: Likewise.

2 years agodoc: sort: mention --version useful for IPv4 addresses
Pádraig Brady [Fri, 30 Sep 2022 14:44:30 +0000 (15:44 +0100)] 
doc: sort: mention --version useful for IPv4 addresses

* doc/coreutils.texi (sort invocation): Mention in the
multi invocation sort example that the -V GNU extension
could be used to sort IPv4 addresses, and thus simplify
to a single invocation.

2 years agomaint: NEWS: use consistent quoting
Pádraig Brady [Wed, 28 Sep 2022 18:01:04 +0000 (19:01 +0100)] 
maint: NEWS: use consistent quoting

* NEWS: Change unmatched curly quote to more consistent single quote.

2 years agodoc: be more consistent when documenting exit status
Pádraig Brady [Tue, 27 Sep 2022 20:59:01 +0000 (21:59 +0100)] 
doc: be more consistent when documenting exit status

* src/system.h (emit_exec_status): A new function to
output standard "Exit status:" info for commands that exec others.
* doc/coreutils.texi (Exit status): Add "ls" and "runcon"
to the list of commands with non standard exit status.
* src/numfmt.c (main): Call initialize_exit_failure() explicitly
to better indicate this utility may exit with something other than
EXIT_FAILURE.
* src/timeout.c (usage): Use more consistent capitalization.
* src/chroot.c: Call emit_exec_status().
* src/env.c: Likewise.
* src/nice.c: Likewise.
* src/nohup.c: Likewise.
* src/runcon.c: Likewise.
* src/stdbuf.c: Likewise.

2 years agoruncon: fix inconsistent exit status upon write error
Pádraig Brady [Tue, 27 Sep 2022 20:39:31 +0000 (21:39 +0100)] 
runcon: fix inconsistent exit status upon write error

* src/runcon.c (main): Call initialize_exit_failure(),
so we use an appropriate exit status upon failure to close stdout.
This should have been part of recent commit ea3ee6df.
* tests/misc/help-version.sh: Adjust test case accordingly.

2 years agomaint: getlimits: diagnose invalid options
Pádraig Brady [Tue, 27 Sep 2022 17:27:05 +0000 (18:27 +0100)] 
maint: getlimits: diagnose invalid options

* src/getlimits.c: Don't call initialize_exit_failure()
as it's not needed for standard EXIT_FAILURE returns.
Also use the function variant that diagnoses invalid options.

2 years agomaint: rmdir: also use DS_... constants here
Pádraig Brady [Tue, 27 Sep 2022 20:35:28 +0000 (21:35 +0100)] 
maint: rmdir: also use DS_... constants here

* src/rmdir.c: As with commit 627c9a97,
use DS_NONEMPTY constant to improve readability.

2 years agowc: add --total={auto,never,always,only} option
Pádraig Brady [Sat, 25 Jun 2022 23:27:06 +0000 (00:27 +0100)] 
wc: add --total={auto,never,always,only} option

without this option, control of when the total is output
is quite awkward. Consider trying to suppress the total line,
which could be achieved with something like:

   wc-no-total() { wc "$@" /dev/null | head -n-2; }

As well as being non obvious, it's also non general.
It would give a non failure, but zero count if passed a file on stdin.
Also it doesn't work in conjunction with the --files0-from option,
which would need to be handled differently with something like:

   { find files -print0; printf '%s\0' /dev/null; } |
   wc --files0-from=- |
   head -n2

Also getting just the total can be awkward as file names
are only suppressed when processing stdin, and
also a total line is only printed if processing more than one file.
For completness this might be achieved currently with:

  wc-only-total() {
    wc "$@" |
    tail -n1 |
    sed 's/^ *//; s/ [^ 0-9]*$//'
  }

* src/wc.c: Add new --total option.
* tests/misc/wc-total.sh: New test suite for the new option.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (wc invocation): Document the new option.
* THANKS.in: Add suggestor.
* NEWS: Mention the new feature.

2 years agomaint: use enums to make dir_status code easier to read
Pádraig Brady [Sun, 25 Sep 2022 14:26:20 +0000 (15:26 +0100)] 
maint: use enums to make dir_status code easier to read

* src/system.h: Add DS_EMPTY, and DS_NONEMPTY enums.
* src/remove.c: Use the new enums to make code easier to understand.

2 years agodoc: mention the recent rm improvement
Pádraig Brady [Sun, 25 Sep 2022 14:25:45 +0000 (15:25 +0100)] 
doc: mention the recent rm improvement

* NEWS: Mention the improvement re handling of directory errnos.

2 years agomaint: fix recent syntax-check failures
Pádraig Brady [Sun, 25 Sep 2022 14:12:13 +0000 (15:12 +0100)] 
maint: fix recent syntax-check failures

* .gitignore: Add new headers from gnulib.
* src/basenc.c: Adjust line length due to replacement
of 'verify' with 'static_assert'.
* src/od.c: Likewise.

2 years agorm: fix diagnostics on I/O error
Paul Eggert [Wed, 21 Sep 2022 21:05:49 +0000 (14:05 -0700)] 
rm: fix diagnostics on I/O error

I ran into this problem when attempting to recursively
remove a directory in a filesystem on flaky hardware.
Although the underlying readdir syscall failed with errno == EIO,
rm issued no diagnostic about the I/O error.

Without this patch I see this behavior:

  $ rm -fr baddir
  rm: cannot remove 'baddir': Directory not empty
  $ rm -ir baddir
  rm: descend into directory 'baddir'? y
  rm: remove directory 'baddir'? y
  rm: cannot remove 'baddir': Directory not empty

With this patch I see the following behavior, which
lets the user know about the I/O error when rm tries
to read baddir's directory entries:

  $ rm -fr baddir
  rm: cannot remove 'baddir': Input/output error
  $ rm -ir baddir
  rm: cannot remove 'baddir': Input/output error

* src/remove.c (Ternary): Remove.  All uses removed.
(get_dir_status): New static function.
(prompt): Last arg is now directory status, not ternary.
Return RM_USER_ACCEPTED if user explicitly accepted.
All uses changed.
Report any significant error in directory status right away.
(prompt, rm_fts): Use get_dir_status to get directory status lazily.
(excise): Treat any FTS_DNR errno as being more descriptive, not
just EPERM and EACCESS.  For example, EIO is more descriptive.
(rm_fts): Distinguish more clearly between explicit and implied
user OK.
* src/remove.h (RM_USER_ACCEPTED): New constant.
(VALID_STATUS): Treat it as valid.
* src/system.h (is_empty_dir): Remove, replacing with ...
(directory_status): ... this more-general function.
All uses changed.  Avoid undefined behavior of looking at
a non-null readdir pointer after corresponding closedir.
* tests/rm/rm-readdir-fail.sh: Adjust test of internals
to match current behavior.

2 years agorm: fix readdir test
Paul Eggert [Sat, 24 Sep 2022 20:40:47 +0000 (13:40 -0700)] 
rm: fix readdir test

* tests/rm/rm-readdir-fail.sh [_DIRENT_HAVE_D_NAMELEN]:
Fix off-by-1 bug in directory entry length.

2 years agodoc: fix typo in previous change
Paul Eggert [Tue, 20 Sep 2022 08:12:37 +0000 (01:12 -0700)] 
doc: fix typo in previous change

2 years agodoc: warn about tabs command (bug#57946)
Paul Eggert [Tue, 20 Sep 2022 07:09:42 +0000 (00:09 -0700)] 
doc: warn about tabs command (bug#57946)

2 years agoall: prefer HTTPS to HTTP
Stefan Kangas [Sun, 18 Sep 2022 14:15:16 +0000 (16:15 +0200)] 
all: prefer HTTPS to HTTP

* README-hacking:
* README-prereq:
* THANKS.in:
* doc/sort-version.texi (Other version/natural sort implementations):
* gl/lib/rand-isaac.c:
* gl/tests/test-rand-isaac.c:
* src/operand2sig.c (operand2sig):
* src/remove.c (nonexistent_file_errno):
* tests/misc/env-signal-handler.sh:
* tests/misc/sort-debug-warn.sh (LC_ALL): Prefer HTTPS to HTTP.
Addresses https://bugs.gnu.org/56512
Copyright-paperwork-exempt: yes

2 years agokill: port to picky-conversion hosts
Paul Eggert [Sun, 18 Sep 2022 02:41:15 +0000 (19:41 -0700)] 
kill: port to picky-conversion hosts

* src/kill.c (send_signals): Don’t rely on conversion overflow
being silent.

2 years agomaint: fix bootstrap module lists for alignof
Paul Eggert [Thu, 15 Sep 2022 06:03:10 +0000 (01:03 -0500)] 
maint: fix bootstrap module lists for alignof

* bootstrap.conf (gnulib_modules): Remove alignof, which isn’t
needed since coreutils source modules don’t include alignof.h.
Add stdalign, since they depend on alignof working without
stdalign.h.

2 years agomaint: prefer static_assert to verify
Paul Eggert [Thu, 15 Sep 2022 05:55:08 +0000 (00:55 -0500)] 
maint: prefer static_assert to verify

* bootstrap.conf: Add assert-h.
* gl/lib/randperm.c: Do not include verify.h.
* gl/lib/randperm.c, src/basenc.c, src/dd.c, src/digest.c:
* src/dircolors.c, src/expr.c, src/factor.c, src/ls.c, src/numfmt.c:
* src/od.c, src/seq.c, src/shred.c, src/sort.c, src/stat.c:
Prefer C23’s static_assert to nonstandard verify.
* gl/modules/randperm (Depends-on): Add assert-h.

2 years agomaint: assume C23 alignof
Paul Eggert [Thu, 15 Sep 2022 05:43:39 +0000 (00:43 -0500)] 
maint: assume C23 alignof

* gl/lib/randread.c, src/stat.c (print_statfs):
No need to include stdalign.h, now that alignof is a keyword
in C23 and Gnulib arranges for this.

2 years agomaint: don’t include config.h twice
Paul Eggert [Thu, 15 Sep 2022 05:30:31 +0000 (00:30 -0500)] 
maint: don’t include config.h twice

* gl/lib/fadvise.h, gl/lib/smack.h, src/blake2/blake2-impl.h:
Do not include config.h from a .h file.  config.h is supposed
to be included once, at the start of compilation and before
any other file.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Thu, 15 Sep 2022 05:29:53 +0000 (00:29 -0500)] 
build: update gnulib submodule to latest

2 years agodoc: shred: minor fix
Álvar Ibeas [Tue, 13 Sep 2022 22:24:27 +0000 (17:24 -0500)] 
doc: shred: minor fix

* doc/coreutils.texi: Fix wording.

Copyright-paperwork-exempt: yes