Chris Meyering [Thu, 30 Jan 2020 06:34:48 +0000 (22:34 -0800)]
build: rearrange yes(1) code to prevent GCC 10 warning
* src/yes.c (main): Convert for loop to do-while in order to indicate
that the loop will be run at least once.
This avoids the following warning after the second loop:
src/yes.c:110:20: error: writing 1 byte into a region of size 0
Pádraig Brady [Wed, 1 Jan 2020 17:43:53 +0000 (17:43 +0000)]
build: auto enable use of openssl with >= version 3
* configure.ac: Set --with-openssl=auto-gpl-compat as the default,
so that openssl is used for md5sum etc., with openssl >= 3,
which is newly licensed under ASL v2.
* gnulib: Update to include "auto-gpl-compat" support.
Pádraig Brady [Wed, 1 Jan 2020 14:16:56 +0000 (14:16 +0000)]
maint: update all copyright year number ranges
Run "make update-copyright" and then...
* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
doc: add example to demonstrate sub-second sleep times
* doc/coreutils.texi (sleep invocation): Add an example to demonstrate
how to use the floating-point and the scientific notation to sleep
for sub-second times, e.g. milli-, micro- and nanoseconds.
Inspired by Stephane Chazelas in:
https://lists.gnu.org/r/coreutils/2019-12/msg00005.html
Paul Eggert [Tue, 12 Nov 2019 00:53:49 +0000 (16:53 -0800)]
doc: remove colon from node name
* doc/sort-version.texi (Minus/Hyphen and Colon characters):
Rename from “Minus/Hyphen @samp{-} and Colon @samp{:} characters”,
as texi2any 6.6 complains about colons in node names.
Paul Eggert [Tue, 12 Nov 2019 00:52:47 +0000 (16:52 -0800)]
shred: modernize documentation
* doc/coreutils.texi (shred invocation):
Modernize discussion to today’s technology (Bug#38168).
* src/shred.c (usage): Omit lengthy duplication of the manual’s
discussion of file systems and storage devices, as that became out
of sync with the manual. Instead, just cite the manual.
Paul Eggert [Tue, 22 Oct 2019 21:55:24 +0000 (14:55 -0700)]
all: improve parsing of numeric arguments
This addresses a longstanding "update all callers" FIXME in
lib/xstrtol.c, by having programs check that numbers do not
have unknown suffixes. The problem was also reported for
'shuf' by my student Maggie Huang while reimplementing a shuf
subset in Python as an exercise in UCLA Computer Science 35L:
https://web.cs.ucla.edu/classes/fall19/cs35L/assign/assign3.html
This patch also improves the portability of the code to unusual
platforms where ULONG_MAX < SIZE_MAX.
* NEWS: Mention user-visible changes.
* src/chgrp.c (parse_group):
* src/chroot.c (parse_additional_groups):
* src/du.c (main):
* src/install.c (get_ids):
* src/join.c (string_to_join_field):
* src/ls.c (decode_switches):
* src/md5sum.c (split_3):
* src/shuf.c (main):
* src/sort.c (specify_nthreads):
* src/uniq.c (size_opt, main):
Use uintmax_t instead of unsigned long, for portability
to oddball platforms where unsigned long is not wide enough.
* src/du.c (main):
* src/expr.c (mpz_init_set_str) [!HAVE_GMP]:
* src/install.c (get_ids):
* src/ls.c (decode_switches):
* src/mknod.c (main):
* src/ptx.c (main):
* src/shuf.c (main):
* src/sort.c (specify_nmerge, specify_nthreads):
Reject numbers with suffixes.
* src/md5sum.c (split_3): Simplify.
Paul Eggert [Tue, 22 Oct 2019 19:58:07 +0000 (12:58 -0700)]
shuf: improve randperm overflow checking
* gl/lib/randperm.c: Include randperm.h first, since it’s the API.
Include stdint.h, count-leading-zeros.h, verify.h.
(floor_lg): Rename from ceil_log (which was not actually
implementing the ceiling!) and implement the floor using
count_leading_zeros.
(randperm_bound): Use floor_lg, not ceil_log. Use uintmax_t
instead of size_t in case the size gets large on a 32-bit host.
* gl/modules/randperm (Depends-on): Add count-leading-zeros, stdint.
Paul Eggert [Tue, 22 Oct 2019 18:34:56 +0000 (11:34 -0700)]
build: re-enable type-limits checking
* configure.ac: When --enable-gcc-warnings is used, omit
-Wno-type-limits. The need for -Wno-type-limits has passed, now
that intprops.h uses builtin primitives for GCC 5 and later, given
that recent GCCs issue type-limits warnings only for non-constant
expressions. --enable-gcc-warnings is not intended for use with
old compilers, so we can drop -Wno-type-limits now.
Paul Eggert [Mon, 21 Oct 2019 20:03:46 +0000 (13:03 -0700)]
shuf: fix bug with ‘-r -n 0’
‘shuf -r -n 0 file’ would mistakenly read from standard input.
Problem reported by my student Jingnong Qu while reimplementing a
shuf subset in Python as an exercise in UCLA Computer Science 35L:
https://web.cs.ucla.edu/classes/fall19/cs35L/assign/assign3.html
* NEWS: Mention the fix. Also, ASCIIfy a previous item.
* src/shuf.c (main): Fix bug.
* tests/misc/shuf.sh: Add a test case for the bug.
Jeff Layton [Thu, 19 Sep 2019 15:59:45 +0000 (11:59 -0400)]
ls: use statx instead of stat when available
statx allows ls to indicate interest in only certain inode metadata.
This is potentially a win on networked/clustered/distributed
file systems. In cases where we'd have to do a full, heavyweight stat()
call we can now do a much lighter statx() call.
As a real-world example, consider a file system like CephFS where one
client is actively writing to a file and another client does an
ls --color in the same directory. --color means that we need to fetch
the mode of the file.
Doing that with a stat() call means that we have to fetch the size and
mtime in addition to the mode. The MDS in that situation will have to
revoke caps in order to ensure that it has up-to-date values to report,
which disrupts the writer.
This has a measurable affect on performance. I ran a fio sequential
write test on one cephfs client and had a second client do "ls --color"
in a tight loop on the directory that held the file:
* src/stat.c: move statx to stat struct conversion to new header...
* src/statx.h: ...here.
* src/ls.c: Add wrapper functions for stat/lstat/fstat calls,
and add variants for when we are only interested in specific info.
Add statx-enabled functions and set the request mask based on the
output format and what values are needed.
* NEWS: Mention the Improvement.
Paul Eggert [Thu, 3 Oct 2019 19:41:22 +0000 (12:41 -0700)]
truncate: avoid integer-overflow assumptions
* src/truncate.c (do_ftruncate): Simplify overflow checking,
and don’t rely on theoretically-nonportable assumptions
like assuming that OFF_MAX < UINTMAX_MAX.
seq: use faster processing for integer steps from 2 to 200
* src/seq.c: (seq_fast): Accept STEP as a parameter and use that
to skip the output of generated numbers.
(main): Relax to using seq_fast for integer steps between 1 and 200.
For larger steps the throughput was faster using the standard
incrementing procedure.
(cmp): Use the equivalent but faster memcmp for equal len strings.
* tests/misc/seq.pl: Update fast path cases.
Addresses https://bugs.gnu.org/37241
The previous commit introduced a bug into the following syntax-check,
and thus effectively turned it off:
$ make sc_prohibit_test_calls_print_ver_with_irrelevant_argument; \
echo $?
prohibit_test_calls_print_ver_with_irrelevant_argument
fatal: cannot change to 'grep': No such file or directory
0
* cfg.mk (sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
Remove changing directory, and pass $(srcdir) as argument to 'git -C'.
Akim Demaille [Sun, 4 Aug 2019 18:02:01 +0000 (11:02 -0700)]
maint: fix issues in syntax-check
* cfg.mk (sc_prohibit_colon_redirection): Don't expect `|` to denote
the pipe character in git grep.
(sc_tests_executable)
(sc_case_insensitive_file_names)
(sc_some_programs_must_avoid_exit_failure)
(sc_prohibit_test_background_without_cleanup_)
(sc_prohibit_test_calls_print_ver_with_irrelevant_argument)
(sc_prohibit_test_ulimit_without_require_)
(sc_prohibit_test_background_without_cleanup_)
(sc_THANKS_in_duplicates)
*sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
Don't expect builddir to be a descendant of srcdir.
(sc_strftime_check): Don't check file size against 0 when "N\nq\n" was
already put in the file.
* THANKS.in: Remove me.
This is due to the "print_extra_number" logic using strings to determine
whether a 'extra number' is needed, but only one string was trimmed
when using a custom printf format.
Prompted by https://lists.gnu.org/r/coreutils/2019-08/msg00001.html
* NEWS: Mention fix.
* src/seq.c (print_numbers): Trim the 'x0_str' string before comparing
it to the previous 'x_str' string.
* tests/misc/seq-extra-number.sh: Add this scenario.
* tests/local.mk (all_tests): Add new test.
Bernhard Voelker [Fri, 19 Jul 2019 00:11:03 +0000 (02:11 +0200)]
doc: improve new version sort chapter
* doc/sort-version.texi: Fix some typos, avoid overly long lines in
the generated PDF, enclose some sample strings in @samp{...} for better
readability, etc. This also avoids an sc-avoid-builtin error:
s/builtin/built-in/
Assaf Gordon [Wed, 10 Jul 2019 01:36:10 +0000 (19:36 -0600)]
doc: add "version sort ordering" chapter
* doc/sort-version.texi: New file.
* doc/local.mk (doc_coreutils_TEXINFOS): Add new file.
* doc/coreutils.texi: @include new file, replace previous "Details about
version sort" section.
Andreas Dilger [Thu, 27 Jun 2019 08:25:55 +0000 (02:25 -0600)]
stat: don't explicitly request file size for filenames
When calling 'stat -c %N' to print the filename, don't explicitly
request the size of the file via statx(), as it may add overhead on
some filesystems. The size is only needed to optimize an allocation
for the relatively rare case of reading a symlink name, and the worst
effect is a somewhat-too-large temporary buffer may be allocated for
areadlink_with_size(), or internal retries if buffer is too small.
The file size will be returned by statx() on most filesystems, even
if not requested, unless the filesystem considers this to be too
expensive for that file, in which case the tradeoff is worthwhile.
* src/stat.c: Don't explicitly request STATX_SIZE for filenames.
Paul Eggert [Thu, 20 Jun 2019 01:46:57 +0000 (18:46 -0700)]
od: use fseek on non-regular files
Problem reported by Szőts Ákos (Bug#36291).
* NEWS: Mention this.
* src/od.c (skip): Try fseek even on files that do not have usable
sizes, falling back on fread if fseek fails.
Assaf Gordon [Mon, 13 May 2019 22:37:40 +0000 (16:37 -0600)]
tests: avoid false-positive in date-debug test
When debugging an invalid date due to DST switching, the intermediate
'normalized time' should not be checked - its value can differ between
systems (e.g. glibc vs musl).
Reported by Niklas Hambüchen in
https://lists.gnu.org/r/coreutils/2019-05/msg00031.html
Analyzed by Rich Felker in
https://lists.gnu.org/r/coreutils/2019-05/msg00039.html
* tests/misc/date-debug.sh: Replace the exact normalized time
with 'XX:XX:XX' so different values would not trigger test failure.
Jeff Layton [Tue, 28 May 2019 12:21:42 +0000 (08:21 -0400)]
stat: Use statx where available and support --cached
* src/stat.c: Drop statbuf argument from out_epoch_sec().
Use statx() rather than [lf]stat() where available,
so a separate call is not required to get birth time.
Set STATX_* mask bits only for things we want to print,
which can be more efficient on some file systems.
Add a new --cache= command-line option that sets the appropriate hint
flags in the statx call. These are primarily used with network
file systems to indicate what level of cache coherency is desired.
The new option is available unconditionally for better portability,
and ignored where not implemented.
* doc/coreutils.texi: Add documention for --cached.
* man/stat.x (SEE ALSO): Mention statx().
* NEWS: Mention the new feature.
Pádraig Brady [Sat, 8 Jun 2019 21:49:01 +0000 (22:49 +0100)]
split: fix failure for certain number of specified files
* src/split.c (set_suffix_length): Use a more standard
zero based logN calculation for the number of units.
* tests/split/suffix-auto-length.sh: Add a test case.
* THANKS.in: Mention the reporter.
* NEWS: Mention the fix.
Fixes https://bugs.gnu.org/35291
Paul Eggert [Thu, 30 May 2019 20:53:54 +0000 (13:53 -0700)]
dd: be more careful about signal handling
Problem reported by Hans Henrik Bergan (Bug#36007).
* NEWS: Mention this.
* src/dd.c (iclose, ifdatasync, ifstat, ifsync):
New functions, which are more careful about SIGINT.
(cleanup): Use iclose instead of close.
(finish_up): Process signals first.
(skip, dd_copy, main): Use ifstat instead of fstat.
(dd_copy): Use ifdatasync and ifsync instead of fdatasync and fsync.
Paul Eggert [Tue, 28 May 2019 19:42:24 +0000 (12:42 -0700)]
cp: fix /dev/stdin problem on Solaris
Problem reported by Jakub Kulik (Bug#35713).
* NEWS: Mention this.
* configure.ac (DEV_FD_MIGHT_BE_CHR): New macro.
* src/copy.c (DEV_FD_MIGHT_BE_CHR): Default to false.
(follow_fstatat): New function.
(copy_internal): Use it.
* src/copy.h (XSTAT): Remove; no longer used.
Kevin Locke [Thu, 23 May 2019 03:07:50 +0000 (21:07 -0600)]
doc: clarify dd sparse detection is by *output* block
The wording of the dd --help text suggests that output will be skipped
for sparse *input* blocks (i.e. that NUL-checking is done on input
blocks) while the code actually checks/skips all-NUL *output* blocks.[1]
* src/dd.c (usage): Update the --help text to clarify the above.
* tests/dd/sparse.sh: Ensure sparseness is controlled with obs.
Paul Eggert [Wed, 15 May 2019 19:42:23 +0000 (12:42 -0700)]
b2sum: port to HP-UX aCC
Its support for the -include option is flaky. Problem reported by
Michael Osipov (Bug#35650). Plus, we could run into other
compilers that don’t support any option like -include. Change the
code so that -include is not needed. Although this causes us to
depart from the upstream version, we’re already doing that for
other reasons.
* configure.ac (USE_XLC_INCLUDE): Remove, as there’s no
guarantee a compiler will support something like -include.
* src/blake2/b2sum.c [HAVE_CONFIG_H]: Include <config.h>.
* src/local.mk (src_b2sum_CPPFLAGS): Add -DHAVE_CONFIG_H.
Do not use -include or a substitute.
Paul Eggert [Tue, 14 May 2019 16:20:56 +0000 (09:20 -0700)]
stdbuf: port configure-time checking to HP-UX aCC
Problem reported by Michael Osipov (Bug#35650).
* configure.ac: Use AC_LANG_WERROR to pay attention to compiler
and linker warnings when testing whether stdbuf will work.
Paul Eggert [Sat, 11 May 2019 20:48:16 +0000 (13:48 -0700)]
b2sum: port to HP-UX C
* src/blake2/blake2.h (BLAKE2_PACKED):
Don’t assume __attribute__ ((packed)) works on non-Microsoft
compilers. Instead, assume it works only if we have good
reason to assume so, and fall back on Microsoft (or not packing)
otherwise. In practice, not packing is good enough and the
BLAKE2_PACKED macro is mostly just for documentation.
Paul Eggert [Sat, 11 May 2019 20:01:37 +0000 (13:01 -0700)]
basenc: port to C99
* src/basenc.c: Various minor style cleanups.
(struct base_decode_context): Do not use anonymous unions, as
they’re not in C99. Use a named union instead. All uses changed.
Paul Eggert [Sat, 11 May 2019 16:32:04 +0000 (09:32 -0700)]
maint: adjust to recent verify_true removal
* src/system.h (X2NREALLOC, X2REALLOC, DECIMAL_DIGIT_ACCUMULATE):
Use verify_expr instead of verify_true, which has been removed.
(DECIMAL_DIGIT_ACCUMULATE): Remove unnecessary size check.
Shugo Maeda [Sun, 31 Mar 2019 22:43:58 +0000 (15:43 -0700)]
factor: output immediately if stdout is a tty but stdin is not
* src/factor.c (lbuf_putc): Use line buffered mode if the standard
output is a terminal in the same way as the stdio library.
User programs might use pty only for the standard out
like the example of Ruby's PTY module:
https://docs.ruby-lang.org/en/2.6.0/PTY.html#module-PTY-label-Example
* NEWS: Mention the fix.
Fixes https://bugs.gnu.orv/35046
Paul Eggert [Sun, 17 Mar 2019 20:20:42 +0000 (13:20 -0700)]
ln: port to symlink ("x", ".") failing with EINVAL
Problem reported by John Marino (Bug#34894).
* src/ln.c (main): Port ln -s to Solaris symlink function,
where symlink ("x", ".") fails with errno == EINVAL.
Pádraig Brady [Sun, 10 Mar 2019 07:48:06 +0000 (23:48 -0800)]
tests: test-N: include subsecond values in gating check
* tests/misc/test-N.sh: The subsecond values for atime and mtime
were potentially seen to differ on newlyl created files.
So we include the subsecond portion when comparing stat values.
Pádraig Brady [Sun, 10 Mar 2019 04:40:34 +0000 (20:40 -0800)]
tests: wc-nbsp: fix false failures on various systems
* tests/misc/wc-nbsp.sh: Add gating checks for all characters,
as there are disparate classifications on various systems:
SunOS 5.10 treats \u202F, \u2060 as !iswprint()
SunOS 5.10 treats \u00A0, \u2007 as iswspace()
AIX 7.2, Darwin 17.4.0, NetBSD 7.1 treat \u2060 as !iswprint()
Pádraig Brady [Thu, 7 Mar 2019 05:04:26 +0000 (21:04 -0800)]
tests: id/zero: avoid false failure due to sed differences
* tests/id/zero.sh: sed on OSX will output a \n even
if the input doesn't have a \n on the last "line".
So ensure we always have a trailing '\n' to avoid the disparity.
Pádraig Brady [Thu, 7 Mar 2019 04:09:16 +0000 (20:09 -0800)]
tests: test-N: fix false positives on some systems
Testing by Assaf Gordon on OSX showed the atime wasn't
being updated when explicitly set back in time.
Also Debian 8.11 / mips64 was seen to not update the
mtime when truncating an empty file.
* tests/misc/test-N.sh: Isolate from different timestamping
behaviors of various (file) systems, by correlating
the timestamps with stat(1) before using `test -N`.
Assaf Gordon [Wed, 6 Mar 2019 06:32:34 +0000 (23:32 -0700)]
doc: replace @hashchar{} with actual hash character
Very old makeinfo-4.13 fails with:
./doc/coreutils.texi:2286: Unknown command `hashchar'.
./doc/coreutils.texi:2286: Misplaced {.
./doc/coreutils.texi:2286: Misplaced }.
Reported Bernhard Voelker in
https://lists.gnu.org/r/coreutils/2019-03/msg00016.html .
* doc/coreutils.texi (basenc invocation): Replace @hashchar{} with
actual hash character. The special syntax is only required
when referring to #line directives.
Pádraig Brady [Wed, 6 Mar 2019 18:34:16 +0000 (10:34 -0800)]
tests: wc-nbsp.sh: avoid failure on FreeBSD
* tests/misc/wc-nbsp.sh: FreeBSD and OS X don't
treat non breaking space as printable characters.
So use wc -L to determine printability before
testing non breaking space functionality.
Pádraig Brady [Wed, 6 Mar 2019 16:58:13 +0000 (08:58 -0800)]
build: fix env build where SIGNUM_BOUND is not constant
* src/env.c (initialize_signals): A new function to initialize
the signals array on the heap, to avoid a build failure on
opensolaris, where SIGNUM_BOUND is not a constant.
Pádraig Brady [Mon, 4 Mar 2019 09:12:04 +0000 (01:12 -0800)]
build: revert recent change with distributed man page handling
* man/local.mk: commit f114495e added an extra check to ensure
a binary was working before using it to generate the man page.
However this was not working for the false(1) command,
and also one can generally specify that one should not
be using generated commands on the current system by passing
'cross_compiling=yes' to the configure invocation.
Pádraig Brady [Mon, 4 Mar 2019 07:50:21 +0000 (23:50 -0800)]
env: add --list-signal-handling to output non default handling
* src/env.c (main): Output blocked or ignored signals
before a command is executed.
* doc/coreutils.texi (env invocation): Add the option.
* tests/misc/env-signal-handler.sh: Add a test case.
* NEWS: Mention the new feature.
Assaf Gordon [Fri, 15 Feb 2019 19:31:48 +0000 (12:31 -0700)]
env: new options --{default,ignore,block}-signal[=SIG]
New options to set signal handlers for the command being executed.
--block-signal suggested by Paul Eggert in http://bugs.gnu.org/34488#71
--default-signal is useful to overcome the POSIX limitation that shell
must not override inherited signal state, e.g. the second 'trap' here is
a no-op:
trap '' PIPE && sh -c 'trap - PIPE ; seq inf | head -n1'
Instead use:
trap '' PIPE && sh -c 'env --default-signal=PIPE seq inf | head -n1'
Similarly, the following will prevent CTRL-C from terminating the
program:
env --ignore-signal=INT seq inf > /dev/null
See https://bugs.gnu.org/34488#8
* NEWS: Mention new options.
* doc/coreutils.texi (env invocation): Document new options.
* man/env.x: Add example of --default-signal=SIG usage.
(SEE ALSO): Mention sigprocmask.
* src/env.c (signals): New global variable.
(longopts): Add new options.
(usage): Print new options.
(parse_signal_params): Parse comma-separated list of signals, store in
signals variable.
(reset_signal_handlers): Set each signal to SIG_DFL/SIG_IGN.
(parse_block_signal_params): Parse command-line options.
(set_signal_proc_mask): Call sigprocmask to block/unblock signals.
(main): Process new options.
* src/local.mk (src_env_SOURCES): Add operand2sig.c.
* tests/misc/env-signal-handler.sh: New test.
* tests/local.mk (all_tests): Add new test.
stat: print birth time on systems supporting statx
* configure.ac: Check for statx(), available on glibc >= 2.28.
* src/stat.c (get_birthtime): Call statx() when available.
* NEWS: Mention the improvement.
Pádraig Brady [Sun, 3 Mar 2019 22:35:18 +0000 (14:35 -0800)]
df: support different file system encodings when not using tty
* src/df.c (replace_problematic_chars): A new wrapper to be
more conservative in our replacement when not connected to a tty.
* tests/df/problematic-chars.sh: Add a test case.
Bernhard Voelker [Tue, 26 Feb 2019 18:06:52 +0000 (19:06 +0100)]
doc: further clarify 'yes' alternative in seq invocation
* doc/coreutils.texi (node seq invocation): Clarify to use the tool
'yes'; otherwise the reader may interpret the sentence as if one
could pass 'yes' as the INCREMENT value.
Pádraig Brady [Sun, 24 Feb 2019 05:23:47 +0000 (21:23 -0800)]
wc: treat non breaking space as a word separator
* src/wc.c (iswnbspace): A new function to match
characters in this class.
(isnbspace): Likewise for single byte charsets.
(main): Initialize posixly_correct from the environment,
to allow disabling honoring NBSP in non C locales.
(wc): Call is[w]nbspace() along with is[w]space.
* bootstrap.conf: Ensure btowc is available.
* tests/misc/wc-nbsp.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
Paul Eggert [Mon, 25 Feb 2019 07:59:22 +0000 (23:59 -0800)]
date: ‘+’ conversion specification flag
The recent Gnulib update fixed Bug#34608; document and test this.
* NEWS: Mention the change.
* doc/coreutils.texi (Padding and other flags):
Update doc to cover new flag and other POSIX.1-2017 changes.
* tests/misc/date.pl (date-century-plus): New test.
Bernhard Voelker [Mon, 26 Nov 2018 08:05:37 +0000 (09:05 +0100)]
all: detect --help and --version more consistently
For select programs which accept only --help and --version options
(in addition to non-option arguments), process these options before
any other options.
Before:
$ dd bs=1 --help
dd: unrecognized option '--help'
Try 'dd --help' for more information.
$ yes me --help
me --help
me --help
...
After:
Any occurrence of '--help' in the arguments (prior to '--') will
show the help screen.