2023-04-18  Pádraig Brady  <P@draigBrady.com>

	version 9.3
	* NEWS: Record release date.

2023-04-16  Pádraig Brady  <P@draigBrady.com>

	tests: avoid allocation checks on ZFS
	* tests/du/basic.sh: Allocation of files was seen to change
	asynchronously on ZFS, so avoid allocation comparisons there.

2023-04-14  Pádraig Brady  <P@draigBrady.com>

	tests: tty-eof: fix various issues
	* tests/misc/tty-eof.pl: Ensure we don't erroneously
	skip commands with parameters.
	Comment as to why cut(1) is treated differently.
	Adjust expect calls to not wait needlessly for cut output.

2023-04-13  Pádraig Brady  <P@draigBrady.com>

	tests: avoid dependence on file layout for cp sparse check
	* tests/cp/sparse-2.sh: Don't depend on the copy taking
	<= allocation of the source.  Instead leverage --debug
	to check that zero detection is being enabled.

	copy: --debug: indicate if NUL detection is used with SEEK_HOLE
	* src/copy.c (sparse_copy): With --sparse=always we also detect
	NULs in extents we're copying, so indicate this with --debug.

2023-04-10  Paul Eggert  <eggert@cs.ucla.edu>

	doc: update re 32-bit builds
	* README-install: Mention how to build on 32-bit-only hosts.
	This builds on a previous patch by Pádraig Brady.

2023-04-10  Pádraig Brady  <P@draigBrady.com>

	build: fix _Noreturn compilation failure
	Fix a build failure seen on gcc 3.4 on Solaris 10 at least.

	* src/crctab.c: Ensure we include config.h for all compilation units.
	This is now required for new _Noreturn usage in gnulib for stdint.h.
	* src/cksum.c: Update generation code to ensure config.h included.
	* cfg.mk: Remove crctab.c exclusion from the config.h check.

2023-04-10  Pádraig Brady  <P@draigBrady.com>

	tests: avoid non portable brace expansion
	* tests/cp/backup-dir.sh: Avoid non portable brace expansion
	which is not supported by FreeBSD or Solaris shells at least.

2023-04-10  Paul Eggert  <eggert@cs.ucla.edu>

	maint: require support for post-2038 timestamps
	* bootstrap.conf (gnulib_modules): Replace year2038 with
	year2038-required.

	build: update gnulib submodule to latest

2023-04-08  Pádraig Brady  <P@draigBrady.com>

	wc: ensure we update file offset
	* src/wc.c (wc): Update the offset when not reading,
	and do read if we can't update the offset.
	* tests/misc/wc-proc.sh: Add a test case.
	* NEWS: Mention the bug fix.
	Fixes https://bugs.gnu.org/61300

	cp,mv: issue "skipped" messages when skipping files
	* NEWS: Mention the change in behavior to issue a "not replaced"
	error diagnostic with -n, and the "skipped" message with -v.
	* src/copy.c (copy_internal): Adjust to output the "skipped" messages
	depending on -i, -n, -u.
	* tests/cp/cp-i.sh: Adjust accordingly.
	* tests/mv/mv-n.sh: Likewise.

2023-04-08  Pádraig Brady  <P@draigBrady.com>

	cp,mv: add --update=none to always skip existing files
	Add --update=none which is equivalent to the --no-clobber behavior
	from before coreutils 9.2.  I.e. existing files are unconditionally
	skipped, and them not being replaced does not affect the exit status.

	* src/copy.h [enum Update_type]: A new type to support parameters
	to the --update command line option.
	[enum Interactive]: Add I_ALWAYS_SKIP.
	* src/copy.c: Treat I_ALWAYS_SKIP like I_ALWAYS_NO (-n),
	except that we don't fail when skipping.
	* src/system.h (emit_update_parameters_note): A new function
	to output the description of the new --update parameters.
	* src/cp.c (main): Parse --update arguments, ensuring that
	-n takes precedence if specified.
	(usage): Describe the new option.  Also allude that
	-u is related in the -n description.
	* src/mv.c: Accept the new --update parameters and
	update usage() accordingly.
	* doc/coreutils.texi (cp invocation): Describe the new --update
	parameters.  Also reference --update from the --no-clobber description.
	(mv invocation): Likewise.
	* tests/mv/update.sh: Test the new parameters.
	* NEWS: Mention the new feature.
	Addresses https://bugs.gnu.org/62572

