]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
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

2 years agomaint: adjust to Gnulib stdbool C23 change
Paul Eggert [Tue, 13 Sep 2022 04:06:24 +0000 (23:06 -0500)] 
maint: adjust to Gnulib stdbool C23 change

* gl/lib/mbsalign.c, gl/lib/randread.c, gl/lib/targetdir.h:
* gl/lib/xdectoint.c, gl/lib/xfts.c, gl/lib/xfts.h:
* src/blake2/b2sum.c, src/copy.h, src/die.h, src/system.h:
Don’t include <stdbool.h>, since Gnulib now emulates C23.

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 13 Sep 2022 03:39:41 +0000 (22:39 -0500)] 
build: update gnulib submodule to latest

2 years agostty: give explicit error for unsupported asymmetric speeds
Pádraig Brady [Sun, 11 Sep 2022 17:37:24 +0000 (18:37 +0100)] 
stty: give explicit error for unsupported asymmetric speeds

* src/stty.c (check_speed): If difference input and output speeds
are specified, then validate the system supports that, before
interacting with the device.

2 years agostty: fix false warnings from [io]speed settings
Pádraig Brady [Sun, 11 Sep 2022 14:37:35 +0000 (15:37 +0100)] 
stty: fix false warnings from [io]speed settings

* src/stty.c (eq_mode): A new function to compare
equivalence of two modes.
(main): Use eq_mode() rather than memcmp() to compare
two modes. Also use stack variables rather than implicitly
initialized static variables.  Also remove all uses of
the SPEED_WAS_SET hack since we now more robustly compare modes.
* NEWS: Update the [io]speed fix entry.
Reported at https://bugs.debian.org/1019468

2 years agomaint: add lib/gmp.h to .gitignore
Pádraig Brady [Fri, 2 Sep 2022 21:06:05 +0000 (22:06 +0100)] 
maint: add lib/gmp.h to .gitignore

* .gitignore: Add generated file.  Tested with:
./configure --without-libgmp && make && git status

2 years agostty: add an undocumented ---debug option for more info
Pádraig Brady [Tue, 30 Aug 2022 23:39:59 +0000 (00:39 +0100)] 
stty: add an undocumented ---debug option for more info

* src/stty.c (main): Move internal TESTING code that showed
the new and old mode, upon failure to apply the new mode,
to being runtime controlled with the ---debug option.
Also augment the display to show which items were not
set as expected.

2 years agodoc: stty: clarify that [-]drain is treated as an option
Pádraig Brady [Wed, 31 Aug 2022 13:16:14 +0000 (14:16 +0100)] 
doc: stty: clarify that [-]drain is treated as an option

* doc/coreutils.texi (stty invocation): Say that "drain"
is treated as an option, rather than a line setting,
and so option processing rules apply to it.
Reported in https://bugs.debian.org/1018803

2 years agostty: validate ispeed and ospeed arguments
Pádraig Brady [Tue, 30 Aug 2022 23:17:21 +0000 (00:17 +0100)] 
stty: validate ispeed and ospeed arguments

* src/stty.c (apply_settings): Validate [io]speed arguments
against the internal accepted set.
(set_speed): Check the cfset[io]speed() return value so
that we validate against the system supported set.
* tests/misc/stty-invalid.sh: Add a test case.
* NEWS: Mention the bug fix.
Reported in https://bugs.debian.org/1018790

2 years agomaint: be defensive in avoiding gnulib's poll module
Pádraig Brady [Sun, 28 Aug 2022 01:48:11 +0000 (02:48 +0100)] 
maint: be defensive in avoiding gnulib's poll module

* src/tail.c (check_output_alive): Add a guard that would
trigger on most platforms, to detect if we're using the
gnulib poll module.  That's currently problematic in the
way it emulates poll() using select() and would cause
issues on macOS and AIX at least as poll() is replaced there.

2 years agotail: use poll() on macOS
Pádraig Brady [Sun, 28 Aug 2022 01:32:34 +0000 (02:32 +0100)] 
tail: use poll() on macOS

