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

3 years agodoc: tr: clarify that -t is ignored unless translating
Pádraig Brady [Sun, 19 Jun 2022 12:18:01 +0000 (13:18 +0100)] 
doc: tr: clarify that -t is ignored unless translating

* src/tr.c (usage): Don't say that -t is disallowed unless translating.
Reported in https://bugs.debian.org/1012447

3 years agorm: don’t assume st_size is nonnegative
Paul Eggert [Sat, 23 Jul 2022 19:11:49 +0000 (12:11 -0700)] 
rm: don’t assume st_size is nonnegative

* src/remove.c: Include stat-time.h.
(cache_fstatat, cache_stat_init): Use negative st->st_atim.tv_sec to
determine whether the stat is cached, not negative st->st_size.
On non-POSIX platforms that lack st_atim.tv_sec, don’t bother to cache.

3 years agostat: -c %s now prints unsigned
Paul Eggert [Fri, 22 Jul 2022 20:50:31 +0000 (13:50 -0700)] 
stat: -c %s now prints unsigned

* src/stat.c (unsigned_file_size): New static function,
copied from src/ls.c.
(print_stat): %s prints an unsigned value now (Bug#56710).

3 years agodd: doc improvement (Bug#54586)
Paul Eggert [Thu, 7 Jul 2022 04:42:19 +0000 (23:42 -0500)] 
dd: doc improvement (Bug#54586)

* doc/coreutils.texi (dd invocation): Explain
fdatasync and fsync better.

3 years agocp: don’t remove nonempty cloned dest
Paul Eggert [Wed, 6 Jul 2022 19:29:12 +0000 (14:29 -0500)] 
cp: don’t remove nonempty cloned dest

This follows up on comments by Pádraig Brady (bug#56391).
* src/copy.c (copy_reg): When --reflink=always removes a file
due to an FICLONE failure, do not remove a nonempty file.

3 years agocp: don’t create empty file if cannot clone
Paul Eggert [Tue, 5 Jul 2022 14:34:17 +0000 (09:34 -0500)] 
cp: don’t create empty file if cannot clone

* src/copy.c (copy_reg): With --reflink=always, if FICLONE fails
on a file we just created, clean up by removing the file (Bug#56391).

3 years agomaint: fix comment typo
Ivan Radić [Sun, 3 Jul 2022 21:34:25 +0000 (23:34 +0200)] 
maint: fix comment typo

* src/uniq.c: s/preceges/precedes/

3 years agoshuf: better diagnostic for ‘shuf -i -10-10’
Paul Eggert [Fri, 24 Jun 2022 15:59:09 +0000 (10:59 -0500)] 
shuf: better diagnostic for ‘shuf -i -10-10’

* src/shuf.c: Do not include xdectoint.h.
(main): Improve diagnostic for ‘shuf -i -10-10’.  Without this
patch, the diagnostic was “shuf: invalid input range: ‘’” which is
not helpful.  Now it is “shuf: invalid input range: ‘-10-10’”.

3 years agocp: avoid -Wmaybe-uninitialized warning from GCC13
Jim Meyering [Thu, 23 Jun 2022 14:33:08 +0000 (07:33 -0700)] 
cp: avoid -Wmaybe-uninitialized warning from GCC13

* src/copy.c (infer_scantype): Always set scan_inference.ext_start,
to make the code match the comment.

3 years agomaint: remove unnecessary inclusion of hash.h
Jim Meyering [Thu, 23 Jun 2022 15:07:18 +0000 (08:07 -0700)] 
maint: remove unnecessary inclusion of hash.h

* src/cut.c: Don't include hash.h. The implementation was
changed not to need that in v8.21-43-g3e466ad05.

3 years agomaint: prefer POSIX-compatible EREs
Paul Eggert [Tue, 21 Jun 2022 03:19:59 +0000 (22:19 -0500)] 
maint: prefer POSIX-compatible EREs

* cfg.mk (begword, endword): New macros.
(sc_prohibit_stat_macro_address, sc_prohibit_fail_0)
(sc_prohibit_short_facl_mode_spec, sc_require_stdio_safer)
(sc_prohibit_sleep, sc_prohibit_framework_failure)
(sc_marked_devdiagnostics):
* build-aux/gen-single-binary.sh:
Prefer POSIX-compatible EREs to GNU extensions like \w and \<.

3 years agocp: fix ‘cp -rx / /mnt’
Paul Eggert [Sat, 11 Jun 2022 17:49:18 +0000 (10:49 -0700)] 
cp: fix ‘cp -rx / /mnt’

Problem reported by pkoraou@gmail.com (Bug#55910).
* src/copy.c (copy_internal): Treat a relative destination name ""
as if it were "." for the purpose of directory-relative syscalls
like fstatat that might might refer to the destination directory.

3 years agomaint: avoid \] in REs
Paul Eggert [Sat, 4 Jun 2022 02:25:59 +0000 (19:25 -0700)] 
maint: avoid \] in REs

* cfg.mk (sc_dd_max_sym_length, sc_prohibit_man_see_also_period):
Do not rely on undefined interpretation of \] in regular expressions.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 4 Jun 2022 00:32:18 +0000 (17:32 -0700)] 
build: update gnulib submodule to latest

* bootstrap: Copy from latest Gnulib.
* tests/misc/ls-misc.pl (v_files): Adjust to new Gnulib behavior.

3 years agomaint: fix spelling in NEWS entry
Bernhard Voelker [Thu, 26 May 2022 14:10:57 +0000 (16:10 +0200)] 
maint: fix spelling in NEWS entry

* NEWS: s/x86-64/x86_64/

3 years agomaint: spelling fix
Paul Eggert [Wed, 25 May 2022 18:49:13 +0000 (11:49 -0700)] 
maint: spelling fix

3 years agosort: tune diff_reversed
Paul Eggert [Wed, 25 May 2022 18:23:39 +0000 (11:23 -0700)] 
sort: tune diff_reversed

* src/sort.c (diff_reversed): Tune.  On x86-64 with GCC, this
saves a conditional branch and shortens the generated machine code.

3 years agosort: refactor tricky diff reversal
Paul Eggert [Wed, 25 May 2022 18:19:08 +0000 (11:19 -0700)] 
sort: refactor tricky diff reversal

* src/sort.c (diff_reversed): New function, to make the intent clearer.
(keycompare, compare): Use it.

3 years agomaint: sort.c: fix syntax-check issue in recent commit
Pádraig Brady [Wed, 25 May 2022 08:59:29 +0000 (09:59 +0100)] 
maint: sort.c: fix syntax-check issue in recent commit

* src/sort.c (keycompare): Avoid useless if before free()
as detected with sc_avoid_if_before_free.

3 years agosort: fix issue with -rk in previous commit
Pádraig Brady [Wed, 25 May 2022 08:45:57 +0000 (09:45 +0100)] 
sort: fix issue with -rk in previous commit

* src/sort.c (keycompare): Fix typo causing -r to be
effectively ignored with -k.
Fixes https://bugs.gnu.org/55622

3 years agosort: fix unlikely int overflow with -r
Paul Eggert [Wed, 18 May 2022 02:30:09 +0000 (19:30 -0700)] 
sort: fix unlikely int overflow with -r

* src/sort.c (keycompare, compare): Don’t overflow if -r is
specified and a comparison function returns INT_MIN, as this
causes the comparison to have undefined behavior (typically the
reverse of correct).  glibc memcmp on s390x reportedly returns
INT_MIN in some cases, so this is not a purely academic issue.

3 years agomaint: simplify comparisons
Paul Eggert [Wed, 18 May 2022 02:17:12 +0000 (19:17 -0700)] 
maint: simplify comparisons

* src/comm.c (compare_files):
* src/join.c (keycmp):
* src/ls.c (off_cmp):
* src/ptx.c (compare_words, compare_occurs):
* src/set-fields.c (compare_ranges):
Prefer ((a > b) - (a < b)) to variants like (a < b ? -1 : a > b)
as it’s typically faster these days.

3 years agosort: remove some gotos
Paul Eggert [Wed, 18 May 2022 01:55:43 +0000 (18:55 -0700)] 
sort: remove some gotos

* src/sort.c (keycompare): Rework to avoid gotos.
This also shrinks the machine code a bit (112 bytes)
with GCC 12 x86-64 -O2.  Nowadays compilers are smart
enough to coalesce jumps so we need not do it by hand.

3 years agosort: pacify GCC 12 false positive
Paul Eggert [Wed, 18 May 2022 01:39:16 +0000 (18:39 -0700)] 
sort: pacify GCC 12 false positive

* src/sort.c (keycompare): Rework to pacify a GCC 12
-Wmaybe-uninitialized false positive, by coalescing some minor
duplicate code and eliminating a branch.  This should execute an
insn or two less in the usual case.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 17 May 2022 22:50:58 +0000 (15:50 -0700)] 
build: update gnulib submodule to latest

3 years agofactor: --exponents: new option for printing in p^e format
Rasmus Villemoes [Wed, 27 Apr 2022 10:07:20 +0000 (12:07 +0200)] 
factor: --exponents: new option for printing in p^e format

When factoring numbers that have a large 2^n factor, it can be hard to
eyeball just how many 2's there are. Add an option to print each prime
power factor in the p^e format (omitting the exponent when it is 1).

* src/factor.c: Add -h, --exponents option for printing in p^e format.
* doc/coreutils.texi (factor invocation): Document the new option.
* tests/misc/factor.pl: Add test case.
* THANKS.in: Add previous suggester
(https://lists.gnu.org/r/coreutils/2017-11/msg00015.html).

Suggested-by: Emanuel Landeholm <emanuel.landeholm@gmail.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
3 years agotests: sort-NaN-infloop: augment testing for recent fix
Pádraig Brady [Mon, 2 May 2022 13:27:34 +0000 (14:27 +0100)] 
tests: sort-NaN-infloop: augment testing for recent fix

* tests/misc/sort-NaN-infloop.sh: Add test case from
https://unix.stackexchange.com/a/700967/37127
* src/sort.c: Avoid syntax-check failure.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 2 May 2022 16:05:44 +0000 (09:05 -0700)] 
build: update gnulib submodule to latest

3 years agosort: fix sort -g infloop again
Paul Eggert [Mon, 2 May 2022 05:46:21 +0000 (22:46 -0700)] 
sort: fix sort -g infloop again

Problem reported by Giulio Genovese (Bug#55212).
* src/sort.c (nan_compare): To compare NaNs, simply printf+strcmp.
This avoids the problem of padding bits and unspecified behavior.
Args are now long double instead of char *; caller changed.

3 years agomv: test Bug#55029
Paul Eggert [Thu, 21 Apr 2022 02:44:56 +0000 (19:44 -0700)] 
mv: test Bug#55029

* tests/mv/backup-dir.sh: New test for Bug#55029,
reported by Steve Ward.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Thu, 21 Apr 2022 02:36:44 +0000 (19:36 -0700)] 
build: update gnulib submodule to latest

3 years agopr: don’t use uninitialized var
Paul Eggert [Tue, 19 Apr 2022 23:13:55 +0000 (16:13 -0700)] 
pr: don’t use uninitialized var

Found with -flto and --enable-gcc-warnings.
* src/pr.c (getoptarg): Fix misuse of xstrtol, which does not
necessarily set tmp_long on errror, and does not set errno in any
reliable way.  The previous code might access uninitialized
storage; on typical platforms this merely causes it to possibly
print the wrong diagnostic.

3 years agodoc: fix ' and ` in PDF output of code
Paul Eggert [Tue, 19 Apr 2022 20:38:17 +0000 (13:38 -0700)] 
doc: fix ' and ` in PDF output of code

* doc/coreutils.texi: Set txicodequoteundirected and
txicodequotebacktick so that ' and ` in code examples appear
as-is, rather than being transliterated to ’ and ‘.  E.g., prefer
“... this is equivalent to ‘tr '\303\266' '\305\201'’ and ...” to
“... this is equivalent to ‘tr ’\303\266’ ’\305\201’’ and ...”
in PDF output.

3 years agodoc: fix footnote formats
Paul Eggert [Tue, 19 Apr 2022 20:28:15 +0000 (13:28 -0700)] 
doc: fix footnote formats

* doc/coreutils.texi: Reword footnote, or put it right next
to previous punctuation.

3 years agodoc: prefer ö to $'\u7530'
Paul Eggert [Tue, 19 Apr 2022 20:24:42 +0000 (13:24 -0700)] 
doc: prefer ö to $'\u7530'

* doc/coreutils.texi (Character arrays): Avoid using shell
notation like $'\u7530' since this isn’t in POSIX yet. Instead,
use ö and Ł which should work in all texinfo output formats.

3 years agodoc: rmdir: clarify --ignore-fail-on-non-empty operation
Pádraig Brady [Sun, 17 Apr 2022 12:11:09 +0000 (13:11 +0100)] 
doc: rmdir: clarify --ignore-fail-on-non-empty operation

This option has changed from ignoring only ENOTEMPTY|EEXIST
(i.e. ignore errors _solely_ due to dir not empty),
to ignoring some other errors from more protected dirs
that are not empty.  That adjustment was made to better
support use with --parents, to essentially remove as much of
a hierarchy as possible, without erroring as we hit more
protected non empty parent dirs.
That functionality adjustment was originally discussed at:
https://lists.gnu.org/r/bug-coreutils/2008-01/msg00283.html

* src/rmdir.c (usage): Adjust to be more accurate to current behavior.
Also adjust --parents option to be easier to read.
* doc/coreutils.texi (rmdir invocation): Likewise.
Reported at https://github.com/coreutils/coreutils/issues/40

3 years agomaint: post-release administrivia
Pádraig Brady [Fri, 15 Apr 2022 21:40:41 +0000 (22:40 +0100)] 
maint: post-release administrivia

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

3 years agoversion 9.1 v9.1
Pádraig Brady [Fri, 15 Apr 2022 21:10:07 +0000 (22:10 +0100)] 
version 9.1

* NEWS: Record release date.

3 years agodoc: avoid unicode errors in texi conversion
Pádraig Brady [Fri, 15 Apr 2022 17:01:32 +0000 (18:01 +0100)] 
doc: avoid unicode errors in texi conversion

Avoid "Unicode character U+#1 not supported, sorry" error
when converting from texi to dvi or pdf.

* doc/coreutils.texi (tr invocation): Avoid the @U{XXXX}
texi representation, as even though info and html can represent
these characters directly, there are conversion errors
for pdf and dvi.  Instead use the more abstract shell
$'\uXXXX' representation.

3 years agobuild: copy: fix build on macos 10.12
Pádraig Brady [Thu, 14 Apr 2022 12:35:22 +0000 (13:35 +0100)] 
build: copy: fix build on macos 10.12

* src/copy.c (copy_reg): Handle the case where CLONE_NOOWNERCOPY
is not defined.
Reported by Jeffrey Walton

3 years agotail: detect closed stdout on Solaris
Pádraig Brady [Wed, 13 Apr 2022 16:31:47 +0000 (17:31 +0100)] 
tail: detect closed stdout on Solaris

* src/tail.c (check_output_alive): Use poll() on Solaris.
Also handle POLLHUP, which Solaris returns in this case.
* tests/tail-2/pipe-f.sh: Use `head -n2` rather than `sed 2q`
as Solaris sed does not exit in this case.
* NEWS: Mention the improvement.
Reported by Bruno Haible.

3 years agomaint: syntax-check: fix preprocessor indentation
Pádraig Brady [Wed, 13 Apr 2022 11:19:16 +0000 (12:19 +0100)] 
maint: syntax-check: fix preprocessor indentation

* gl/lib/targetdir.h: Keep '#' at start of line.

3 years agocp,mv,install: omit an ‘inline’
Paul Eggert [Wed, 13 Apr 2022 06:56:41 +0000 (23:56 -0700)] 
cp,mv,install: omit an ‘inline’

* gl/lib/targetdir.c (target_directory_operand):
Omit unnecessary ‘inline’.

3 years agocp,mv,install: improve EACCES targetdir messages
Paul Eggert [Wed, 13 Apr 2022 06:56:41 +0000 (23:56 -0700)] 
cp,mv,install: improve EACCES targetdir messages

This improves on the fix for --target-directory diagnostics bugs on
Solaris 11.  Problem reported by Bruno Haible and Pádraig Brady; see:
https://lists.gnu.org/r/coreutils/2022-04/msg00044.html
Also, omit some unnecessary stat calls.
* gl/lib/targetdir.c (target_directory_operand): If !O_DIRECTORY,
do not bother calling open if stat failed with errno != EOVERFLOW.
Rename is_a_dir to try_to_open since that’s closer to what it means.
If the open failed with EACCES and we used O_SEARCH, look at stat
results to see whether errno should be ENOTDIR for better diagnostics.
Treat EOVERFLOW as an “I don’t know whether it’s a directory and
there’s no easy way to find out” rather than as an error.

3 years agocp,mv,install: avoid excess stat calls on non-GNU
Paul Eggert [Wed, 13 Apr 2022 06:56:41 +0000 (23:56 -0700)] 
cp,mv,install: avoid excess stat calls on non-GNU

* gl/lib/targetdir.c (target_directory_operand): New arg ST.
All callers changed.
* src/cp.c (do_copy):
* src/mv.c (main):
Avoid unnecessary stat call if target_directory_operand already
got the status.

3 years agocp,mv,install: modularize targetdir
Paul Eggert [Wed, 13 Apr 2022 06:56:41 +0000 (23:56 -0700)] 
cp,mv,install: modularize targetdir

Move target directory code out of system.h to a new targetdir module.
This doesn’t change functionality.
* bootstrap.conf (gnulib_modules): Add targetdir.
* src/cp.c, src/install.c, src/mv.c: Include targetdir.h.
* src/system.h (must_be_working_directory, target_directory_operand)
(targetdir_dirfd_valid): Move from here ...
* gl/lib/targetdir.c, gl/lib/targetdir.h, gl/modules/targetdir:
... to these new files.

3 years agocp,mv,install: avoid EACCES with non directory destination
Pádraig Brady [Sun, 10 Apr 2022 15:59:40 +0000 (16:59 +0100)] 
cp,mv,install: avoid EACCES with non directory destination

* src/system.h (target_directory_operand): Also check with stat()
on systems with O_SEARCH, to avoid open("file", O_SEARCH|O_DIRECTORY)
returning EACCES rather than ENOTDIR, which was seen on Solaris 11.4
when operating on non dirs without execute bit set.
* NEWS: Remove related bug entry, as that issue was only introduced
after coreutils v9.0 was released.
Reported by Bruno Haible.

3 years agosync: support syncing files on cygwin
Pádraig Brady [Tue, 12 Apr 2022 11:04:38 +0000 (12:04 +0100)] 
sync: support syncing files on cygwin

* src/sync.c (sync_arg): Similarly to AIX, Cygwin 2.9.0
was seen to need write access to have permission to sync a file.

3 years agotests: cygwin: handle ENOENT from execvp(".")
Pádraig Brady [Tue, 12 Apr 2022 11:31:01 +0000 (12:31 +0100)] 
tests: cygwin: handle ENOENT from execvp(".")

* tests/misc/env.sh: Verify with another command that
execvp() doesn not return ENOENT, before testing the
exit code from the command in question.
* tests/misc/nice-fail.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/timeout-parameters.sh: Likewise.

3 years agotests: env-S.pl: unset cygwin hardwired env vars
Pádraig Brady [Tue, 12 Apr 2022 11:50:40 +0000 (12:50 +0100)] 
tests: env-S.pl: unset cygwin hardwired env vars

* tests/misc/env-S.pl: Unset SYSTEMROOT and WINDIR.

3 years agotests: md5sum: fix false failures on cygwin
Pádraig Brady [Mon, 11 Apr 2022 14:37:04 +0000 (15:37 +0100)] 
tests: md5sum: fix false failures on cygwin

* tests/misc/md5sum-newline.pl: Avoid binary '*' tags when
comparing checksums.
* tests/misc/md5sum-bsd.sh: Avoid binary '*' tags so that we correctly
trigger the ambiguity test.
Reported by Bruno Haible

3 years agotests: b2sum.sh: fix false failure on cygwin
Pádraig Brady [Mon, 11 Apr 2022 14:37:04 +0000 (15:37 +0100)] 
tests: b2sum.sh: fix false failure on cygwin

* tests/misc/b2sum.sh: Avoid binary '*' tags when comparing checksums.
Reported by Bruno Haible

3 years agotests: dircolors.pl: avoid false failure with TERM=dumb
Pádraig Brady [Mon, 11 Apr 2022 13:17:59 +0000 (14:17 +0100)] 
tests: dircolors.pl: avoid false failure with TERM=dumb

* tests/Coreutils.pm: Ensure an unset $TERM env var,
which is required on perl 5.22.2 on Solaris 11 OpenIndiana at least,
where TERM was being reset to 'dumb'.
Reported By Bruno Haible.

3 years agotests: printf-mb.sh: fix false failure with french translations
Pádraig Brady [Mon, 11 Apr 2022 12:47:44 +0000 (13:47 +0100)] 
tests: printf-mb.sh: fix false failure with french translations

* tests/misc/printf-mb.sh: As per commit 04148c99c,
adjust non C warnings before comparison, to those of LC_MESSAGES=C.
Reported by Adam Sampson

3 years agotests: stty.sh: skip on systems without perl
Pádraig Brady [Sun, 10 Apr 2022 14:47:52 +0000 (15:47 +0100)] 
tests: stty.sh: skip on systems without perl

* init.cfg (stty_reversible_init_): Add require_perl_
to ensure we skip rather than error, without perl.

3 years agocp,mv,install: avoid opening non directory destination
Pádraig Brady [Sat, 9 Apr 2022 14:46:52 +0000 (15:46 +0100)] 
cp,mv,install: avoid opening non directory destination

commit v9.0-66-ge2daa8f79 introduced an issue, for example
where cp could hang when overwriting a destination fifo,
when it would try to open() the fifo on systems
like Solaris 10 that didn't support the O_DIRECTORY flag.

This is still racy on such systems, but only in the
case where a directory is replaced by a fifo in
the small window between stat() and open().

* src/system.h (target_directory_operand): On systems without
O_DIRECTORY, ensure the file is a directory before attempting to open().
* tests/cp/special-f.sh: Protect cp with timeout(1),
as cp was seen to hang when trying to overwrite an existing fifo.
* NEWS: Mention the bug fix.

3 years agodoc: install --compare: clarify mode of operation
Pádraig Brady [Sat, 9 Apr 2022 11:42:37 +0000 (12:42 +0100)] 
doc: install --compare: clarify mode of operation

* doc/coreutils.texi (install invocation): For the --compare option,
clarify that the ownership or permissions of the source files don't
matter.  Also don't imply --owner or --group need to be specified
for --compare to be effective.
* src/install.c (usage): Add more detail on what's being compared.
Fixes https://bugs.gnu.org/50889

3 years agodoc: remove older ChangeLog items
Pádraig Brady [Fri, 8 Apr 2022 16:08:32 +0000 (17:08 +0100)] 
doc: remove older ChangeLog items

* Makefile.am: Update the oldest documented version
to 8.27 which is now about 5 years old.

3 years agomaint: remove obsolete statat gnulib module
Bernhard Voelker [Thu, 7 Apr 2022 16:59:16 +0000 (18:59 +0200)] 
maint: remove obsolete statat gnulib module

* bootstrap.conf (gnulib_modules): Remove statat.

3 years agobuild: update gnulib submodule to latest
Pádraig Brady [Thu, 7 Apr 2022 16:19:37 +0000 (17:19 +0100)] 
build: update gnulib submodule to latest

* gnulib: Update to latest
* src/copy.c: Replace deprecated {l,}statat(), with fstatat().
* src/cp.c: Likewise.
* src/install.c: Likewise.
* src/remove.c: Likewise.

3 years agofactor: improve support on RISCV and loongson
Pádraig Brady [Mon, 4 Apr 2022 12:41:32 +0000 (13:41 +0100)] 
factor: improve support on RISCV and loongson

* src/longlong.h: Pull in RISCV fix and loongarch64 support from
https://gmplib.org/repo/gmp/log/tip/longlong.h

3 years agodoc: describe `dd iseek` as a feature not a change
Pádraig Brady [Sun, 3 Apr 2022 21:11:25 +0000 (22:11 +0100)] 
doc: describe `dd iseek` as a feature not a change

* NEWS: Move description from "Changes in behavior"
to "New features".

3 years agols: avoid expensive capability lookup by default
Pádraig Brady [Sun, 3 Apr 2022 20:42:42 +0000 (21:42 +0100)] 
ls: avoid expensive capability lookup by default

Lookup of file-based capabilities adds 30% overhead to the common
case of ls --color usage.  Since the use of file capabilities is
very rare, it doesn't make sense to pay this cost in the common
case.  It's better to use getcap to inspect capabilities, and the
following run shows only 8 files using capabilities on my fedora
35 distro (14 years after the feature was introduced to the linux
kernel).

  $ getcap -r /
  /usr/bin/arping = cap_net_raw+p
  /usr/bin/clockdiff = cap_net_raw+p
  /usr/bin/gnome-keyring-daemon = cap_ipc_lock+ep
  /usr/bin/gnome-shell = cap_sys_nice+ep
  /usr/bin/newgidmap = cap_setgid+ep
  /usr/bin/newuidmap = cap_setuid+ep
  /usr/sbin/mtr-packet = cap_net_raw+ep
  /usr/sbin/suexec = cap_setgid,cap_setuid+ep

* src/dircolors.hin: Set "CAPABILITY" to "00", to indicate unused.
* src/ls.c: Set the default C_CAP color to not colored.
* NEWS: Mention the change in behavior.

3 years agodircolors: colorize backup files with bright black
Ville Skyttä [Tue, 22 Mar 2022 18:24:27 +0000 (20:24 +0200)] 
dircolors: colorize backup files with bright black

* src/dircolors.hin: Add patterns for suffixes for "backup files".
The color used is so they stand out less than non-backup files,
and bright black works well on both light and dark backgrounds.
* THANKS.in: Remove duplicate.
Fixes https://bugs.gnu.org/54521

3 years agodoc: join: clarify that -e only effective for -12jo fields
Pádraig Brady [Tue, 29 Mar 2022 15:34:10 +0000 (16:34 +0100)] 
doc: join: clarify that -e only effective for -12jo fields

* src/join.c (usage): Clarify that -e is not sufficient
to enable output of missing fields from one of the inputs.
Rather the -12jo options are required to explicitly
enable output of those fields.
Fixes https://bugs.gnu.org/54625

3 years agomaint: sync latest bootstrap from gnulib
Pádraig Brady [Fri, 25 Mar 2022 19:08:28 +0000 (19:08 +0000)] 
maint: sync latest bootstrap from gnulib

* bootstrap: Should have updated this with the last gnulib update.

3 years agotests: improve recent printf test
Pádraig Brady [Sun, 20 Mar 2022 17:46:13 +0000 (17:46 +0000)] 
tests: improve recent printf test

* tests/misc/printf-mb.sh: Given we shortcut the single char
(invalid multi-byte) case, add a case to ensure we're correctly
checking the return from mbrtowc().

3 years agoprintf: support printing the numeric value of multi-byte chars
Pádraig Brady [Fri, 18 Mar 2022 14:52:36 +0000 (14:52 +0000)] 
printf: support printing the numeric value of multi-byte chars

* src/printf.c (STRTOX): Update to support multi-byte chars.
* tests/misc/printf-mb.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/54388

3 years agomaint: move build-related NEWS item to its own section
Pádraig Brady [Fri, 18 Mar 2022 15:02:42 +0000 (15:02 +0000)] 
maint: move build-related NEWS item to its own section

* NEWS: Follow other Build-related patterns in NEWS.

3 years agodoc: test: clarify that -rwx don't just check perm bits
Pádraig Brady [Fri, 11 Mar 2022 12:47:05 +0000 (12:47 +0000)] 
doc: test: clarify that -rwx don't just check perm bits

* src/test.c (usage): State that -rwx is determined by
user access, rather than permission bits.
* doc/coreutils.texi (Access permission tests): Likewise.
* man/test.x [SEE ALSO]: access(2).
Fixes https://bugs.gnu.org/54338

3 years agomaint: address syntax-check issues in recent commit
Pádraig Brady [Mon, 7 Mar 2022 22:39:32 +0000 (22:39 +0000)] 
maint: address syntax-check issues in recent commit

* cfg.mk (sc_die_EXIT_FAILURE): Generalize to match any EXIT_ define,
and also relax to ignore error() usage with ternary operator.
* src/chroot.c (main): Use () to avoid the sc_error_quotes check.

3 years agostat: only automount with --cached=never
Pádraig Brady [Mon, 7 Mar 2022 23:29:20 +0000 (23:29 +0000)] 
stat: only automount with --cached=never

Revert to the default behavior before the introduction of statx().

* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never.
* doc/coreutils.texi (stat invocation): Mention the automount
behavior with --cached=never.
* NEWS: Mention the change in behavior.

Fixes https://bugs.gnu.org/54287

3 years agols: avoid triggering automounts
Rohan Sable [Mon, 7 Mar 2022 14:14:13 +0000 (14:14 +0000)] 
ls: avoid triggering automounts

statx() has different defaults wrt automounting
compared to stat() or lstat(), so explicitly
set the AT_NO_AUTOMOUNT flag to suppress that behavior,
and avoid unintended operations or potential errors.

* src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/54286

Signed-off-by: Rohan Sable <rsable@redhat.com>
3 years agobuild: ensure AT_NO_AUTOMOUNT is defined
Pádraig Brady [Mon, 7 Mar 2022 22:00:22 +0000 (22:00 +0000)] 
build: ensure AT_NO_AUTOMOUNT is defined

update gnulib submodule to latest,
where this is the only change

3 years agodate: fix newly-introduced %%-N bug
Paul Eggert [Sat, 5 Mar 2022 19:23:01 +0000 (11:23 -0800)] 
date: fix newly-introduced %%-N bug

* src/date.c (adjust_resolution): Don’t mishandle %%-N.
* tests/misc/date.pl (pct-pct): New test.

3 years agochown: warn about USER.GROUP
Paul Eggert [Fri, 25 Feb 2022 02:17:23 +0000 (18:17 -0800)] 
chown: warn about USER.GROUP

Suggested by Dan Jacobson (Bug#44770).
* src/chown.c, src/chroot.c (main):
Issue warnings if obsolete USER.GROUP notation is present.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 25 Feb 2022 02:05:03 +0000 (18:05 -0800)] 
build: update gnulib submodule to latest

3 years agofmt: fix invalid multi-byte splitting on macOS
Pádraig Brady [Wed, 23 Feb 2022 17:50:46 +0000 (17:50 +0000)] 
fmt: fix invalid multi-byte splitting on macOS

On macOS, isspace(0x85) returns true,
which results in splitting within multi-byte characters.

* src/fmt.c (get_line): s/isspace/c_isspace/.
* tests/fmt/non-space.sh: Add a new test.
* tests/local.mk: Reference new test.
* NEWS: Mention the fix.
Addresses https://bugs.gnu.org/54124