2023-04-04  Pádraig Brady  <P@draigBrady.com>

	cp: fix --backup with subdirectories
	* gnulib: Reference the latest gnulib including the
	fix to the backupfile module in commit 94496522.
	* tests/cp/backup-dir.sh: Add a test to ensure
	we rename appropriately when backing up through subdirs.
	* NEWS: Mention the bug fix.
	Fixes https://bugs.gnu.org/62607

2023-03-31  Pádraig Brady  <P@draigBrady.com>

	tests: tee: avoid false failure due to fifo usage
	* tests/misc/tee.sh: Call cleanup_ in all cases to ensure
	there are no overlapping interactions on the fifo that
	might impact later parts of the test.  This was seen to
	cause issue with dash on musl libc.
	Addresses https://bugs.gnu.org/62542

	tests: adjust csplit VM limit
	* tests/misc/csplit-heap.sh: More memory is required to avoid
	a false failure on some systems.  Noticed with musl libc
	with bash as the shell.  This is confirmed to still easily
	trigger with the original memory leak being tested.
	Addresses https://bugs.gnu.org/62542

	wc: diagnose overflow of total counts
	* src/wc.c (wc): Use INT_ADD_WRAPV() to detect overflow.
	(main): Upon overflow, saturate the total, print a diagnostic,
	and set exit status.
	* tests/misc/wc-total.sh: Add a test case, which operates
	on BTRFS and 64 bit systems at least.
	Reported at https://bugs.debian.org/1027100

2023-03-28  Pádraig Brady  <P@draigBrady.com>

	dircolors: diagnose read errors
	* NEWS: Mention the fix.
	* src/dircolors.c: Fail upon read error from getline().
	* tests/misc/dircolors.sh: Add a new test.
	* tests/local.mk: Reference the new test.

	tests: add a test case for the previous date fix
	* NEWS: Also mention this bug fix.
	* tests/misc/date-f.sh: Add a new test.
	* tests/local.mk: Reference the new test.

2023-03-28  Paul Eggert  <eggert@cs.ucla.edu>

	date: diagnose -f read errors
	* src/date.c (batch_convert): Diagnose read errors, fixing Bug#62497.

2023-03-25  Paul Eggert  <eggert@cs.ucla.edu>

	cp: clarify commentary
	* src/copy.c: Make comments a bit clearer.

2023-03-24  Pádraig Brady  <P@draigBrady.com>

	copy: fix --reflink=auto to fallback in more cases
	On restricted systems like android or some containers,
	FICLONE could return EPERM, EACCES, or ENOTTY,
	which would have induced the command to fail to copy
	rather than falling back to a more standard copy.

	* src/copy.c (is_terminal_failure): A new function refactored
	from handle_clone_fail().
	(is_CLONENOTSUP): Merge in the handling of EACCES, ENOTTY, EPERM
	as they also pertain to determination of whether cloning is supported
	if we ever use this function in that context.
	(handle_clone_fail): Use is_terminal_failure() in all cases,
	so that we assume a terminal failure in less errno cases.
	* NEWS: Mention the bug fix.
	Addresses https://bugs.gnu.org/62404

2023-03-24  Pádraig Brady  <P@draigBrady.com>

	doc: add a NEWS entry for the previous fix
	* NEWS: Mention the previous cksum --check fix.

2023-03-23  Pádraig Brady  <P@draigBrady.com>

	cksum: fix reporting of failed checks
	This applies to all checksumming utilities,
	where we incorrectly report all subsequent files as checking 'OK'
	once any file has passed a digest check.
	The exit status was not impacted, only the printed status.

	* src/digest.c (digest_check): Use the correct state variable
	to determine if the _current_ file has passed or not.
	* tests/misc/md5sum.pl: Add a test case.
	Fixes https://bugs.gnu.org/62403

2023-03-21  Nick Alcock  <nick.alcock@oracle.com>

	tests: skip some parts of tests/misc/tee.sh if run as root
	Similarly to the fix to tests/rmdir/ignore.sh in c0e5f8c59,
	tee should not be expected to fail when run with read-only outputs
	when run as root.

	* tests/misc/tee.sh: Add uid_is_privileged_ guard around test for
	read-only outputs.