* src/tail.c (check_output_alive): poll() is the most commonly used
interface, so use this on macOS also to minimize divergence.

2 years agotests: runcon: fix new test to skip on non SELinux systems
Pádraig Brady [Sat, 27 Aug 2022 21:15:44 +0000 (22:15 +0100)] 
tests: runcon: fix new test to skip on non SELinux systems

* tests/misc/runcon-compute.sh: Use our new internal error
125 status to detect SELinux errors, and skip in this case.

2 years agodoc: NEWS: document recent comm fix, and runcon change
Pádraig Brady [Sat, 27 Aug 2022 20:32:01 +0000 (21:32 +0100)] 
doc: NEWS: document recent comm fix, and runcon change

* NEWS: Mention comm bug fix, and runcon change in behavior.

2 years agotests: fix tests after recent runcon change
Pádraig Brady [Sat, 27 Aug 2022 18:17:27 +0000 (19:17 +0100)] 
tests: fix tests after recent runcon change

Following commit v9.1-49-gea3ee6df2

* tests/misc/invalid-opt.pl: Map runcon failure status to 125.
* tests/misc/usage_vs_getopt.sh: Likewise.

2 years agocomm: fix NUL --output-delimiter with --total
Pádraig Brady [Sat, 27 Aug 2022 17:40:14 +0000 (18:40 +0100)] 
comm: fix NUL --output-delimiter with --total

* src/comm.c (compare_files): Handle the single character
--output-delimeter case separately so that NUL is appropriately
handled.
* doc/coreutils.texi (comm invocation): Fix the description
of --output-delimiter to say an empty delimeter is treated
as a NUL separator, rather than being disallowed.
* tests/misc/comm.pl: Add a test case.
Reported at https://bugs.debian.org/1014008

2 years agomaint: remove FIXME comment from timeout.c
Pádraig Brady [Sat, 27 Aug 2022 16:54:42 +0000 (17:54 +0100)] 
maint: remove FIXME comment from timeout.c

* src/timeout.c: We shouldn't hardcode `sh -c` as users
can specify that if needed, so remove the comment.

2 years agoruncon: distinguish runcon specific errors in exit status
Pádraig Brady [Sat, 27 Aug 2022 16:50:20 +0000 (17:50 +0100)] 
runcon: distinguish runcon specific errors in exit status

* src/runcon.c: Use EXIT_CANCELED (125) instead of EXIT_FAILURE (1),
so that errors specific to runcon can be distinguished,
from those of the invoked program.
* doc/coreutils.texi (runcon invocation): Fix the Exit status
description to say we return 125 (not 127) for internal errors.
* tests/misc/runcon-no-reorder.sh: Add a test case.

2 years agodoc: README: split out ancillary information
Pádraig Brady [Sat, 13 Aug 2022 19:48:12 +0000 (20:48 +0100)] 
doc: README: split out ancillary information

The README was becoming too long and contained
quite a bit of info only pertaining to rarely used systems, so...

* README: Split out install specific info to README-install.
Also remove a few stale lines, and reorder a few items.
* README-install: A new file split from README.
* Makefile.am [EXTRA_DIST]: Explicitly reference new README-install
file for distribution, since automake only auto adds README.
* TODO: Reference the HPUX info now in README-install.

2 years agols: support explicit --time=modification selection
Pádraig Brady [Fri, 12 Aug 2022 13:16:14 +0000 (14:16 +0100)] 
ls: support explicit --time=modification selection

* src/ls.c [time_args]: Add support for explicit
'mtime' or 'modification' arguments to --time.
* tests/misc/ls-time.sh: Add explicit --time=mtime usage.
* doc/coreutils.texi (ls invocation): Describe --time=mtime.
* NEWS: Mention the new feature.

2 years agodoc: ls: clarify description of timestamps
Pádraig Brady [Fri, 12 Aug 2022 12:40:00 +0000 (13:40 +0100)] 
doc: ls: clarify description of timestamps