2023-03-20  Pádraig Brady  <P@draigBrady.com>

	maint: post-release administrivia
	* NEWS: Add header line for next release.
	* .prev-version: Record previous version.
	* cfg.mk (old_NEWS_hash): Auto-update.

	version 9.2
	* NEWS: Record release date.

2023-03-19  Pádraig Brady  <P@draigBrady.com>

	tests: avoid false failure on systems without statx
	* tests/ls/stat-free-symlinks.sh: Filter out syscalls that
	return ENOSYS, as that was seen with statx() on Debian 10.13
	on mips64, and resulted in overcounting of stat calls.

	stty: ensure arbitrary data is not displayed
	* src/stty.c (main): Use static structures to ensure
	they're initialized (to zero), so that random data is
	not displayed, or compared resulting in a inaccurate
	failure reported to users.  This was seen on musl libc
	where some parts of the termios c_cc array were
	not initialized by tcgetattr().
	Reported by Bruno Haible.

	tests: df: avoid false failure on systems with multiple roots
	* tests/df/df-symlink.sh: Skip the test on systems
	with multiple file system roots.

2023-03-18  Pádraig Brady  <P@draigBrady.com>

	doc: uniq: revert previous man page adjustment
	* src/uniq.c (usage): -D doesn't take an argument
	so should be separated in the description.

	doc: uniq: use more standard description of -D long option
	* src/uniq.c: Describe -D and --all-repeated together,
	as with all other long options.
	Fixes https://bugs.gnu.org/62249

	tests: aix: avoid unsupported functionality
	* tests/misc/tee.sh: AIX doesn't support detecting
	closed outputs either with poll() or select() so avoid
	testing that functionality.
	* tests/tail-2/pipe-f.sh: Likewise.

2023-03-16  Bernhard Voelker  <mail@bernhard-voelker.de>

	maint: avoid discarded-qualifiers warnings with SELinux 3.5
	Since SELinux version 3.5, the return value of context_str(3) is
	declared as const; see:
	  https://github.com/SELinuxProject/selinux/commit/dd98fa322766
	Therefore, GCC complains (here with -Werror):
	  src/selinux.c: In function 'defaultcon':
	  src/selinux.c:152:16: error: assignment discards 'const' qualifier \
	    from pointer target type [-Werror=discarded-qualifiers]
	    152 |   if (!(constr = context_str (tcontext)))
	        |                ^
	  src/selinux.c: In function 'restorecon_private':
	  src/selinux.c:252:16: error: assignment discards 'const' qualifier \
	    from pointer target type [-Werror=discarded-qualifiers]
	    252 |   if (!(constr = context_str (tcontext)))
	      |                ^

	* src/selinux.c (defaultcon): Define CONSTR as const.
	(restorecon_private): Likewise.

2023-03-15  Pádraig Brady  <P@draigBrady.com>

	test: avoid a test hang on Hurd
	* tests/cp/sparse-to-pipe.sh: Protect the cp call seen to
	hang on Hurd/i686 with a timeout.
	Reported By: Bruno Haible

	cksum: fix --raw on 64 bit big endian systems
	* src/sum.c (output_bsd): On sparc64 for example,
	a crc of 0 was output due to casting an int variable
	to uint16_t and thus operating on the wrong end of the variable.
	Instead use explicit assignment to the narrower type
	to ensure we get the appropriate data.
	(output_sysv): Likewise.
	Reported by Bruno Haible.

2023-03-15  Bruno Haible  <bruno@clisp.org>

	build: avoid -Wsometimes-uninitialized on macOS 12
	* src/pr.c (integer_overflow): Mark as _Noreturn.
	* src/test.c (beyond): Likewise.

2023-03-13  Pádraig Brady  <P@draigBrady.com>

	doc: remove older ChangeLog items
	* Makefile.am: Update the oldest documented version
	to 8.29 which is now about 5 years old.

	tee: avoid undefined behavior after fclose()
	* iopoll.c (fclose_wait): Rename from confusing fclose_nonblock name.
	Also adjust to do no operations on the stream after fclose()
	as this is undefined. Instead use fflush() to determine EAGAIN status.
	(fwrite_wait): Renamed from confusing fwrite_nonblock name.

	doc: dircolors: better separate the sections in the database
	* src/dircolors.hin: Make the separate sections of the self
	documenting dircolors database more apparent,
	by adding heading comments, and appropriate separation.

2023-03-13  Pádraig Brady  <P@draigBrady.com>

	ls: --color: honor separate sequences for extension cases
	Following on from commit v8.29-45-g24053fbd8 which unconditionally
	used case insensitive extension matching, support selective
	case sensitive matching when there are separate extension cases
	defined with different display sequences.

	* src/dircolors.hin: Document how file name suffixes are matched.
	Note this is displayed with `dircolors --print-database` which
	the texi info recommends to use for details.
	* src/ls.c (parse_ls_color): Postprocess the list to
	mark entries for case sensitive matching,
	and also adjust so that unmatchable entries are more quickly ignored.
	(get_color_indicator): Use exact matching rather than
	case insensitive matching if so marked.
	* tests/ls/color-ext.sh: Add test cases.
	* NEWS: Mention the change in behavior.
	Addresses https://bugs.gnu.org/33123

2023-03-13  Pádraig Brady  <P@draigBrady.com>

	tests: adjust du test for recent apparent size change
	* tests/du/threshold.sh: Directories are assumed to be
	of size 0 with --apparent since commit v9.1-187-g110bcd283
	so remove --apparent cases from this test.

2023-03-08  Pádraig Brady  <P@draigBrady.com>

	tee: support non blocking outputs
	Non blocking outputs can be seen for example
	when piping telnet through tee to a terminal.
	In that case telnet sets its input to nonblocking mode,
	which results in tee's output being nonblocking,
	in which case in may receive an EAGAIN error upon write().
	The same issue was seen with mpirun.
	The following can be used to reproduce this
	locally at a terminal (in most invocations):

	  $ { dd iflag=nonblock count=0 status=none;
	      dd bs=10K count=10 if=/dev/zero status=none; } |
	    tee || echo fail >/dev/tty

	* src/iopoll.c (iopoll_internal): A new function refactored from
	iopoll(), to also support a mode where we check the output
	descriptor is writeable.
	(iopoll): Now refactored to just call iopoll_internal().
	(fwait_for_nonblocking_write): A new internal function which
	uses iopoll_internal() to wait for writeable output
	if an EAGAIN or EWOULDBLOCK was received.
	(fwrite_nonblock): An fwrite() wrapper which uses
	fwait_for_nonblocking_write() to handle EAGAIN.
	(fclose_nonblock): Likewise.
	src/iopoll.h: Add fclose_nonblock, fwrite_nonblock.
	src/tee.c: Call fclose_nonblock() and fwrite_nonblock wrappers,
	instead of the standard functions.
	* tests/misc/tee.sh: Add a test case.
	* NEWS: Mention the improvement.

	The idea was suggested by Kamil Dudka in
	https://bugzilla.redhat.com/1615467

2023-03-08  Pádraig Brady  <P@draigBrady.com>

	doc: remove redundant NEWS entry
	* NEWS: There was no bug on macOS,
	and the split -n new feature is documented already.

2023-03-07  Paul Eggert  <eggert@cs.ucla.edu>

	split: support split -n on larger pipe input
	* bootstrap.conf (gnulib_modules): Add free-posix, tmpfile.
	* src/split.c (copy_to_tmpfile): New function.
	(input_file_size): Use it to split larger files when sizes cannot
	easily be determined via fstat or lseek.  See Bug#61386#235.
	* tests/split/l-chunk.sh: Mark tests of /dev/zero as
	very expensive since they exhaust /tmp.

2023-03-07  Pádraig Brady  <P@draigBrady.com>

	tee: fix a crash with unwriteable files
	This was introduced recently with commit v9.1-166-g6b12e62d9

	* src/tee.c (tee_files): Check the return from fopen()
	before passing to fileno() etc.
	* tests/misc/tee.sh: Add a test case.