* src/ls.c (usage): Don't mention "modification" in the
description of ctime (-c), as it's confusing with mtime.
Mention "metadata" when discussing "change" time to
disambiguate from data change time.
* doc/coreutils.texi (ls invocation): State that --time=creation
falls back to using mtime where not available.

3 years agodoc: cp: fix --reflink=when typo in texinfo
Pierre Marsais [Sat, 30 Jul 2022 21:51:18 +0000 (22:51 +0100)] 
doc: cp: fix --reflink=when typo in texinfo

This behaviour is correctly documented when doing `cp --help`.
There is no `--reflink=when` option.

* doc/coreutils.texi (cp invocation): Fix document stating
that `--reflink` is equivalent to `--reflink=always`.

3 years agodoc: uniq: clarify -f operation
Pádraig Brady [Mon, 1 Aug 2022 20:55:12 +0000 (21:55 +0100)] 
doc: uniq: clarify -f operation

* doc/coreutils.texi (uniq invocation): State that leading blanks
are part of the field, and also that -f is one based.

3 years agodoc: reference fmt(1) from fold(1)
Pádraig Brady [Sat, 30 Jul 2022 12:06:56 +0000 (13:06 +0100)] 
doc: reference fmt(1) from fold(1)

* man/fold.x: fold and fmt have overlapping functionality,
so reference fmt(1) from the lower level fold(1) utility.

3 years agotouch: fix aliasing bug
Paul Eggert [Wed, 27 Jul 2022 16:59:38 +0000 (09:59 -0700)] 
touch: fix aliasing bug

Problem reported by Tim Lange in:
https://lists.gnu.org/r/coreutils/2022-07/msg00008.html
* src/touch.c (date_relative): Rename from get_reldate,
and use a functional style to fix the aliasing bug.

3 years agodoc: env: clarify that empty signal args are ignored
Pádraig Brady [Tue, 26 Jul 2022 13:10:59 +0000 (14:10 +0100)] 
doc: env: clarify that empty signal args are ignored

It's useful to treat empty and missing arguments differently.
Missing means all signals, while empty means no signals and
so is a no-op.  It's useful to treat empty arguments like
this, so that dynamically specified arguments like the following
are supported

  env --ignore-signals "$SIGS_TO_IGNORE"

Note `env --ignore-signals=` is treated as an empty argument.

* doc/coreutils.texi (env invocation): Empty args are treated
differently to missing arguments, so call that out explicitly.
* src/env.c (usage): Likewise.
Addresses https://bugs.debian.org/1016049

3 years agodoc: date: clarify which options are mutually exclusive
Pádraig Brady [Sun, 24 Jul 2022 19:49:29 +0000 (20:49 +0100)] 
doc: date: clarify which options are mutually exclusive

* src/date.c (usage): Specify that --date, --file, --reference,
and --resolution are mutually exclusive.  This is also useful
documentation to group similar options.
* doc/coreutils.texi (Options for date): Likewise.
Addresses https://bugs.gnu.org/55401

3 years agodate: --debug: diagnose discarded -d or -s options
Pádraig Brady [Sun, 24 Jul 2022 18:24:18 +0000 (19:24 +0100)] 
date: --debug: diagnose discarded -d or -s options

* src/date.c: (main): Track and diagnose whether any
-d or -s options are dropped, as users may think
multiple options are supported, given they can be relative.
* tests/misc/date-debug.sh: Add a test case.
* NEWS: Mention the improvement.

3 years agoruncon: ensure --compute runs the file it inspects
Pádraig Brady [Sun, 24 Jul 2022 17:46:10 +0000 (18:46 +0100)] 
runcon: ensure --compute runs the file it inspects

* src/runcon.c (main): With -c avoid searching the path
to ensure the file specified to --compute is executed.
* tests/misc/runcon-compute.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Reported in https://bugs.debian.org/1013924