2023-03-06  Paul Eggert  <eggert@cs.ucla.edu>

	maint: pacify ‘make syntax-check’
	Problem reported by Pádraig Brady (Bug#61386#226).
	* src/split.c (parse_chunk): Use die instead of error.
	(main): Quote a string.
	* tests/local.mk (all_root_tests): Move du/apparent.sh from here ...
	(all_tests): ... to here.

2023-03-06  Pádraig Brady  <P@draigBrady.com>

	tail,tee: avoid issues with many files on systems without poll
	* src/iopoll.c (iopoll): Protect the call to select against
	passing in a descriptor larger than FD_SETSIZE.

2023-03-05  Paul Eggert  <eggert@cs.ucla.edu>

	du: --apparent counts only symlinks and regular
	Problem reported by Christoph Anton Mitterer (Bug#61884).
	* src/du.c (process_file): When counting apparent sizes, count
	only usable st_size members.
	* tests/du/apparent.sh: New file.
	* tests/local.mk (all_root_tests): Add it.

2023-03-04  Paul Eggert  <eggert@cs.ucla.edu>

	split: tune for when creating output files
	* src/split.c (create): Avoid fstat + ftruncate in the usual case
	where the output file does not already exist, by trying
	to create it with O_EXCL first.  This costs a failed open
	in the unusual case where the output file already exists,
	but that’s OK.

	split: style fix
	* src/split.c (ofile_open): Avoid ‘if (! (a = b))’ style.

	split: prefer signed integers to size_t
	This allows for better runtime checking with gcc
	-fsanitize=undefined.
	* src/split.c: Include idx.h.
	(open_pipes_alloc, n_open_pipes, suffix_length)
	(set_suffix_length, input_file_size, sufindex, outbase_length)
	(outfile_length, addsuf_length, create, cwrite, bytes_split)
	(lines_split, line_bytes_split, lines_chunk_split)
	(bytes_chunk_extract, ofile_open, lines_rr, main):
	Prefer signed integers (typically idx_t) to size_t.

	split: handle large numbers better
	Prefer signed types to uintmax_t, as this allows for better
	runtime checking with gcc -fsanitize=undefined.
	Also, when an integer overflows just use the maximal value
	when the code will do the right thing anyway.
	* src/split.c (set_suffix_length, bytes_split, lines_split)
	(line_bytes_split, lines_chunk_split, bytes_chunk_extract)
	(lines_rr, parse_chunk, main):
	Prefer a signed type (typically intmax_t) to uintmax_t.
	(strtoint_die): New function.
	(OVERFLOW_OK): New macro.  Use it elsewhere, where we now allow
	LONGINT_OVERFLOW because the code then does the right thing on all
	practical platforms (they have int wide enough so that it cannot
	be practically exhausted).  We can do this now that we can safely
	assume intmax_t has at least 64 bits.
	(parse_n_units): New function.
	(parse_chunk, main): Use it.
	(main): Do not worry about integer overflow when the code
	will do the right thing anyway with the extreme value.
	Just use the extreme value.
	* tests/split/fail.sh: Adjust to match new behavior.

	split: prefer ssize_t for read result
	* src/split.c (bytes_split, lines_chunk_split)
	(bytes_chunk_extract, main): Prefer ssize_t to size_t when
	representing the return value of ‘read’.  Use a negative value
	instead of SIZE_MAX to indicate a missing value.

	split: be more careful about buffer sizes
	* src/split.c: Include sys-limits.h, not safe-read.h.
	(input_file_size, bytes_split, lines_split, line_bytes_split)
	(lines_chunk_split, bytes_chunk_extract, lines_rr): Call read, not
	safe_read, since safe_read no longer buys us anything.
	(main): Reject outlandish buffer sizes right away,
	rather than allocating huge buffers and never using them.

	split: minor -1 / 0 refactor
	* src/split.c (create, bytes_split, ofile_open):
	Prefer comparing to 0 to comparing to -1.

	split: don’t worry about ECHILD
	* src/split.c (closeout): There should be no need for a special
	case for ECHILD, since we never wait for the same child twice.
	Simplify with this in mind.

	split: don’t assume pid_t fits in int
	* src/split.c (filter_pid): Now pid_t, not int.
	(of_t): opid member is now pid_t, not int.

	split: simplify SIGPIPE handling
	Ignore and default SIGPIPE, rather than blocking and unblocking it.
	* src/split.c (default_SIGPIPE):
	New static var, replacing oldblocked and newblocked.
	(create): Use it.
	(main): Set it.

	split: port ‘split -n N /dev/null’ better to macOS
	* src/split.c (input_file_size): Do not bother with lseek if the
	initial read probe reaches EOF, since the file size is known then.
	This works better on macOS, which doesn’t allow lseek on /dev/null.
	Do not special-case size-zero files, as the issue can occur
	with any size file (though /proc files are the most common).
	If the current position is past end of file, treat this as
	size zero regardless of whether the file has a usable st_size.
	Pass through lseek -1 return values rather than using ‘return -1’;
	this makes the code a bit easier to analyze (and a bit faster).
	Avoid undefined behavior if the size calculation overflows.
	(lines_chunk_split): Do not bother with lseek if it would have
	no effect if successful.  This works better on macOS, which
	doesn’t allow lseek on /dev/null.
	* tests/split/l-chunk.sh: Adjust to match fixed behavior.

	maint: fix NEWS quoting
	* NEWS: Use English-language quoting in recent news.

	split: split more evenly with -n
	* src/split.c (bytes_split): New arg REM_BYTES.
	Use this to split more evenly.  All callers changed.
	(lines_chunk_split, bytes_chunk_extract):
	Be consistent with new byte_split.
	* tests/split/b-chunk.sh, tests/split/l-chunk.sh: Test new behavior.

	split: small -n lines simplification
	* src/split.c (lines_chunk_split):
	Rewrite while as if-while for clarity.

	split: refactor lines_chunk_split
	* src/split.c (lines_chunk_split): Simplify by having chunk_end
	point to the first byte after the chunk, rather than to the last
	byte of the chunk.  This will reduce confusion once we allow
	chunks to be empty.

	tee: tune when later -p overrides earlier
	* src/tee.c (pipe_check): Make this a local var instead
	of a static var.  This suppresses a -Wmaybe-uninitialized
	diagnostic with gcc 12.2.1 20221121 (Red Hat 12.2.1-4).
	(main): Don’t set pipe_check unnecessarily if a later
	-p option overrides an earlier one that wants pipe_check.
	Problem discovered when I investigated the GCC warning.

2023-03-01  Pádraig Brady  <P@draigBrady.com>

	maint: refactor tail.c to use iopoll
	* src/tail.c (check_output_alive): Reuse iopoll()
	rather than directly calling poll() or select().
	* src/iopoll.c (iopoll): Refactor to support non blocking operation,
	or ignoring descriptors by passing a negative value.
	* src/iopoll.h (iopoll): Adjust to support a BLOCK parameter.
	* src/tee.c (tee_files): Adjust iopoll() call to explicitly block.
	* src/local.mk: Have tail depend on iopoll.c.

2023-02-28  Pádraig Brady  <P@draigBrady.com>

	tail: avoid undefined behavior when polling outputs
	* src/tail.c (check_output_alive): Only check the returned
	events from poll() when it indicates there are events to check.

	doc: tee -p: clarify operation
	* src/tee.c (usage): Change from describing one (non pipe) aspect
	to the more general point of being the option to use if working with
	pipes, and referencing the more detailed info below.
	* doc/coreutils.texi (tee invocation): s/standard/appropriate/ since
	the standard operation with pipes is to exit immediately upon write
	error.  s/early/immediately/ as it's ambiguous as to what "early"
	is in relation to.

	tests: tee -p: add test for early exit with closed pipes
	* tests/misc/tee.sh: Add a test for the new iopoll logic
	to detect closed outputs and exit early without needing
	further input.

2023-02-28  Carl Edquist  <edquist@cs.wisc.edu>

	tee: enhance -p mode using iopoll() to detect broken pipe outputs
	If input is intermittent (a tty, pipe, or socket), and all remaining
	outputs are pipes (eg, >(cmd) process substitutions), exit early when
	they have all become broken pipes (and thus future writes will fail),
	without waiting for more input to become available, as future write
	attempts to these outputs will fail (SIGPIPE/EPIPE).

	Only provide this enhancement when pipe errors are ignored (-p mode).

	Note that only one output needs to be monitored at a time with iopoll(),
	as we only want to exit early if _all_ outputs have been removed.

	* src/tee.c (pipe_check): New global for iopoll mode.
	(main): enable pipe_check for -p, as long as output_error ignores EPIPE,
	and input is suitable for iopoll().
	(get_next_out): Helper function for finding next valid output.
	(fail_output, tee_files): Break out write failure/output removal logic
	to helper function.
	(tee_files): Add out_pollable array to track which outputs are suitable
	for iopoll() (ie, that are pipes); track first output index that is
	still valid; add iopoll() broken pipe detection before calling read(),
	removing an output that becomes a broken pipe.
	* src/local.mk (src_tee_SOURCES): include src/iopoll.c.
	* NEWS: Mention tee -p enhancement in Improvements.
	* doc/coreutils.texi: Mention the new early exit behavior in the nopipe
	modes for the tee -p option.

	Suggested-by: Arsen Arsenović <arsen@aarsen.me>

2023-02-28  Carl Edquist  <edquist@cs.wisc.edu>

	all: add broken pipe detection while waiting for input
	When a program's output becomes a broken pipe, future attempts to write
	to that ouput will fail (SIGPIPE/EPIPE).  Once it is known that all
	future write attepts will fail (due to broken pipes), in many cases it
	becomes pointless to wait for further input for slow devices like ttys.
	Ideally, a program could use this information to exit early once it is
	known that future writes will fail.

	Introduce iopoll() to wait on a pair of fds (input & output) for input
	to become ready or output to become a broken pipe.

	This is relevant when input is intermittent (a tty, pipe, or socket);
	but if input is always ready (a regular file or block device), then
	a read() will not block, and write failures for a broken pipe will
	happen normally.

	Introduce iopoll_input_ok() to check whether an input fd is relevant
	for iopoll().

	Experimentally, broken pipes are only detectable immediately for pipes,
	but not sockets.  Errors for other file types will be detected in the
	usual way, on write failure.

	Introduce iopoll_output_ok() to check whether an output fd is suitable
	for iopoll() -- namely, whether it is a pipe.

	iopoll() is best implemented with a native poll(2) where possible, but
	fall back to a select(2)-based implementation platforms where there are
	portability issues.  See also discussion in tail.c.

	In general, adding a call to iopoll() before a read() in filter programs
	also allows broken pipes to "propagate" backwards in a shell pipeline.

	* src/iopoll.c, src/iopoll.h (iopoll): New function implementing broken
	pipe detection on output while waiting for input.
	(IOPOLL_BROKEN_OUTPUT, IOPOLL_ERROR): Return codes for iopoll().
	(IOPOLL_USES_POLL): Macro for poll() vs select() implementation.
	(iopoll_input_ok): New function to check whether an input fd is relevant
	for iopoll().
	(iopoll_output_ok): New function to check whether an input fd is
	suitable for iopoll().
	* src/local.mk (noinst_HEADERS): add src/iopoll.h.

2023-02-27  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-26  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-26  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-24  Pádraig Brady  <P@draigBrady.com>

	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`.

2023-02-24  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-24  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-23  Paul Eggert  <eggert@cs.ucla.edu>

	build: update gnulib submodule to latest

2023-02-23  Pádraig Brady  <P@draigBrady.com>

	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

2023-02-21  ChuanGang Jiang  <jiangchuanganghw@outlook.com>

	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

2023-02-21  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-21  Jim Meyering  <meyering@fb.com>

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

2023-02-21  Jim Meyering  <meyering@meta.com>

	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.

2023-02-18  Paul Eggert  <eggert@cs.ucla.edu>

	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.

	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.

	build: update gnulib submodule to latest

2023-02-16  Paul Eggert  <eggert@cs.ucla.edu>

	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.

2023-02-10  ChuanGang Jiang  <jiangchuanganghw@outlook.com>

	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

2023-02-10  Paul Eggert  <eggert@cs.ucla.edu>

	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

2023-02-06  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-06  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-06  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-05  Pádraig Brady  <P@draigBrady.com>

	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.

2023-02-04  Paul Eggert  <eggert@cs.ucla.edu>

	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.

	maint: prefer https: to git:
	The idea is to defend against some adversary-in-the-middle attacks.

	build: update gnulib submodule to latest

2023-02-03  Pádraig Brady  <P@draigBrady.com>

	maint: avoid line length syntax check failure
	* src/cp.c: Adjust source line to be <= 80 chars.

	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.

2023-02-01  Jim Meyering  <meyering@fb.com>

	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.

2023-01-31  Paul Eggert  <eggert@cs.ucla.edu>

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

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

	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.

	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.

2023-01-30  Pádraig Brady  <P@draigBrady.com>

	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.

2023-01-30  Jim Meyering  <meyering@fb.com>

	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
