Compare commits

...

898 Commits
v8.30 ... v9.3

Author SHA1 Message Date
Pádraig Brady
f386722dc0 version 9.3
* NEWS: Record release date.
2023-04-18 15:08:11 +01:00
Pádraig Brady
d81094dc7b 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-16 16:11:20 +01:00
Pádraig Brady
cf91b9d62c 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-14 00:02:22 +01:00
Pádraig Brady
daa1e4f557 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.
2023-04-13 20:19:18 +01:00
Pádraig Brady
854c90ecc0 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-13 20:19:09 +01:00
Paul Eggert
cc95246ee2 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 11:56:43 -07:00
Pádraig Brady
ae4dace2ec 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 19:45:14 +01:00
Pádraig Brady
09ded7049b 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 18:54:19 +01:00
Paul Eggert
ffd62ab92c maint: require support for post-2038 timestamps
* bootstrap.conf (gnulib_modules): Replace year2038 with
year2038-required.
2023-04-09 19:21:55 -07:00
Paul Eggert
6f91c2eac3 build: update gnulib submodule to latest 2023-04-09 19:21:55 -07:00
Pádraig Brady
ce630dfc7e 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
2023-04-08 12:19:40 +01:00
Pádraig Brady
f6c21f6d3a 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 12:11:58 +01:00
Pádraig Brady
db28af406f 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-08 12:11:50 +01:00
Pádraig Brady
5891d28ede 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-04-04 12:00:11 +01:00
Pádraig Brady
17c31a73f1 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
2023-03-31 11:58:53 +01:00
Pádraig Brady
5e170ff0b8 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
2023-03-31 11:58:53 +01:00
Pádraig Brady
7ad749886c 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-31 11:58:49 +01:00
Pádraig Brady
a9bd274616 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.
2023-03-28 14:24:29 +01:00
Pádraig Brady
a4525de1ef 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 13:40:43 +01:00
Paul Eggert
9c5e542fd1 date: diagnose -f read errors
* src/date.c (batch_convert): Diagnose read errors, fixing Bug#62497.
2023-03-28 01:53:06 -07:00
Paul Eggert
6272817de0 cp: clarify commentary
* src/copy.c: Make comments a bit clearer.
2023-03-25 13:20:16 -07:00
Pádraig Brady
093a8b4bfa 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 13:12:51 +00:00
Pádraig Brady
55456b95d8 doc: add a NEWS entry for the previous fix
* NEWS: Mention the previous cksum --check fix.
2023-03-24 12:52:13 +00:00
Pádraig Brady
76f2fb6271 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-23 12:36:53 +00:00
Nick Alcock
eeabb11eb6 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-21 16:15:18 +00:00
Pádraig Brady
bdda9adb38 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2023-03-20 14:08:46 +00:00
Pádraig Brady
df4e4fbc7d version 9.2
* NEWS: Record release date.
2023-03-20 13:44:36 +00:00
Pádraig Brady
445f502839 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.
2023-03-19 23:44:51 +00:00
Pádraig Brady
eb745e3b95 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.
2023-03-19 22:25:50 +00:00
Pádraig Brady
82bb131c55 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-19 12:23:05 +00:00
Pádraig Brady
11f4d59138 doc: uniq: revert previous man page adjustment
* src/uniq.c (usage): -D doesn't take an argument
so should be separated in the description.
2023-03-18 14:58:20 +00:00
Pádraig Brady
8a759fdc88 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
2023-03-18 11:44:24 +00:00
Pádraig Brady
a109106eb8 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-18 11:44:24 +00:00
Bernhard Voelker
f346fc0144 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-17 00:12:18 +01:00
Pádraig Brady
1d03781daa 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
2023-03-15 18:11:00 +00:00
Pádraig Brady
a8e6e627f1 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 14:05:38 +00:00
Bruno Haible
f1ff021247 build: avoid -Wsometimes-uninitialized on macOS 12
* src/pr.c (integer_overflow): Mark as _Noreturn.
* src/test.c (beyond): Likewise.
2023-03-15 13:15:11 +00:00
Pádraig Brady
e68b15a3ef doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.29 which is now about 5 years old.
2023-03-13 21:45:50 +00:00
Pádraig Brady
73d372dcc1 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.
2023-03-13 21:26:21 +00:00
Pádraig Brady
f26af59833 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 16:20:38 +00:00
Pádraig Brady
47988fad88 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 16:20:38 +00:00
Pádraig Brady
1ac1d6def6 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-13 16:20:38 +00:00
Pádraig Brady
16000805eb 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 18:32:05 +00:00
Pádraig Brady
176b74f0e7 doc: remove redundant NEWS entry
* NEWS: There was no bug on macOS,
and the split -n new feature is documented already.
2023-03-08 18:28:06 +00:00
Paul Eggert
bb9dbcbbfd 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 13:41:46 -08:00
Pádraig Brady
35ac97e0d6 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-07 01:14:00 +00:00
Paul Eggert
a4778006c8 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 15:39:07 -08:00
Pádraig Brady
e30af1e584 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-06 13:04:40 +00:00
Paul Eggert
110bcd2838 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 16:57:16 -08:00
Paul Eggert
8022874d12 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.
2023-03-04 14:49:46 -08:00
Paul Eggert
788654dd82 split: style fix
* src/split.c (ofile_open): Avoid ‘if (! (a = b))’ style.
2023-03-04 14:49:46 -08:00
Paul Eggert
40bf1591bb 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.
2023-03-04 14:49:46 -08:00
Paul Eggert
3434cdcec1 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.
2023-03-04 14:49:46 -08:00
Paul Eggert
1ebee5b1a3 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.
2023-03-04 14:49:46 -08:00
Paul Eggert
e19a59141b 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.
2023-03-04 14:49:46 -08:00
Paul Eggert
0450987853 split: minor -1 / 0 refactor
* src/split.c (create, bytes_split, ofile_open):
Prefer comparing to 0 to comparing to -1.
2023-03-04 14:49:46 -08:00
Paul Eggert
a110ce4ce3 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.
2023-03-04 14:49:46 -08:00
Paul Eggert
41615f0f8f 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.
2023-03-04 14:49:45 -08:00
Paul Eggert
99fcde22ce 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.
2023-03-04 14:49:45 -08:00
Paul Eggert
aa266f1b3d 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.
2023-03-04 14:49:45 -08:00
Paul Eggert
fe64f8be01 maint: fix NEWS quoting
* NEWS: Use English-language quoting in recent news.
2023-03-04 14:49:45 -08:00
Paul Eggert
fb6fc7f3ce 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.
2023-03-04 14:49:45 -08:00
Paul Eggert
0d997e18b9 split: small -n lines simplification
* src/split.c (lines_chunk_split):
Rewrite while as if-while for clarity.
2023-03-04 14:49:45 -08:00
Paul Eggert
f749449e5c 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.
2023-03-04 14:49:45 -08:00
Paul Eggert
0789451237 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-04 14:49:45 -08:00
Pádraig Brady
76b5843ff9 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-03-01 19:27:36 +00:00
Pádraig Brady
5bcc2912e7 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.
2023-02-28 14:04:16 +00:00
Pádraig Brady
fb757fd7d9 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.
2023-02-28 14:02:42 +00:00
Pádraig Brady
b1376bb829 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 14:02:42 +00:00
Carl Edquist
6b12e62d95 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 14:02:42 +00:00
Carl Edquist
b5c421a784 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-28 14:02:38 +00:00
Pádraig Brady
0175e337a8 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-27 12:17:06 +00:00
Pádraig Brady
995021cb0c 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 18:31:35 +00:00
Pádraig Brady
3ead67dd16 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-26 18:31:28 +00:00
Pádraig Brady
65bb276564 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 15:17:36 +00:00
Pádraig Brady
5c8c2a5161 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 00:35:18 +00:00
Pádraig Brady
d899f9e332 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-24 00:35:18 +00:00
Paul Eggert
8a7fc0096c build: update gnulib submodule to latest 2023-02-23 13:27:00 -08:00
Pádraig Brady
c97c40c3b4 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-23 15:22:14 +00:00
ChuanGang Jiang
3edbf016be 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 16:22:20 +00:00
Pádraig Brady
afae7787f2 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 16:17:53 +00:00
Jim Meyering
c62488a801 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 07:18:17 -08:00
Jim Meyering
a0803c4bad 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-21 07:18:17 -08:00
Paul Eggert
95f4ee0577 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.
2023-02-18 13:30:10 -08:00
Paul Eggert
f48b80ff26 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.
2023-02-18 13:30:09 -08:00
Paul Eggert
cccfae54dc build: update gnulib submodule to latest 2023-02-18 13:30:09 -08:00
Paul Eggert
4b05739168 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-16 15:40:06 -08:00
ChuanGang Jiang
cf80f988ee 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 18:06:54 +00:00
Paul Eggert
d374d32ccf 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-09 19:54:20 -08:00
Pádraig Brady
d195e3863c 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 16:28:53 +00:00
Pádraig Brady
c0c63e9735 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 16:18:12 +00:00
Pádraig Brady
ead07bb3d4 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-06 13:09:40 +00:00
Pádraig Brady
2984e47c78 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-05 14:15:03 +00:00
Paul Eggert
5699313c76 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.
2023-02-04 14:42:58 -08:00
Paul Eggert
407d8af116 maint: prefer https: to git:
The idea is to defend against some adversary-in-the-middle attacks.
2023-02-04 14:13:27 -08:00
Paul Eggert
d42e4e9191 build: update gnulib submodule to latest 2023-02-04 10:45:18 -08:00
Pádraig Brady
b5904c985c maint: avoid line length syntax check failure
* src/cp.c: Adjust source line to be <= 80 chars.
2023-02-03 16:42:01 +00:00
Pádraig Brady
ce5225bcef 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-03 16:38:55 +00:00
Jim Meyering
b319685c6e 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 18:24:28 -08:00
Paul Eggert
7a8db7dbaf doc: document --preserve=mode better
* doc/coreutils.texi: Spruce up cp --preserve=mode doc.
2023-01-31 13:53:58 -08:00
Paul Eggert
6baadf8ba3 cp: improve --preserve usage doc
* src/cp.c (usage): Improve description of --preserve.
2023-01-31 13:53:58 -08:00
Paul Eggert
01503ce731 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.
2023-01-31 09:25:25 -08:00
Paul Eggert
7a69df8899 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-31 08:54:37 -08:00
Pádraig Brady
666a7fc1d5 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 19:29:38 +00:00
Jim Meyering
5c830d40e0 digest.c: remove a duplicate variable
* src/digest.c (digest_check): Locals n_misformatted_lines and
n_improperly_formatted_lines were declared and set/incremented
identically. Remove declaration of the latter. Use the other instead.
2023-01-30 09:26:09 -08:00
Jim Meyering
d73ca62c4f build: avoid spurious failures due to lack of EGREP definition
* configure.ac: Use AC_PROG_EGREP, since many doc and test rules
use $EGREP.
* cfg.mk (sc_tests_list_consistency): Use grep -E, not $(EGREP) here.
2023-01-30 09:18:13 -08:00
Pádraig Brady
95bc69a7e7 tests: ensure we fail if mv --no-copy crashes
* tests/mv/no-copy.sh: Honor `make syntax` check
and use the `returns_ 1 ...` pattern.
2023-01-27 19:46:52 +00:00
Paul Eggert
20005ca733 mv: new option --no-copy
Wishlist item from Mike Frysinger (Bug#61050).
* src/copy.c (copy_internal):
Do not fall back on copying if x->no_copy.
* src/copy.h (struct cp_options): New member no_copy.
* src/mv.c (NO_COPY_OPTION): New constant.
(long_options, usage, main): Support --no-copy.
* tests/mv/no-copy.sh: New test.
* tests/local.mk (all_tests): Add it.
2023-01-27 11:03:38 -08:00
Pádraig Brady
d5868df0d0 maint: add lib/error.h to .gitignore
* .gitignore: Add /lib/error.h as suggested by sc_gitignore_missing
as a result of gnulib change 2886cca8.
2023-01-17 22:38:40 +00:00
Pádraig Brady
7479ef7c11 doc: csplit: more accurate --elide-empty-files help
* src/csplit.c (usage): Use "suppress" rather than "remove"
when describing -z so it's more apparent that the effect
is a particular numbered file is not created, rather than
being removed later.  I.e., don't suggest -z may induce
gaps in file numbering.
Reported at https://bugs.debian.org/1029103
2023-01-17 21:44:48 +00:00
Paul Eggert
28a85116fe build: update gnulib submodule to latest
* m4/xattr.m4: Remove.  This file is now autogenerated by 'bootstrap',
since it's now in Gnulib.  (I did this part by hand.)
2023-01-13 17:51:01 -08:00
Pádraig Brady
7fc84d1c0f copy: copy_file_range: handle ENOENT for CIFS
* src/copy.c (sparse_copy): Fallback to standard copy upon ENOENT,
which was seen intermittently across CIFS file systems.
* NEWS: Mention the bug fix, though qualify it as an "issue"
rather than a bug, as coreutils is likely only highlighting
a CIFS bug in this case.
Fixes https://bugs.gnu.org/60455
2023-01-08 13:34:52 +00:00
Paul Eggert
e64113d601 maint: update .gitignore
* .gitignore: Add confdefs*, conftest* (temporaries built
by ‘configure’).
2023-01-07 15:50:51 -08:00
Paul Eggert
d62ca23f08 maint: adjust to Gnulib macro renaming
* src/local.mk (LDADD, copy_ldadd, remove_ldadd, src_sort_LDADD)
(src_test_LDADD, copy_ldadd, src_date_LDADD, src_ginstall_LDADD)
(src_ln_LDADD, src_ls_LDADD, src_mktemp_LDADD, src_pr_LDADD)
(src_tac_LDADD, src_touch_LDADD, src_dd_LDADD, src_sleep_LDADD)
(src_sort_LDADD, src_tail_LDADD, src_sort_LDADD, LDADD):
Adjust to recent Gnulib changes.
2023-01-07 15:50:51 -08:00
Paul Eggert
ca08a87489 build: update gnulib submodule to latest 2023-01-07 15:50:51 -08:00
Pádraig Brady
f6c93f334e copy: immediately fail with transient reflink errors
* src/copy.c (handle_clone_fail): A new function refactored
from copy_reg() to handle failures from FICLONE or fclonefileat().
Fail with all errors from FICLONE, unless they're from the set
indicating the file system or file do not support the clone operation.
Also fail with errors from fclonefileat() (dest_dest < 0)
if they're from the set indicating a transient failure for the file.
(copy_ref): Call handle_clone_fail() after fclonefileat() and FICLONE.
(sparse_copy): Call the refactored is_CLONENOTSUP()
which is now also used by the new handle_clone_fail() function.
* NEWS: Mention the bug fix.  Also mention explicitly
the older --reflink=auto default change to aid searching.
* cfg.mk: Adjust old_NEWS_hash with `make update-NEWS-hash`.
Fixes https://bugs.gnu.org/60489
2023-01-06 14:32:44 +00:00
Pádraig Brady
f4567ed953 all: further adjustments for new Ronna, Quetta SI prefixes
* src/dd.c (parse_integer): Support Q,R suffixes.
* src/od.c (main): Likewise.
* src/split.c (main): Likewise.
* src/stdbuf.c (parse_size): Likewise.
* src/truncate.c (main): Likewise.
* src/sort.c (specify_size_size): Likewise.
Also line length syntax check fix.
* tests/misc/numfmt.pl: Adust top end large number checks
to the new largest values.
* doc/coreutils.texi (numfmt invocation): Add a numfmt example.
* NEWS: Tweak to aid searchability.
2023-01-06 14:26:40 +00:00
Paul Eggert
e1ff4ee0f6 numfmt: add support for new SI prefixes
* src/dd, src/head.c, src/od.c, src/sort.c, src/stdbuf.c, src/tail.c:
(usage):
* src/system.h (emit_size_note):
Mention new SI prefixes.
* src/du.c (main):
* src/head.c (head_file):
* src/numfmt.c (suffix_power, suffix_power_char, prepare_padded_number):
* src/shred.c (main):
* src/sort.c (unit_order):
* src/tail.c (parse_options):
Support new SI prefixes.
* src/numfmt.c (MAX_ACCEPTABLE_DIGITS): Increase to 33.
(zero_and_valid_suffixes, valid_suffixes): New constants,
with new SI prefixes.
(valid_suffix, unit_to_umax): Use them.
(prepare_padded_number): Diagnose "999Q" instead of "999Y".
* tests/misc/numfmt.pl, tests/misc/sort.pl:
Adjust tests to match new max.
2023-01-05 12:47:41 -08:00
Paul Eggert
26bac32137 ls: adjust to Gnulib renaming
* src/local.mk (src_ls_LDADD): In Gnulib,
LIB_HAS_ACL was renamed to FILE_HAS_ACL_LIB.
2023-01-05 12:47:41 -08:00
Paul Eggert
b7c8754c90 build: update gnulib submodule to latest 2023-01-05 12:47:41 -08:00
Bernhard Voelker
8d4768c94d maint: avoid grep warning in sc_prohibit_test_minus_ao
Newer grep(1) complains:
  $ make sc_prohibit_test_minus_ao
  /usr/bin/grep: warning: * at start of expression
  prohibit_test_minus_ao

* cfg.mk (exclude_file_name_regexp--sc_prohibit_test_minus_ao): Fix
expression inroduced in v8.24-120-g3205bb178, and narrow down the file
pattern to the 'doc/' directory.
2023-01-03 09:16:09 +01:00
Pádraig Brady
31cf78f1d5 doc: copy: mention the reinstated I/O size constraints
* NEWS: Mention the change in behavior re block size multiples
to support unusual devices with this constraint.
* src/copy.c (copy_reg): Likewise.
2023-01-02 23:30:09 +00:00
Paul Eggert
6c343a5574 copy: fix possible over allocation for regular files
* bootstrap.conf (gnulib_modules): Add count-leading-zeros,
which was already an indirect dependency, since ioblksize.h
now uses it directly.
* src/ioblksize.h: Include count-leading-zeros.h.
(io_blksize): Treat impossible blocksizes as IO_BUFSIZE.
When growing a blocksize to IO_BUFSIZE, keep it a multiple of the
stated blocksize.  Work around the ZFS performance bug.
* NEWS: Mention the bug fix.
Problem reported by Korn Andras at https://bugs.gnu.org/59382
2023-01-02 23:30:07 +00:00
Pádraig Brady
01755d36e7 maint: update all copyright year number ranges
Update to latest gnulib with new copyright year.
Run "make update-copyright" and then...

* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Manually update copyright year,
until we fully sync with gnulib at a later stage.
* tests/sample-test: Adjust to use the single most recent year.
2023-01-01 14:50:15 +00:00
Pádraig Brady
0239f2a782 build: update gnulib submodule to latest
mainly to get updated copyright year

* tests/init.sh: Sync with gnulib
2023-01-01 14:47:08 +00:00
Pádraig Brady
c9a21ec317 stty: fix off by one column wrapping on output
* src/stty.c (wrapf): Adjust the comparison by 1,
to account for the space we're adding.
* tests/misc/stty.sh: Add a test case.
* NEWS: Mention the fix.
Reported in https://bugs.debian.org/1027442
2022-12-31 19:01:59 +00:00
Pádraig Brady
879d2180d6 copy: attempt copy offload with sparse files by default
This was seen to vastly improve performance
on NFS 4.2 systems by allowing server side copies,
with partially sparse files (avidemux generated mp4 files).

* src/copy.c (lseek_copy): Also set hole_size to 0,
i.e. enable copy_file_range(), with --sparse=auto (the default),
to enable copy offload in this case, as we've strong signal
from SEEK_DATA that we're operating on actual data and not holes here.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/60416
2022-12-31 00:20:45 +00:00
Pádraig Brady
266b7cbc84 wc: fix regression determining file size
* src/wc.c (wc): Use off_t rather than size_t
when calculating where to seek to, so that
we don't seek to a too low offset on systems
where size_t < off_t, which would result in
many read() calls to determine the file size.
* tests/misc/wc-proc.sh: Add a test case
sufficient for 32 bit systems at least.
* NEWS: Mention the bug fix.
Reported at https://bugs.debian.org/1027101
2022-12-29 14:15:54 +00:00
Pádraig Brady
4bf990bf65 maint: avoid recent syntax check failure
* tests/cp/proc-short-read.sh: Adjust so shorter lines.
2022-12-29 14:15:54 +00:00
Paul Eggert
cfe4af661f doc: improve doc of du with CoW etc
Problem reported by Krzysztof Żelechowski (Bug#60335).
* doc/coreutils.texi (du invocation): Reword.
2022-12-26 10:35:24 -08:00
Paul Eggert
7279459f9f doc: improve du --threshold wording
* doc/coreutils.texi (du invocation): Reword.
2022-12-26 10:35:24 -08:00
Paul Eggert
16fc0f30fe tests: accommodate bogomips capitalizations
* tests/cp/proc-short-read.sh: Kernel on ARMv7 Processor rev 3 (v7l)
spells it "BogoMIPS", so allow any capitalization.  Patch from
Zach van Rijn in <https://bugs.gnu.org/60339>.
2022-12-26 09:01:37 -08:00
Paul Eggert
9581c4b59d build: update gnulib submodule to latest 2022-12-06 11:08:02 -08:00
Paul Eggert
8c4d57ba27 doc: timezone -> time zone 2022-12-06 10:40:53 -08:00
Paul Eggert
5399f2aac4 doc: improve date -I doc
Suggested by Marc Chantreux (bug#59827).
* doc/coreutils.texi (Options for date):
Give formats for -I, like we already do for --rfc-3339.
2022-12-05 18:42:34 -08:00
Dennis Williamson
02441761c9 build: fix missing inclusion of poll.h on macOS
* src/tail.c: Following on from commit v9.1-55-g324c188cf
also include poll.h for __APPLE__, which was seen to be required
on macOS 11.6
2022-12-05 14:32:36 +00:00
Pádraig Brady
aaa306ad76 doc: tee: make -p decription more complete
* doc/coreutils.texi (tee invocation): Give a more
cohesive description of the -p option, and how
it differs from the default operation.
2022-11-29 14:52:52 +00:00
Arsen Arsenović
8613d35be6 scripts: commit-msg: recognize Git cut_lines
This prevents spurious failures from happening when someone sets
commit.verbose or passes -v to commit.
2022-11-20 18:17:47 +00:00
Paul Eggert
7bb940cced doc: more dash fixes
* doc/coreutils.texi, doc/sort-version.texi: Prefer on "x -- y" to
"x---y" in prose, as the result is more readable in Emacs.
Fix some instances of unescaped ‘-’ that should be minus, not
hyphen. Fix some other instances that should be en dash.  No
spaces around en dash when it’s a range.
2022-11-15 10:57:31 -08:00
Paul Eggert
4f43143ab1 maint: fix cfg.mk comment
* cfg.mk (sc_texi_long_option_escaped): Fix comment.
2022-11-15 10:57:31 -08:00
Pádraig Brady
5450c7f8d3 tests: make SIGPIPE trap checking more robust
* init.cfg (trap_sigpipe_or_skip_): A subshell with ignored SIGPIPE
was seen to not terminate, on Solaris 11 at least.
So protect with a timeout(1).
2022-11-15 14:02:16 +00:00
Pádraig Brady
e3bb975448 maint: avoid new grep -q syntax-check failures
* cfg.mk: Exclude NEWS from the check.
* init.cfg: s/grep -q/grep >/dev/null/.
* tests/ls/hyperlink.sh: Likewise.
* tests/ls/symlink-quote.sh: Likewise.
2022-11-15 14:02:10 +00:00
Pádraig Brady
e902f9b88d maint: avoid misquoting of some --long-options in texi
* cfg.mk (sc_texi_long_option_escaped): A new check to
avoid future instances of this.
* doc/coreutils.texi (Common options): Rearrange this menu
to be less repetitive in each description, and avoid long lines.
Addresses https://bugs.gnu.org/59262
2022-11-15 13:30:24 +00:00
Paul Eggert
2fce39eb3a doc: fix markup
Problem reported by Antonio Diaz Diaz (bug#59262).
* doc/coreutils.texi: Use markup in menus to prevent
‘--’ from turning into an em dash, and to be more
consistent.
2022-11-14 19:08:53 -08:00
Paul Eggert
b73888b12c build: update gnulib submodule to latest 2022-11-14 19:08:53 -08:00
Pádraig Brady
994c83e2e3 doc: printf: make "java" encoding example more standard
Note using iconv(1) rather than recode(1) is not appropriate
for this example, as the required functionality is only
available on libiconv's iconv implementation, which is
not installed on most systems.

* doc/coreutils.texi (printf invocation): Use env rather than
/usr/local/bin for the printf command.  Escape '%' so more robust.
Also use a locale that exists on modern systems.
2022-10-28 14:51:56 +01:00
Pádraig Brady
90817ff295 doc: move description of printf options to better location
* doc/coreutils.texi (printf invocation): Move the description
of accepted options from the middle of the unicode discussion.
2022-10-28 13:45:35 +01:00
Pádraig Brady
0925e8a0f4 printf: with \U, support all valid unicode points
Previously this was restricted to the C99 universal character subset,
which restricted most values <= 0x9F, as that simplifies the C lexer.
However printf(1) doesn't need this restriction.
Note also the bash builtin printf already supports all values <= 0x9F.

* src/printf.c (main): Relax the restriction on points <= 0x9F.
* doc/coreutils.texi (printf invocation): Adjust description.
* tests/misc/printf-cov.pl: Adjust accordingly.  Add new cases.
* NEWS: Mention the change in behavior.
Reported at https://bugs.debian.org/1022857
2022-10-28 13:45:27 +01:00
Pádraig Brady
468c4fb10d doc: basenc: reference from base{32,64} docs
* doc/coreutils.texi (base32 invocation): Reference basenc
to improve discoverability.
(base64 invocation): Likewise.
* man/base32.x: Likewise.
* man/base64.x: Likewise.
2022-10-26 12:50:11 +01:00
Pádraig Brady
4fd708810c doc: sort: mention --version useful for IPv4 addresses
* doc/coreutils.texi (sort invocation): Mention in the
multi invocation sort example that the -V GNU extension
could be used to sort IPv4 addresses, and thus simplify
to a single invocation.
2022-09-30 15:44:30 +01:00
Pádraig Brady
339fb6bb84 maint: NEWS: use consistent quoting
* NEWS: Change unmatched curly quote to more consistent single quote.
2022-09-28 19:01:04 +01:00
Pádraig Brady
8aa3b82ea1 doc: be more consistent when documenting exit status
* src/system.h (emit_exec_status): A new function to
output standard "Exit status:" info for commands that exec others.
* doc/coreutils.texi (Exit status): Add "ls" and "runcon"
to the list of commands with non standard exit status.
* src/numfmt.c (main): Call initialize_exit_failure() explicitly
to better indicate this utility may exit with something other than
EXIT_FAILURE.
* src/timeout.c (usage): Use more consistent capitalization.
* src/chroot.c: Call emit_exec_status().
* src/env.c: Likewise.
* src/nice.c: Likewise.
* src/nohup.c: Likewise.
* src/runcon.c: Likewise.
* src/stdbuf.c: Likewise.
2022-09-28 15:06:11 +01:00
Pádraig Brady
4c1d30771d runcon: fix inconsistent exit status upon write error
* src/runcon.c (main): Call initialize_exit_failure(),
so we use an appropriate exit status upon failure to close stdout.
This should have been part of recent commit ea3ee6df.
* tests/misc/help-version.sh: Adjust test case accordingly.
2022-09-28 15:06:11 +01:00
Pádraig Brady
f69743604b maint: getlimits: diagnose invalid options
* src/getlimits.c: Don't call initialize_exit_failure()
as it's not needed for standard EXIT_FAILURE returns.
Also use the function variant that diagnoses invalid options.
2022-09-28 15:06:11 +01:00
Pádraig Brady
322f7abf8a maint: rmdir: also use DS_... constants here
* src/rmdir.c: As with commit 627c9a97,
use DS_NONEMPTY constant to improve readability.
2022-09-28 15:06:11 +01:00
Pádraig Brady
ce2b875cd7 wc: add --total={auto,never,always,only} option
without this option, control of when the total is output
is quite awkward. Consider trying to suppress the total line,
which could be achieved with something like:

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

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

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

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

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

* src/wc.c: Add new --total option.
* tests/misc/wc-total.sh: New test suite for the new option.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (wc invocation): Document the new option.
* THANKS.in: Add suggestor.
* NEWS: Mention the new feature.
2022-09-26 15:04:56 +01:00
Pádraig Brady
627c9a97c1 maint: use enums to make dir_status code easier to read
* src/system.h: Add DS_EMPTY, and DS_NONEMPTY enums.
* src/remove.c: Use the new enums to make code easier to understand.
2022-09-25 15:26:20 +01:00
Pádraig Brady
800ff60f6f doc: mention the recent rm improvement
* NEWS: Mention the improvement re handling of directory errnos.
2022-09-25 15:25:45 +01:00
Pádraig Brady
c86b6ec711 maint: fix recent syntax-check failures
* .gitignore: Add new headers from gnulib.
* src/basenc.c: Adjust line length due to replacement
of 'verify' with 'static_assert'.
* src/od.c: Likewise.
2022-09-25 15:12:13 +01:00
Paul Eggert
eb7841426c rm: fix diagnostics on I/O error
I ran into this problem when attempting to recursively
remove a directory in a filesystem on flaky hardware.
Although the underlying readdir syscall failed with errno == EIO,
rm issued no diagnostic about the I/O error.

Without this patch I see this behavior:

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

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

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

* src/remove.c (Ternary): Remove.  All uses removed.
(get_dir_status): New static function.
(prompt): Last arg is now directory status, not ternary.
Return RM_USER_ACCEPTED if user explicitly accepted.
All uses changed.
Report any significant error in directory status right away.
(prompt, rm_fts): Use get_dir_status to get directory status lazily.
(excise): Treat any FTS_DNR errno as being more descriptive, not
just EPERM and EACCESS.  For example, EIO is more descriptive.
(rm_fts): Distinguish more clearly between explicit and implied
user OK.
* src/remove.h (RM_USER_ACCEPTED): New constant.
(VALID_STATUS): Treat it as valid.
* src/system.h (is_empty_dir): Remove, replacing with ...
(directory_status): ... this more-general function.
All uses changed.  Avoid undefined behavior of looking at
a non-null readdir pointer after corresponding closedir.
* tests/rm/rm-readdir-fail.sh: Adjust test of internals
to match current behavior.
2022-09-24 16:34:31 -07:00
Paul Eggert
5a14ccad48 rm: fix readdir test
* tests/rm/rm-readdir-fail.sh [_DIRENT_HAVE_D_NAMELEN]:
Fix off-by-1 bug in directory entry length.
2022-09-24 16:34:30 -07:00
Paul Eggert
b2f8dfc129 doc: fix typo in previous change 2022-09-20 01:12:37 -07:00
Paul Eggert
4cbe227fa0 doc: warn about tabs command (bug#57946) 2022-09-20 00:10:37 -07:00
Stefan Kangas
875c636ce5 all: prefer HTTPS to HTTP
* README-hacking:
* README-prereq:
* THANKS.in:
* doc/sort-version.texi (Other version/natural sort implementations):
* gl/lib/rand-isaac.c:
* gl/tests/test-rand-isaac.c:
* src/operand2sig.c (operand2sig):
* src/remove.c (nonexistent_file_errno):
* tests/misc/env-signal-handler.sh:
* tests/misc/sort-debug-warn.sh (LC_ALL): Prefer HTTPS to HTTP.
Addresses https://bugs.gnu.org/56512
Copyright-paperwork-exempt: yes
2022-09-18 11:42:02 -07:00
Paul Eggert
9062704bf8 kill: port to picky-conversion hosts
* src/kill.c (send_signals): Don’t rely on conversion overflow
being silent.
2022-09-17 19:41:31 -07:00
Paul Eggert
728f3baa50 maint: fix bootstrap module lists for alignof
* bootstrap.conf (gnulib_modules): Remove alignof, which isn’t
needed since coreutils source modules don’t include alignof.h.
Add stdalign, since they depend on alignof working without
stdalign.h.
2022-09-15 01:16:31 -05:00
Paul Eggert
9a777a44b3 maint: prefer static_assert to verify
* bootstrap.conf: Add assert-h.
* gl/lib/randperm.c: Do not include verify.h.
* gl/lib/randperm.c, src/basenc.c, src/dd.c, src/digest.c:
* src/dircolors.c, src/expr.c, src/factor.c, src/ls.c, src/numfmt.c:
* src/od.c, src/seq.c, src/shred.c, src/sort.c, src/stat.c:
Prefer C23’s static_assert to nonstandard verify.
* gl/modules/randperm (Depends-on): Add assert-h.
2022-09-15 01:16:31 -05:00
Paul Eggert
7363a58286 maint: assume C23 alignof
* gl/lib/randread.c, src/stat.c (print_statfs):
No need to include stdalign.h, now that alignof is a keyword
in C23 and Gnulib arranges for this.
2022-09-15 00:44:01 -05:00
Paul Eggert
b29ef22135 maint: don’t include config.h twice
* gl/lib/fadvise.h, gl/lib/smack.h, src/blake2/blake2-impl.h:
Do not include config.h from a .h file.  config.h is supposed
to be included once, at the start of compilation and before
any other file.
2022-09-15 00:44:01 -05:00
Paul Eggert
3d97ccfa38 build: update gnulib submodule to latest 2022-09-15 00:44:01 -05:00
Álvar Ibeas
76193a5e75 doc: shred: minor fix
* doc/coreutils.texi: Fix wording.

Copyright-paperwork-exempt: yes
2022-09-13 17:25:10 -05:00
Paul Eggert
ede8203763 maint: adjust to Gnulib stdbool C23 change
* gl/lib/mbsalign.c, gl/lib/randread.c, gl/lib/targetdir.h:
* gl/lib/xdectoint.c, gl/lib/xfts.c, gl/lib/xfts.h:
* src/blake2/b2sum.c, src/copy.h, src/die.h, src/system.h:
Don’t include <stdbool.h>, since Gnulib now emulates C23.
2022-09-12 23:07:06 -05:00
Paul Eggert
9a53930aa1 build: update gnulib submodule to latest 2022-09-12 23:07:05 -05:00
Pádraig Brady
39f71795d2 stty: give explicit error for unsupported asymmetric speeds
* src/stty.c (check_speed): If difference input and output speeds
are specified, then validate the system supports that, before
interacting with the device.
2022-09-11 18:44:10 +01:00
Pádraig Brady
760998a789 stty: fix false warnings from [io]speed settings
* src/stty.c (eq_mode): A new function to compare
equivalence of two modes.
(main): Use eq_mode() rather than memcmp() to compare
two modes. Also use stack variables rather than implicitly
initialized static variables.  Also remove all uses of
the SPEED_WAS_SET hack since we now more robustly compare modes.
* NEWS: Update the [io]speed fix entry.
Reported at https://bugs.debian.org/1019468
2022-09-11 15:40:52 +01:00
Pádraig Brady
8fdf9307b6 maint: add lib/gmp.h to .gitignore
* .gitignore: Add generated file.  Tested with:
./configure --without-libgmp && make && git status
2022-09-02 22:06:05 +01:00
Pádraig Brady
d1f4632ff4 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.
2022-08-31 22:55:31 +01:00
Pádraig Brady
b81205bdc7 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
2022-08-31 19:09:15 +01:00
Pádraig Brady
f87a78f334 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
2022-08-31 01:03:33 +01:00
Pádraig Brady
3a1c328cd5 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.
2022-08-29 15:33:12 +01:00
Pádraig Brady
324c188cfd 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.
2022-08-29 15:32:54 +01:00
Pádraig Brady
b3bb2b707c 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.
2022-08-27 22:15:44 +01:00
Pádraig Brady
af231b6c4f doc: NEWS: document recent comm fix, and runcon change
* NEWS: Mention comm bug fix, and runcon change in behavior.
2022-08-27 21:37:28 +01:00
Pádraig Brady
d2c5376f05 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.
2022-08-27 19:18:29 +01:00
Pádraig Brady
708ae170c9 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
2022-08-27 18:41:10 +01:00
Pádraig Brady
c88f08f9b6 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.
2022-08-27 17:54:42 +01:00
Pádraig Brady
ea3ee6df27 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.
2022-08-27 17:50:20 +01:00
Pádraig Brady
e3d6035938 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.
2022-08-13 21:09:09 +01:00
Pádraig Brady
a88b666bea 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.
2022-08-13 13:48:24 +01:00
Pádraig Brady
35fbc51d3f 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.
2022-08-12 14:21:12 +01:00
Pierre Marsais
c7920f2b1b 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`.
2022-08-01 22:00:07 +01:00
Pádraig Brady
993f0d968d 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.
2022-08-01 21:55:12 +01:00
Pádraig Brady
ab976f4090 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.
2022-07-30 13:06:56 +01:00
Paul Eggert
afffa445b9 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.
2022-07-27 10:04:49 -07:00
Pádraig Brady
187712b97b 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
2022-07-26 14:16:55 +01:00
Pádraig Brady
56783caccf 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
2022-07-24 21:09:24 +01:00
Pádraig Brady
854e035121 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.
2022-07-24 20:40:34 +01:00
Pádraig Brady
96c1499413 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
2022-07-24 18:55:41 +01:00
Pádraig Brady
b8aafe5145 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
2022-07-24 18:22:50 +01:00
Paul Eggert
8ec11f3e72 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.
2022-07-23 12:17:44 -07:00
Paul Eggert
116ac656e7 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).
2022-07-22 13:51:13 -07:00
Paul Eggert
e6c7091634 dd: doc improvement (Bug#54586)
* doc/coreutils.texi (dd invocation): Explain
fdatasync and fsync better.
2022-07-06 23:42:55 -05:00
Paul Eggert
8da1edffff 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.
2022-07-06 14:31:32 -05:00
Paul Eggert
1edda5009b 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).
2022-07-05 10:02:46 -05:00
Ivan Radić
fa332d998c maint: fix comment typo
* src/uniq.c: s/preceges/precedes/
2022-07-04 15:15:05 +01:00
Paul Eggert
9f71f478ec 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’”.
2022-06-24 11:03:00 -05:00
Jim Meyering
6c03e8fbb2 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.
2022-06-23 08:31:21 -07:00
Jim Meyering
7e6c39cc02 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.
2022-06-23 08:31:20 -07:00
Paul Eggert
fa7ed969c3 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 \<.
2022-06-20 22:23:24 -05:00
Paul Eggert
b54da709a1 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.
2022-06-11 10:53:59 -07:00
Paul Eggert
93e099e4c3 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.
2022-06-03 19:45:47 -07:00
Paul Eggert
0ae619f349 build: update gnulib submodule to latest
* bootstrap: Copy from latest Gnulib.
* tests/misc/ls-misc.pl (v_files): Adjust to new Gnulib behavior.
2022-06-03 19:45:47 -07:00
Bernhard Voelker
b3331d59e8 maint: fix spelling in NEWS entry
* NEWS: s/x86-64/x86_64/
2022-05-26 16:12:41 +02:00
Paul Eggert
8c1a447a37 maint: spelling fix 2022-05-25 11:49:13 -07:00
Paul Eggert
9104dad18b 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.
2022-05-25 11:24:09 -07:00
Paul Eggert
dc457c5e1b sort: refactor tricky diff reversal
* src/sort.c (diff_reversed): New function, to make the intent clearer.
(keycompare, compare): Use it.
2022-05-25 11:24:09 -07:00
Pádraig Brady
f0fb9cddc0 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.
2022-05-25 09:59:29 +01:00
Pádraig Brady
4e0167ea14 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
2022-05-25 09:47:40 +01:00
Paul Eggert
a351fdd6fc 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.
2022-05-17 19:30:55 -07:00
Paul Eggert
5864e8f919 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.
2022-05-17 19:30:55 -07:00
Paul Eggert
9f2fa50748 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.
2022-05-17 19:30:55 -07:00
Paul Eggert
7646618e70 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.
2022-05-17 19:30:55 -07:00
Paul Eggert
16e857509f build: update gnulib submodule to latest 2022-05-17 19:30:55 -07:00
Rasmus Villemoes
f45ab30c0b 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>
2022-05-09 14:38:01 +01:00
Pádraig Brady
ddafdae21c 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.
2022-05-02 21:26:59 +01:00
Paul Eggert
cfeb6b15a5 build: update gnulib submodule to latest 2022-05-02 10:04:49 -07:00
Paul Eggert
2f56f5a420 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.
2022-05-01 22:53:29 -07:00
Paul Eggert
e087525091 mv: test Bug#55029
* tests/mv/backup-dir.sh: New test for Bug#55029,
reported by Steve Ward.
2022-04-20 19:45:59 -07:00
Paul Eggert
6805e4dfc2 build: update gnulib submodule to latest 2022-04-20 19:45:59 -07:00
Paul Eggert
81d58df164 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.
2022-04-19 16:14:50 -07:00
Paul Eggert
913f14bbd0 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.
2022-04-19 13:40:38 -07:00
Paul Eggert
f0de24e53f doc: fix footnote formats
* doc/coreutils.texi: Reword footnote, or put it right next
to previous punctuation.
2022-04-19 13:40:38 -07:00
Paul Eggert
6106b56191 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.
2022-04-19 13:40:38 -07:00
Pádraig Brady
dd614d6011 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
2022-04-17 13:46:03 +01:00
Pádraig Brady
07d59f5a54 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2022-04-15 22:40:41 +01:00
Pádraig Brady
ca22b9eba0 version 9.1
* NEWS: Record release date.
2022-04-15 22:10:07 +01:00
Pádraig Brady
0f2cf20af6 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.
2022-04-15 18:28:38 +01:00
Pádraig Brady
bcfbcef928 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
2022-04-14 13:37:23 +01:00
Pádraig Brady
87d5f1e17e 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.
2022-04-13 20:10:14 +01:00
Pádraig Brady
48e15cef45 maint: syntax-check: fix preprocessor indentation
* gl/lib/targetdir.h: Keep '#' at start of line.
2022-04-13 12:21:01 +01:00
Paul Eggert
b411f21414 cp,mv,install: omit an ‘inline’
* gl/lib/targetdir.c (target_directory_operand):
Omit unnecessary ‘inline’.
2022-04-12 23:57:15 -07:00
Paul Eggert
f0a9f5e7da 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.
2022-04-12 23:57:15 -07:00
Paul Eggert
197a570ff0 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.
2022-04-12 23:57:15 -07:00
Paul Eggert
30c932a309 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.
2022-04-12 23:57:15 -07:00
Pádraig Brady
52139fd690 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.
2022-04-13 00:37:12 +01:00
Pádraig Brady
6e9bf0765f 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.
2022-04-13 00:36:25 +01:00
Pádraig Brady
4f920e93ec 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.
2022-04-13 00:36:25 +01:00
Pádraig Brady
f98dcbfc1c tests: env-S.pl: unset cygwin hardwired env vars
* tests/misc/env-S.pl: Unset SYSTEMROOT and WINDIR.
2022-04-13 00:36:25 +01:00
Pádraig Brady
028cad9149 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
2022-04-12 13:30:50 +01:00
Pádraig Brady
2122ceba8e tests: b2sum.sh: fix false failure on cygwin
* tests/misc/b2sum.sh: Avoid binary '*' tags when comparing checksums.
Reported by Bruno Haible
2022-04-11 15:47:16 +01:00
Pádraig Brady
e43099f6e9 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.
2022-04-11 15:47:16 +01:00
Pádraig Brady
021fc4fad2 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
2022-04-11 15:46:57 +01:00
Pádraig Brady
046ab76166 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.
2022-04-10 15:48:29 +01:00
Pádraig Brady
cc01b8a8f4 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.
2022-04-09 22:21:24 +01:00
Pádraig Brady
54bec51754 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
2022-04-09 13:00:52 +01:00
Pádraig Brady
d28e369960 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.27 which is now about 5 years old.
2022-04-08 17:08:32 +01:00
Bernhard Voelker
8f1f0dc975 maint: remove obsolete statat gnulib module
* bootstrap.conf (gnulib_modules): Remove statat.
2022-04-08 17:05:56 +01:00
Pádraig Brady
73c0c15225 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.
2022-04-07 17:38:17 +01:00
Pádraig Brady
224c1fee69 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
2022-04-04 13:41:32 +01:00
Pádraig Brady
8d9321ee0f doc: describe dd iseek as a feature not a change
* NEWS: Move description from "Changes in behavior"
to "New features".
2022-04-03 22:11:25 +01:00
Pádraig Brady
6b5134770d 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.
2022-04-03 22:10:35 +01:00
Ville Skyttä
52aeae2c3d 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
2022-04-03 20:59:38 +01:00
Pádraig Brady
120ce321d5 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
2022-03-29 16:34:10 +01:00
Pádraig Brady
e07c40c3ea maint: sync latest bootstrap from gnulib
* bootstrap: Should have updated this with the last gnulib update.
2022-03-25 19:08:28 +00:00
Pádraig Brady
500c697cc8 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().
2022-03-20 17:46:13 +00:00
Pádraig Brady
6367cfe5fc 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
2022-03-19 16:57:07 +00:00
Pádraig Brady
28adf9cf58 maint: move build-related NEWS item to its own section
* NEWS: Follow other Build-related patterns in NEWS.
2022-03-18 15:02:42 +00:00
Pádraig Brady
aa53e73974 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
2022-03-12 13:19:06 +00:00
Pádraig Brady
8767d75b9d 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.
2022-03-07 23:33:25 +00:00
Pádraig Brady
92cb8427c5 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
2022-03-07 23:33:21 +00:00
Rohan Sable
85c975df2c 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>
2022-03-07 23:26:42 +00:00
Pádraig Brady
3f61958495 build: ensure AT_NO_AUTOMOUNT is defined
update gnulib submodule to latest,
where this is the only change
2022-03-07 22:00:22 +00:00
Paul Eggert
4306bb6246 date: fix newly-introduced %%-N bug
* src/date.c (adjust_resolution): Don’t mishandle %%-N.
* tests/misc/date.pl (pct-pct): New test.
2022-03-05 11:23:38 -08:00
Paul Eggert
8f31074cb4 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.
2022-02-24 18:19:40 -08:00
Paul Eggert
3abaa2ad67 build: update gnulib submodule to latest 2022-02-24 18:19:40 -08:00
Pádraig Brady
6dc702928e 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
2022-02-24 13:58:06 +00:00
Pádraig Brady
677fb3e4ab tests: improve compat with macOS
* tests/misc/wc-nbsp.sh: Only the en_US.iso8859-1 form
is accepted on macOS 10.15.7 at least.  GNU/Linux also
accepts ISO-8859-1 (and canonicalizes the charmap to this).
2022-02-24 13:58:06 +00:00
Paul Eggert
97e9778296 dd: counts ending in "B" now count bytes
This implements my suggestion in Bug#54112.
* src/dd.c (usage): Document the change.
(parse_integer, scanargs): Implement the change.
Omit some now-obsolete checks for invalid flags.
* tests/dd/bytes.sh: Test the new behavior, while retaining
checks for the now-obsolete usage.
* tests/dd/nocache_eof.sh: Avoid now-obsolete usage.
2022-02-22 18:56:53 -08:00
Paul Eggert
ef694d3448 dd: improve doc relative to POSIX
* doc/coreutils.texi (dd invocation): Improve documentation,
clarifying whether features are extensions to POSIX.
2022-02-22 09:04:27 -08:00
Paul Eggert
4439ef3ec4 dd: support iseek= and oseek=
Alias iseek=N to skip=N, oseek=N to seek=N (Bug#45648).
* src/dd.c (scanargs): Parse iseek= and oseek=.
* tests/dd/skip-seek.pl (sk-seek5): New test case.
2022-02-22 09:04:27 -08:00
Paul Eggert
3f7519130a cp: avoid unnecessary buffer allocation
Do not allocate I/O buffer if copy_file_range suffices.
* src/copy.c (sparse_copy, lseek_copy): Buffer arg is now char **
instead of char *, and buffer is now allocated only if needed.
All uses changed.
2022-02-21 00:19:24 -08:00
Paul Eggert
7dbe465fd3 build: update gnulib submodule to latest 2022-02-19 15:54:45 -08:00
Pádraig Brady
cee468f9c5 doc: env: fix man page reference of exec(2) to exec(3p)
* man/env.x: Change exec() reference from section 2 to 3p.
2022-02-15 17:07:22 +00:00
Pádraig Brady
63228501e6 doc: use bold style for man page references
It's more common to use bold style than not,
for references to other man pages.
Ideally each man page renderer would highlight references,
but currently some rely on styles in the page itself.

* man/help2man: Implement a --bold-refs option that
will mark up references like "name(1)" with bold
style around the "name" component.
* man/local.mk: Pass --bold-refs to our help2man unless disabled.
* configure.ac: Add a --disable-bold-man-page-references option.
Addresses https://bugs.gnu.org/53977
2022-02-15 17:07:22 +00:00
Pádraig Brady
041dfff5db dircolors: speed up processing of TERM entries
* src/dircolors.c (main): Avoid glob matching
when we've already matched in a group of {COLOR,}TERM entries.
2022-02-15 17:01:19 +00:00
Pádraig Brady
75c9fc6740 dircolors: consider COLORTERM as well as TERM env vars
COLORTERM is an environment used usually to expose truecolor support in
terminal emulators.  Therefore support matches on that in addition
to TERM.  Also set the default COLORTERM match pattern so that
we apply colors if COLORTERM is any value.

This implicitly supports a terminal like "foot"
without a need for an explicit TERM entry.

* NEWS: Mention the new feature.
* src/dircolors.c (main): Match COLORTERM like we do for TERM.
* src/dircolors.hin: Add default config to match any COLORTERM.
* tests/misc/dircolors.pl: Add test cases.
2022-02-15 17:01:19 +00:00
Paul Eggert
0b0f1965fb tr: mention multibyte problem in man page
* man/tr.x: Document tr problem.
2022-02-14 12:16:40 -08:00
Paul Eggert
8d3dce9861 tr: improve multibyte etc. doc
Problem reported by Dan Jacobson (Bug#48248).
* doc/coreutils.texi (tr invocation): Improve documentation for
tr's failure to support multibyte characters POSIX-style.
* doc/coreutils.texi (tr invocation), src/tr.c (usage):
Use terminology closer to POSIX's.
2022-02-14 12:03:49 -08:00
Pádraig Brady
abc4533fe4 dircolors: add --print-ls-colors to display colored entries
* NEWS: Mention the new feature.
* doc/coreutils.texi (dircolors invocation): Describe the new
--print-ls-colors option.
* src/dircolors.c (print_ls_colors): A new global to select
between shell or terminal output.
(append_entry): A new function refactored from dc_parse_stream()
to append the entry in the appropriate format.
(dc_parse_stream): Adjust to call append_entry().
* tests/misc/dircolors.pl: Add test cases.
2022-02-13 18:25:59 +00:00
Pádraig Brady
26db930c81 chown,chgrp: reinstate numeric id output in -v messages
since gnulib commit ff208d546a,
related to coreutils commit v9.0-143-gabde15969
we no longer maintain numeric IDs through chopt->{user,group}_name.
Therefore we need to adjust to ensure tests/chown/basic.sh passes.

* src/chown-core.c (uid_to_str, gid_to_str): New helper functions
to convert numeric id to string.
(change_file_owner): Use the above new functions to pass
numeric ids to describe_change().
2022-02-13 14:20:16 +00:00
Paul Eggert
d8047ae86d sort: fix several version-sort problems
This also affects ls -v in some corner cases.
Problems reported by Michael Debertol <https://bugs.gnu.org/49239>.
While looking into this, I spotted some more areas where the
code and documentation did not agree, or where the documentation
was unclear.  In some cases I changed the code; in others
the documentation.  I hope things are nailed down better now.
* doc/sort-version.texi: Distinguish more carefully between
characters and bytes.  Say that non-identical strings can
compare equal, since they now can.  Improve readability in
various ways.  Make it clearer that a suffix can be the
entire string.
* src/ls.c (cmp_version): Fall back on strcmp if filevercmp
reports equality, since filevercmp is no longer a total order.
* src/sort.c (keycompare): Use filenvercmp, to treat NULs correctly.
* tests/misc/ls-misc.pl (v_files):
Adjust test to match new behavior.
* tests/misc/sort-version.sh: Add tests for stability,
and for sorting with NUL bytes.
2022-02-12 20:15:03 -08:00
Paul Eggert
e7ccf4775e build: update gnulib submodule to latest 2022-02-12 20:15:02 -08:00
Pádraig Brady
195e943be7 doc: avoid using "[" is URLS in --help output
* src/system.h (emit_ancillary_info): While supported if entered
  manually, the "[" character is not highlighted as part of a
  URL by default in terminals, so avoid using it.
  Addresses https://bugs.gnu.org/53946
2022-02-12 18:43:25 +00:00
Pádraig Brady
d35b305109 doc: adust --help, --version alignment
* src/system.h: Adjust the alignment of the --help
and --version option descriptions, to start at column 21.
This better aligns with the descriptions of most commands,
and also aligns with the minimum column a description must
start at to ensure a blank line is not output when a description
follows an option on a line by itself.
2022-02-12 18:23:48 +00:00
Pádraig Brady
a4d8d58429 doc: rmdir: improve --help formatting
* src/rmdir.c (usage): Move description to column 21,
so that a --long-option on its own line without a
trailing description, doesn't have an erroneous blank
line inserted between the option and description.
Also group descriptions with blank lines rather than indents,
so that man pages don't have erroneous blank lines
added within the description.
Addresses https://bugs.gnu.org/53946
2022-02-12 18:16:34 +00:00
Pádraig Brady
dc689eba57 doc: ls: reference dircolors(1) from --help
* src/ls.c (usage): s/dircolors/dircolors(1)/.
* man/ls.x [SEE ALSO]: Reference dircolors(1).
Addresses https://bugs.gnu.org/53946
2022-02-12 18:03:38 +00:00
Pádraig Brady
353ba4978f doc: ls: improve --help formatting
* src/ls.c (usage): Use blank lines to group multi-line
option descriptions, rather than indenting.
This results in more consistent alignment of descriptions,
and also avoids erroneous new lines in generated in man pages.
Addresses https://bugs.gnu.org/53946
2022-02-12 17:55:03 +00:00
Paul Eggert
cedf627a90 doc: improve version-sort doc
* doc/coreutils.texi, doc/sort-version.texi:
Capitalize “Coreutils”.
* doc/sort-version.texi: Don’t emphasize natural sort so much,
since Coreutils has just version sort.
Use the term “lexicographic” instead of “alphabetic” or “standard”.
Suggest combining ‘V’ with ‘b’, and show why ‘b’ is needed.
Use shorter titles for sections, as GNU Emacs displays info poorly
when titles are too long to fit in a line.
Use @samp instead of @code for samples of data.
Do not use @samp{@code{...}}; @samp{...} should suffice and
double-nesting looks bad with Emacs.
Omit blank lines in examples that would not be present
in actual shell sessions.
Quote with `` and '', not with " or with '.
Mention dpkg --compare-versions more prominently.
Don’t rely on "\n" being equivalent to "\\n" in shell args.
Prefer Unicode name for hyphen-minus.
2022-02-08 10:52:43 -08:00
Christian Hesse
b65ff7e4d0 dircolors: highlight .avif as image
This add highlighting for AV1 Image File Format (AVIF):
https://aomediacodec.github.io/av1-avif/

* src/dircolors.hin: Highlight .avif as image.

Signed-off-by: Christian Hesse <mail@eworm.de>
2022-02-07 13:51:24 +00:00
Paul Eggert
8a3dedfef9 date: test against bug#50115
* tests/misc/date.pl: Add test.
2022-02-05 13:47:07 -08:00
Paul Eggert
cf6c849899 build: update gnulib submodule to latest 2022-02-05 13:47:07 -08:00
Pádraig Brady
b52d66452d doc: fix somewhat ambiguous date format representation
* doc/coreutils.texi (date invocation): Remove @var{...} usage,
as that capitalizes in the representation and thus somewhat
ambiguates the format wrt Month and Minute.  This also avoids
a syntax check failure about redundant capitalization in @var{}.
2022-02-05 12:53:19 +00:00
Paul Eggert
67cd2c3b72 date: improve doc
Problem reported by Dan Jacobson (Bug#51288).
* doc/coreutils.texi (date invocation, Setting the time)
(Options for date):
* src/date.c (usage): Improve doc.
2022-02-04 18:21:46 -08:00
Paul Eggert
413a6cf521 build: update gnulib submodule to latest 2022-02-04 17:43:45 -08:00
Paul Eggert
abde159693 id: print groups of listed name
Problem reported by Vladimir D. Seleznev (Bug#53631).
* src/id.c (main): Do not canonicalize user name before
deciding what groups the user belongs to.
2022-02-04 14:53:35 -08:00
Bernhard Voelker
9a29ee2903 doc: add NEWS entry for recent cksum change
* NEWS (Changes in behavior): Add entry for commit v9.0-92-ga42a03913.
2022-02-01 13:13:05 +00:00
Paul Eggert
59da65b7fe maint: suppress bogus noreturn warnings
* configure.ac: Move the single-binary code before the
gcc-warnings code, so that the latter can depend on the former.
Suppress -Wsuggest-attribute=noreturn with single binaries,
to avoid diagnostics like the following:
  src/expr.c: In function 'single_binary_main_expr':
  error: function might be candidate for attribute 'noreturn'
Problem reported by Pádraig Brady in:
https://lists.gnu.org/r/coreutils/2022-01/msg00061.html
2022-01-31 22:09:37 -08:00
Paul Eggert
1b552e73e8 tr: pacify -fsanitizer=leak
* src/tr.c (main): Use main_exit, not return, in a couple of
places missed last time.
2022-01-31 22:09:37 -08:00
Paul Eggert
222eee9631 chgrp: fix typo in previous change
* src/chgrp.c (main): Use main_exit, not exit.
2022-01-31 22:09:37 -08:00
Paul Eggert
bcc479b0b5 maint: mark some _Noreturn functions
* src/basenc.c (finish_and_exit, do_encode, do_decode):
* src/comm.c (compare_files):
* src/tsort.c (tsort):
* src/uptime.c (uptime):
Mark with _Noreturn.  Otherwise, unoptimized compilations may warn
that the calling renamed-main function doesn't return a value,
when !lint and when single-binary.
2022-01-31 22:09:37 -08:00
Paul Eggert
fb7579768d df: fix memory leak
* src/df.c (devlist_free): Remove.
(filter_mount_list): Free all of devlist, instead of merely
the entries in devlist_table.
2022-01-31 22:09:37 -08:00
Pádraig Brady
253a46d09f maint: cut: avoid exporting recently added variable
* src/cut.c: Make output_delimiter_default static,
as identified by `make syntax-check`.
2022-01-31 22:00:12 +00:00
Paul Eggert
eb3cd9e97b maint: pacify gcc -flto -Wmaybe-uninitialized
* gl/lib/xdectoint.c (__xnumtoint): Tell gcc that ‘error’
does not return here.
* gl/modules/xdectoint (Depends-on): Add stdbool, verify.
2022-01-31 12:07:39 -08:00
Paul Eggert
604f8a6c4d dd: do not access uninitialized
* src/dd.c (parse_integer): Avoid undefined behavior
that accesses an uninitialized ‘n’ when e == LONGINT_INVALID.
Return more-accurate error code when INTMAX_MAX < n.
2022-01-31 12:07:39 -08:00
Paul Eggert
d0e3b0ae1a uptime: simplify -fsanitize=leak pacification
* src/uptime.c (uptime): Exit here ...
(main): ... instead of here.
2022-01-31 12:07:39 -08:00
Paul Eggert
701fcbc78e uniq: remove IF_LINT
* src/uniq.c (check_file): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
cb99998abe unexpand: remove IF_LINT
* src/unexpand.c (unexpand): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
0ea9aacee9 pr: remove IF_LINT
* src/pr.c (read_line): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
10ded12481 truncate: simplify
* src/truncate.c (do_ftruncate): Check != 0 instead of == -1.
Avoid a cast.
(main): Use C99 style decls after statements.
Simplify ‘open’ logic.
2022-01-31 12:07:39 -08:00
Paul Eggert
f8664b6c8e shred: remove IF_LINT
* src/shred.c (dopass): Remove a no-longer-needed IF_LINT.

(read_line): Remove an IF_LINT; no longer needed with
today’s GCC.
2022-01-31 12:07:39 -08:00
Paul Eggert
5288f5ab5e pr: simplify -fsanitize=leak pacification
* src/pr.c (main): Remove an IF_LINT.
Use main_exit rather than return.
2022-01-31 12:07:39 -08:00
Paul Eggert
75a87dc038 pinky: simplify -fsanitize=leak pacification
* src/pinky.c (short_pinky): exit instead of freeing.
2022-01-31 12:07:39 -08:00
Paul Eggert
00973ca777 paste: remove IF_LINT
* src/paste.c (paste_parallel): Remove no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
aafa9bf069 hostname: simplify
* src/hostname.c (sethostname): Provide a substitute on all
platforms, to simplify the mainline code.
(main): Simplify.  Remove an IF_LINT.
Use main_exit rather than return.
2022-01-31 12:07:39 -08:00
Paul Eggert
dba02d1996 factor: remove IF_LINT
* src/factor.c (factor_using_squfof) [USE_SQUFOF]:
Use plain assert (...), not IF_LINT (assert (...)).
This code is currently never compiled or executed,
so this is merely a symbolic cleanup.
2022-01-31 12:07:39 -08:00
Paul Eggert
ec8f3ea958 expand: remove IF_LINT
* src/expand.c (expand): Remove no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
ed93b50eea env: simplify -fsanitize=leak pacification
* src/env.c (unset_envvars): Remove IF_LINT code.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
04d735ea96 md5sum: remove IF_LINTs
* src/digest.c (digest_check): Remove IF_LINTs that are no longer
needed, as GCC has gotten smarter since 2008.
2022-01-31 12:07:39 -08:00
Paul Eggert
c55372d0d8 df: simplify -fsanitize=leak pacification
* src/df.c (print_table, main) [lint]: Omit unnecessary cleanup.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
7e7ecf20aa date: simplify -fsanitize=leak pacification
* src/date.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
423fed3dd8 cut: simplify and remove an IF_LINT
* src/cut.c (enum operating_mode, operating_mode)
(output_delimiter_specified, cut_stream):
Remove; no longer needed.
(output_delimiter_default): New static var.  Code can now
use ‘output_delimiter_string != output_delimiter_default’
instead of ‘output_delimiter_specified’.
(cut_file): New arg CUT_STREAM.  Caller changed.
(main): Simplify.  Coalesce duplicate code.  Redo to avoid need
for IF_LINT, or for the static var.  No need to xstrdup optarg.
2022-01-31 12:07:39 -08:00
Paul Eggert
22a0f9c32e cut: simplify -fsanitize=leak pacification
* src/set-fields.c (reset_fields): Remove, as it’s not needed for
-fsanitize=leak even when ‘lint’ is defined.  All uses removed.
2022-01-31 12:07:39 -08:00
Paul Eggert
836617fa12 cp: simplify GCC pacification
* src/cp.c (make_dir_parents_private): Remove IF_LINT code that is
no longer needed, as GCC has apparently gotten smarter since 2008.
2022-01-31 12:07:39 -08:00
Paul Eggert
904f9e3bf4 chown: simplify -fsanitize=leak pacification
* src/chgrp.c, src/chown.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
e55ffab35b basenc: simplify -fsanitize=leak pacification
* src/basenc.c (finish_and_exit): New function.
(do_encode, do_decode): Use it.  Accept new INFILE arg.  Remove
no-longer-needed IF_LINT code.  Exit when done.  Caller changed.
2022-01-31 12:07:39 -08:00
Paul Eggert
e2feea68ac test: simplify gcc pacification
* src/test.c (get_mtime) [lint]: Omit ifdef lint code that is no
longer needed, as GCC has gotten smarter since 2005.
2022-01-31 12:07:39 -08:00
Paul Eggert
a72fc9ba5f tail: simplify -fsanitize=leak pacification
Also, close a no-longer-needed file descriptor when falling
back from inotify.
* src/tail.c (tail_forever_inotify): Return void, not bool.  Exit
on fatal error, or on successful completion.  Accept an extra
argument pointing to a hash table that the caller should free on
non-fatal error; this simplifies cleanup.  Don’t bother setting
errno when returning.  Caller changed.
(main): Omit no-longer-needed IF_LINT code.  Close inotify
descriptor if inotify fails; this fixes a file descriptor leak and
means we needn’t call inotify_rm_watch.  Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
f3984a6dba tac: simplify -fsanitize=leak pacification
* src/tac.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
0106b5a4b8 shuf: simplify -fsanitize=leak pacification
* src/shuf.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
8692f2a6d3 numfmt: simplify -fsanitize=leak pacification
* src/numfmt.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
6ca7266666 mktemp: simplify -fsanitize=leak pacification
* src/mktemp.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
d85374258a dd: simplify -fsanitize=leak pacification
* src/dd.c (cleanup) [lint]: Omit unnecessary cleanup.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
f21ccfb02c cp: simplify cp/install/ln/mv pacification
* src/copy.c (dest_info_free, src_info_free) [lint]:
Remove.  All uses removed.
(copy_internal): Pacify only Clang and Coverity; GCC doesn’t need it.
* src/cp-hash.c (forget_all) [lint]: Remove.  All uses removed.
* src/cp.c, src/install.c, src/ln.c, src/mv.c (main):
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
b50b63e06c chmod: pacify -fsanitizer=leak
* src/chmod.c (main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
8fe6dd3b77 yes: pacify -fsanitizer=leak
* src/yes.c (main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
a7de740baa tsort: pacify -fsanitizer=leak
* src/tsort.c (detect_loop): Free removed successor.
2022-01-31 12:07:39 -08:00
Paul Eggert
a08853948c sort: pacify -fsanitizer=leak
* src/sort.c (pipe_fork, keycompare, sort, main):
Remove lint code that no longer seems to be needed.
(sort): Unconditionally compile ifdef lint code that is needed
to free storage even when not linting.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
06b45ef985 split: pacify -fsanitizer=leak
* src/split.c (lines_rr): New arg FILESP.  All uses changed.
(main): Use main_exit, not return.  Omit unnecessary alignfree.
2022-01-31 12:07:39 -08:00
Paul Eggert
75b50689f1 ptx: pacify -fsanitizer=leak
* src/ptx.c (unescape_string): Rename from copy_unescaped_string,
and unescape the string in place.  Callers changed.  This way,
we needn’t allocate storage and thus needn’t worry about
-fsanitizer=leak.
2022-01-31 12:07:39 -08:00
Paul Eggert
b29f782a3f seq: pacify -fsanitizer=leak
* src/seq.c (seq_fast): If successful, exit rather than returning true.
Callers changed.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
05e889b7d5 tsort: pacify -fsanitizer=leak
* src/tsort.c (struct item.balance): Now signed char to save space.
(struct item.printed): New member.
(new_item): Initialize k->printed to false.  Simplify via xzalloc.
(scan_zeros): Use k->printed rather than nulling out string.
(tsort): Move exiting code here ...
(main): ... from here.
(tsort) [lint]: Omit no-longer-needed code.  Instead, set head->printed.
2022-01-31 12:07:39 -08:00
Paul Eggert
1a83573596 tr: pacify -fsanitizer=leak
* src/tr.c (main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
7a9bda0477 stat: pacify -fsanitizer=leak
* src/stat.c (main):  Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
9b2a58ba64 comm: pacify -fsanitizer=leak
* src/comm.c (compare_files): Move exiting code here ...
(main): ... from here, to pacify gcc -fsanitize=leak.
2022-01-31 12:07:38 -08:00
Paul Eggert
afa93e8804 expr: lint cleanup, and introducing main_exit
This introduces a new macro main_exit, which is useful
for pacifying gcc -fsanitizer=lint and in some cases
means we can remove some ‘IF_LINT’ and ‘ifdef lint’ code.
* src/expr.c (main): Use main_exit, not return.
(docolon): Omit an IF_LINT that GCC no longer needs.
* src/system.h (main_exit): New macro.
2022-01-31 12:07:38 -08:00
Pádraig Brady
a42a039132 cksum: use more exact selection of digest algorithms
Use more constrained argument matching
to improve forward compatibility and robustness.

For example it's better that `cksum -a sha3` is _not_
equivalent to `cksum -a sha386`, so that a user
specifying `-a sha3` on an older cksum would not be surprised.

Also argmatch() is used when parsing tags from lines like:
SHA3 (filename) = abcedf....
so it's more robust that older cksum instances to fail
earlier in the parsing process, when parsing output from
possible future cksum implementations that might support SHA3.

* src/digest.c (algorithm_from_tag): Use argmatch_exact()
to ensure we don't match abbreviated algorithms.
(main): Likewise.
* tests/misc/cksum-a.sh: Add a test case.
2022-01-30 23:13:52 +00:00
Pádraig Brady
703e0487e4 build: update gnulib submodule to latest
To provide argmatch_exact() that does not
use abbreviated matching, to be used by cksum.
2022-01-30 20:34:29 +00:00
Paul Eggert
57c812cc3e mv: when installing to dir use dir-relative names
When the destination for mv is a directory, use functions like openat
to access the destination files, when such functions are available.
This should be more efficient and should avoid some race conditions.
Likewise for 'install'.
* src/cp.c (must_be_working_directory, target_directory_operand)
(target_dirfd_valid): Move from here ...
* src/system.h: ... to here, so that install and mv can use them.
Make them inline so GCC doesn’t complain.
* src/install.c (lchown) [HAVE_LCHOWN]: Remove; no longer needed.
(need_copy, copy_file, change_attributes, change_timestamps)
(install_file_in_file, install_file_in_dir):
New args for directory-relative names.  All uses changed.
Continue to pass full names as needed, for diagnostics and for
lower-level functions that do not support directory-relative names.
(install_file_in_dir): Update *TARGET_DIRFD as needed.
(main): Handle target-directory in the new, cp-like way.
* src/mv.c (remove_trailing_slashes): Remove static var; now local.
(do_move): New args for directory-relative names.  All uses changed.
Continue to pass full names as needed, for diagnostics and for
lower-level functions that do not support directory-relative names.
(movefile): Remove; no longer needed.
(main): Handle target-directory in the new, cp-like way.
* tests/install/basic-1.sh:
* tests/mv/diag.sh: Adjust to match new diagnostic wording.
2022-01-29 16:29:18 -08:00
Paul Eggert
534cfbb448 cp: fix comment typo 2022-01-29 16:29:18 -08:00
Pádraig Brady
795a16627c doc: NEWS: explain _why_ copy_file_range() is used
* NEWS: Mention why we're making the change in behavior in cat(1).
2022-01-28 15:13:25 +00:00
Pádraig Brady
2fb945ef77 build: update gnulib submodule to latest
To fix a syntax-check false failure
2022-01-28 15:07:14 +00:00
Paul Eggert
50e438972b dd: synchronize output after write errors
Problem reported by Sworddragon (Bug#51345).
* src/dd.c (cleanup): Synchronize output unless dd has been interrupted.
(synchronize_output): New function, split out from dd_copy.
Update conversions_mask so synchronization is done at most once.
(main): Do not die with the output file open, since we want to be
able to synchronize it before exiting.  Synchronize output before
exiting.
2022-01-28 00:01:55 -08:00
Paul Eggert
c4f9554ee9 dd: output final progress before syncing
Problem reported by Sworddragon (Bug#51482).
* src/dd.c (reported_w_bytes): New var.
(print_xfer_stats): Set it.
(dd_copy): Print a final progress report if useful before
synchronizing output data.
2022-01-27 18:35:02 -08:00
Paul Eggert
816d84f138 cat: prefer copy_file_range to read+write
* src/cat.c (copy_cat): New function.
(main): Use it.
2022-01-27 13:04:14 -08:00
Paul Eggert
3b98e21eed csplit: improve integer overflow checking
* src/csplit.c: Prefer signed integers to unsigned for sizes
when either will do.  Check for some unlikely overflows.
(INCR_SIZE): Remove; no longer used.
(free_buffer): Also free the arg, simplifying callers.
(get_new_buffer): Use xpalloc instead of computing new
size by hand.  Add ATTRIBUTE_DEALLOC.
(delete_all_files, close_output_file):
If unlink fails with ENOENT, treat it as success.
(close_output_file): If unlink fails, decrement count anyway.
(parse_repeat_count, parse_patterns): Check for int overflow.
(check_format_conv_type): Use signed format.
2022-01-27 13:04:14 -08:00
Paul Eggert
b973d2d44a maint: simplify memory alignment
Use the new Gnulib modules alignalloc and xalignalloc
to simplify some memory allocation.
Also, fix some unlikely integer overflow problems.
* bootstrap.conf (gnulib_modules): Add alignalloc, xalignalloc.
* src/cat.c, src/copy.c, src/dd.c, src/shred.c, src/split.c:
Include alignalloc.h.
* src/cat.c (main):
* src/copy.c (copy_reg):
* src/dd.c (alloc_ibuf, alloc_obuf):
* src/shred.c (dopass):
* src/split.c (main):
Use alignalloc/xalignalloc/alignfree instead of doing page
alignment by hand.
* src/cat.c (main):
Check for integer overflow in page size calculations.
* src/dd.c (INPUT_BLOCK_SLOP, OUTPUT_BLOCK_SLOP, MAX_BLOCKSIZE):
(real_ibuf, real_obuf) [lint]:
Remove; no longer needed.
(cleanup) [lint]:
(scanargs): Simplify.
* src/ioblksize.h (io_blksize): Do not allow blocksizes largest
than the largest power of two that fits in idx_t and size_t.
* src/shred.c (PAGE_ALIGN_SLOP, PATTERNBUF_SIZE): Remove.
2022-01-27 13:04:14 -08:00
Paul Eggert
1a8a566963 build: update gnulib submodule to latest 2022-01-27 13:04:14 -08:00
Paul Eggert
fbc7958b36 copy: remove unnecessary ‘free’
* src/copy.c (copy_reg): Remove a ‘free’ call that does nothing
because its argument is always a null pointer, starting with
2007-11-1608:31:15Z!jim@meyering.net.
2022-01-27 13:04:14 -08:00
Paul Eggert
f19bc026b3 dd: simplify conv=swab code
Simplify byte-swapping, so that the code no longer needs to
allocate a page before the input buffer.
* src/dd.c (SWAB_ALIGN_OFFSET, char_is_saved, saved_char): Remove.
All uses removed.
(INPUT_BLOCK_SLOP): Simplify to just page_size.
(alloc_ibuf, dd_copy): Adjust to new swab_buffer API.
(swab_buffer): New arg SAVED_BYTE, taking the place of the old
global variables.  Do not access BUF[-1].
2022-01-27 13:04:14 -08:00
Paul Eggert
e94d95075d dd: improve integer overflow checking
* src/dd.c: Prefer signed to unsigned types where either will do,
as this helps improve checking with gcc -fsanitize=undefined.
Limit the signed types to their intended ranges.
(MAX_BLOCKSIZE): Don’t exceed IDX_MAX - slop either.
(input_offset_overflow): Remove; overflow now denoted by negative.
(parse_integer): Return INTMAX_MAX on overflow, instead of unspecified.
Do not falsely report overflow for ‘00x99999999999999999999999999999’.
* tests/dd/misc.sh: New test for 00xBIG.
* tests/dd/skip-seek-past-file.sh: Adjust to new diagnostic wording.
New test for BIGxBIG.
2022-01-27 13:04:14 -08:00
Paul Eggert
e462d928b0 shred: fix declaration typo
* gl/lib/randint.h (randint_all_new):
Do not declare with _GL_ATTRIBUTE_NONNULL (), as
the arg can be a null pointer.  This fixes a typo added in
2021-11-01T05:30:28Z!eggert@cs.ucla.edu.
2022-01-27 13:04:14 -08:00
Paul Eggert
4ec55ec0bd cat: prefer signed to unsigned
* src/cat.c: Prefer signed to unsigned types
where either will do, as they allow for better
overflow checking at runtime.
2022-01-27 13:04:14 -08:00
Paul Eggert
a36bc1910f cat: improve style
* cat.c: Improve style a bit, mostly by assuming C99-style
declarations after statements
2022-01-27 13:04:14 -08:00
Pádraig Brady
4a0a8fdbec doc: csplit: clarify [OFFSET] syntax
* src/csplit.c (usage): Clarify that '+' prefix is optional on OFFSET.
* doc/coreutils.texi (csplit invocation): Likewise.
Fixes https://bugs.gnu.org/53574
2022-01-27 13:07:28 +00:00
Paul Eggert
2ba6fb653c build: allow readlinkat calls
Problem reported by Bernhard Voelker in:
https://lists.gnu.org/r/coreutils/2022-01/msg00026.html
* cfg.mk (sc_prohibit_readlink): Remove.  It’s OK to call
readlinkat to determine whether a file is a symbolic link.
2022-01-15 12:12:49 -08:00
Paul Eggert
b197885b2d cp: rely on Gnulib for copy_file_range workaround
Gnulib now replaces copy_file_range on buggy hosts
so there is no need for Coreutils to worry about the bug.
* src/copy.c: Do not include sys/utsname.h, xstrtol.h.
(functional_copy_file_range): Remove.  All uses now
simply call copy_file_range.
2022-01-14 17:44:49 -08:00
Paul Eggert
db539b7c34 build: update gnulib submodule to latest 2022-01-14 17:44:49 -08:00
Paul Eggert
6df8e86208 doc: fix pluralization typo 2022-01-14 15:47:41 -08:00
Paul Eggert
f39a02a744 cp: fix two typos in previous change
Somehow ‘make check’ didn’t catch these the first few times.
* src/copy.c (copy_dir): Don’t pass null pointer to
copy_internal where it now expects non-null if move mode.
* src/cp.c (make_dir_parents_private): Initialize *attr_list
before recentely-added quick return.
2022-01-14 15:17:54 -08:00
Paul Eggert
95d6754451 cp: omit unnecessary stat of destination
'cp A B' attempts to open B as a directory, to see whether to
write to B/A instead of to B.  In the common case where the
open fails with ENOENT, do not bother to stat B afterwards
since the stat should also fail with ENOENT.
* src/copy.c (copy_internal, copy): Change bool arg about
nonexistent destination to a 3-way int argument.  All callers changed.
(copy_internal): Do not bother to stat a destination already known
to not exist when following symlinks.
2022-01-14 14:09:25 -08:00
Paul Eggert
43fa191b5a build: update gnulib submodule to latest 2022-01-13 12:02:16 -08:00
Paul Eggert
e2daa8f797 cp: when copying to dir use dir-relative names
When copying to a directory, use functions like openat to access
the destination files, when such functions are available.  This
should be more efficient and should avoid some race conditions.
* bootstrap.conf (gnulib_modules): Add areadlinkat-with-size,
fchmodat, fchownat, mkdirat, mkfifoat, utimensat.
* src/copy.c (lchown) [!HAVE_LCHOWN]:
* src/copy.c, src/system.h (rpl_mkfifo, mkfifo) [!HAVE_MKFIFO]:
Remove.  All uses removed.
(utimens_symlink): Remove; we shouldn’t have to worry about
those obsolete systems any more.  All uses replaced by utimensat.
* src/copy.c (copy_dir, set_owner, fchmod_or_lchmod, copy_reg)
(same_file_ok, writable_destination, overwrite_ok, abandon_move)
(create_hard_link, src_is_dst_backup, copy_internal, copy):
* src/cp.c (make_dir_parents_private, re_protect):
New args for directory-relative names.  All uses changed.
Continue to pass full names as needed, for diagnostics and for
lower-level functions like qset_acl that do not support
directory-relative names.
* src/copy.c (copy_reg): Prefer readlinkat to lstatat for merely
checking whether a file is a symlink, to avoid EOVERFLOW issues.
(subst_suffix): New function.
(create_hard_link): Accept a null SRC_NAME as meaning that if it
is needed it needs to be constructed from SRC_RELNAME, DST_NAME,
and DST_RELNAME.
(source_is_dst_backup): Use subst_suffix instead of doing it by hand.
(copy_internal): Remember and use directory-relative names instead
of full names.
* src/cp.c (lchown) [!HAVE_LCHOWN]: Remove.  All uses removed.
(must_be_working_directory): New function.
(target_directory_operand): Simply take file name as arg,
and return a file descriptor or negative number on failure;
open with O_DIRECTORY to obtain any file descriptor.
All uses changed.
(target_dirfd_valid): New function.
(do_copy): Use these new functions to obtain a file descriptor
for any target directory, and use directory-relative names
for that directory.
(main): Omit no-longer-needed stat when --target-directory,
as do_copy now does this.
* src/ln.c (O_PATHSEARCH): Move from here ...
* src/system.h: ... to here.
* tests/cp/fail-perm.sh: Adjust to change in diagnostic wording,
and add a test for --no-target-directory.
2022-01-13 11:36:51 -08:00
Paul Eggert
3f488e1d52 cp: tweak internal name
* src/cp.c (do_copy): Omit confusingly-named local new_dest, since
there’s another var new_dst that means something quite different.
2022-01-13 11:36:51 -08:00
Daniel Knittl-Frank
95ec19ecbd scripts: fix typo in commit-msg git-hook script
Commit 2f438fa9f5 (basenc: A new program
complementary to base64/base32) introduced a typo in the list of allowed
commit message prefixes, accidentally changing "basename" to
"nbasename".  Revert it back to the correct "basename".
2022-01-12 22:59:30 +00:00
Paul Eggert
73bd6306d1 df: tiny simplification
* src/df.c (LOG_EQ): Remove.  All callers replaced by ==.
2022-01-07 14:56:55 -08:00
Pádraig Brady
3067a9293a 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.
2022-01-02 16:15:55 +00:00
Pádraig Brady
76700e775e build: update gnulib submodule to latest
mainly to get updated copyright year

* doc/fdl.texi: Sync from gnulib.
* .gitignore: Add lib/unictype, as bitmap.h therein is depended on
since gnulib commit f698ea71
2022-01-02 16:14:40 +00:00
Paul Eggert
840ae54cf5 date: new option --resolution
* NEWS, doc/coreutils.texi (Options for date): Mention this.
* src/date.c (RESOLUTION_OPTION): New constant.
(DEBUG_DATE_PARSING_OPTION): Rename from DEBUG_DATE_PARSING.
All uses changed.
(long_options, usage, main): Support --resolution.
2021-12-31 10:53:29 -08:00
Paul Eggert
0cd39a246a date: %-N now means suppress extra digits
* NEWS, doc/coreutils.texi: Mention this.
* bootstrap.conf (gnulib_modules): Add gettime-res.
* src/date.c (res_width, adjust_resolution): New functions.
(main): Adjust %-N to be %9N, or whatever, before using it.
2021-12-31 10:53:29 -08:00
Paul Eggert
64b65cf4b8 build: update gnulib submodule to latest 2021-12-31 10:53:29 -08:00
Paul Eggert
1011b88594 doc: Document , vs . in date --rfc-3339=ns 2021-12-31 10:53:29 -08:00
Paul Eggert
6812e6baa7 build: port to AIX 7.1
This fixes a porting bug introduced in
2019-08-12T03:29:00Z!bruno@clisp.org.
Problem discovered on AIX 7.1.
* src/local.mk (LDADD): Add $(LIB_MBRTOWC), since pretty much
every command uses quotearg or mbrtowc or whatever.
(src_sort_LDADD): Add $(LIBPMULTITHREAD) and
$(LIB_PTHREAD_SIGMASK) instead of $(LIBTHREAD).
2021-12-31 10:53:29 -08:00
Paul Eggert
aa670bed50 build: be more careful about Perl
Problem reported by Serge Belyshev (Bug#52844).
* configure.ac (HAVE_PERL): Rely on latest Gnulib gl_PERL, which
sets gl_cv_prog_perl.
2021-12-28 02:03:42 -08:00
Paul Eggert
2f60fa465e build: update gnulib submodule to latest 2021-12-28 02:03:42 -08:00
Max Filippov
5bc9d92868 all: fix adjustment of /proc/$pid/cmdline by single binary
When configured with --enable-single-binary tools issue incorrect prctl:

  prctl(PR_SET_KEEPCAPS, ...)      = -1 EINVAL (Invalid argument)

PR_SET_MM_ARG_START is not a prctl 'option' parameter, it's 'arg2'
parameter for the option PR_SET_MM.  It also has to have 'arg4' and
'arg5' set to 0 explicitly, otherwise the kernel also returns -EINVAL.

* src/coreutils.c (launch_program): Fix prctl arguments.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/52800
2021-12-27 12:09:39 +00:00
Paul Eggert
5475fd6fe0 ls: improve doc for =WHEN
* src/ls.c (usage): Improve clarity of =WHEN args (Bug#52782).
2021-12-24 15:26:16 -08:00
Paul Eggert
d5ae6d8120 doc: colorize -> color
Living so close to Hollywood I know that "colorize"
means adding color to something that was already monochrome,
whereas "color" means to give color to something.
Coreutils apps color text instead of colorizing it.
2021-12-24 09:49:21 -08:00
Bernhard Voelker
1435e8e5c5 maint: update tests/init.sh from gnulib
* tests/init.sh: Sync from gnulib/tests/init.sh.
A recent gnulib update (4f497bf3c) missed this.
2021-12-20 23:13:36 +01:00
Jim Meyering
eb2400fb9f maint: syntax-check requires "char const *", not "const char *"
* gl/lib/mbsalign.c (mbs_align_pad): Adjust.
* src/chroot.c (is_root): Adjust.
* src/digest.c (main): Adjust.
* src/relpath.c (buffer_or_output) Adjust.
* src/ls.c (print_name_with_quoting, get_color_indicator): Adjust.
2021-12-20 12:50:08 -08:00
Jim Meyering
1cfbd4548d maint: split a long line
* src/test.c (three_arguments): Split long line.
2021-12-20 12:50:08 -08:00
Jim Meyering
a2b21e9105 maint: commit-msg: compute UTF-8-aware line-length
* scripts/git-hooks/commit-msg: Count UTF-8 characters rather
than bytes to avoid erroneously rejecting as "longer than 72" a
log message line like the UTF-8 one for id.c just prior.  It has
77 bytes but only 67 characters.
(check_msg): Read in "utf8" mode. Also include actual length
in the diagnostic.
(main): Don't loop when stdout is redirected, as it is when
invoked via vc-dwim.
Paul Eggert reported privately both the error of counting bytes
rather than chars and the re_edit loop when failing via vc-dwim.
2021-12-20 10:46:11 -08:00
Paul Eggert
915a5e3360 id: improve doc for when USER is omitted
* src/id.c (usage): “current user” → “current process” (Bug#52656).
2021-12-19 09:17:08 -08:00
Paul Eggert
8621e44cda maint: use GNU style for spacing 2021-12-18 09:35:04 -08:00
Bruno Haible
3bf118dad0 build: non-recursive Automake in a less hacky way
* bootstrap.conf (gnulib_modules): Remove
non-recursive-gnulib-prefix-hack.
(gnulib_tool_option_extras): Add --automake-subdir.
(bootstrap_post_import_hook): No need to massage lib/gnulib.mk.
2021-12-16 09:33:12 -08:00
Paul Eggert
064b31eb48 build: update bootstrap to latest 2021-12-16 09:33:12 -08:00
Paul Eggert
1827ae8243 build: update gnulib submodule to latest 2021-12-16 09:33:12 -08:00
Jim Meyering
bbc5e84513 maint: factor.c: avoid new GCC 12 warning
* src/factor.c (millerrabin2): Mark as ATTRIBUTE_PURE,
per advice from GCC 12.
2021-12-14 19:52:50 -08:00
Paul Eggert
bfc7a9b5e0 build: update gnulib submodule to latest
* NEWS: Mention the bugfix.
2021-12-14 12:47:36 -08:00
Paul Eggert
8931d571d0 mv: Bug#52410 fix
The recent Gnulib update fixed this bug reported by Vincent Vermilya.
* tests/mv/backup-dir.sh: Test for Bug#52410.
2021-12-10 14:10:51 -08:00
Paul Eggert
4f497bf3c7 build: update gnulib submodule to latest 2021-12-10 14:10:50 -08:00
Paul Eggert
e3d1ff0437 uname: port to recent macOS
Problem reported by Jakub Sokołowski (bug #52330).
* src/uname.c [__APPLE__]: Don’t include sys/syctl.h,
mach/machine.h, mach-o/arch.h.
(print_element_env): New function.  With __APPLE__, it defers to the
env var UNAME_MACHINE (if given) for uname -m, and similarly for -nrsv.
(main): Use it.  For -p with __APPLE__, rely on predefined macros
and omit any 64-bit indication, for compatibility with macOS uname.
2021-12-07 14:00:42 -08:00
Paul Eggert
5e36c0ce07 cp: clone on macOS
* configure.ac: Check for fclonefileat.
* src/copy.c [HAVE_FCLONEFILEAT && !USE_XATTR]:
Include <sys/clonefile.h>.
(copy_reg): If possible, use fclonefileat to clone.
2021-11-21 19:13:03 -08:00
Paul Eggert
41bec08d7a cp: streamline cloning by skipping fstat
* src/copy.c (copy_reg): Attempt clone_file before fstat of dest,
so that if clone_file succeeds we can skip the fstat.
2021-11-21 12:32:46 -08:00
Paul Eggert
5012223d78 cp: fix --preserve=ownership permissions bug
This fixes a bug that I introduced in
2006-12-06T19:44:08Z!eggert@cs.ucla.edu.
* src/copy.c (USE_XATTR): New macro.
(copy_reg): Use it to help the compiler.  Prefer open u+w to a
later chmod u=rw; u+r isn’t needed for xattr.  For the later u-r,
do only one (or zero) chmod calls instead of two (or one).
In the last chmod, respect the umask instead of ignoring it.
* tests/cp/preserve-mode.sh: Test for the bug.
2021-11-20 13:50:35 -08:00
Paul Eggert
3e2d644483 maint: prefer MAYBE_UNUSED
Prefer MAYBE_UNUSED to _GL_UNUSED, since the C2x syntax
will be [[maybe_unused]] at the start of the declaration,
and we want to look forward to that.  All uses of _GL_UNUSED
either changed to MAYBE_UNUSED, or (when not needed) removed.
2021-11-18 21:37:38 -08:00
Paul Eggert
d0f035fc64 cp: fix security context race
This fixes an issue introduced in the fix for Bug#11100.
* NEWS: Mention this.
* src/copy.c (copy_reg): Fix obscure bug where open-without-CREAT
failed with ENOENT and we forget to call set_process_security_ctx
before calling open-with-CREAT. Also, don’t bother to unlink
DST_NAME if open failed with ENOENT; and if unlink fails with
ENOENT, don’t consider that to be an error (someone else could
have removed the file for us, and that’s OK).  Also, don’t worry
about move mode, since we use O_EXCL|O_CREAT and so won’t open
an existing file.
2021-11-18 08:31:59 -08:00
Paul Eggert
0f84467a34 maint: update NEWS for macOS fix 2021-11-16 17:06:36 -08:00
Paul Eggert
0060ef82ee cp: minor clarity tweak
* src/copy.c (copy_reg): Use cached data_copy_required.
2021-11-16 16:51:44 -08:00
Paul Eggert
08930f21cb cp: fix ptrdiff_t/ssize_t theoretical glitches
* src/copy.c (sparse_copy): Use system.h’s SSIZE_MAX.
Don’t assume SSIZE_MAX <= PTRDIFF_MAX.
2021-11-16 16:11:27 -08:00
Paul Eggert
eae8df0d94 build: update gnulib submodule to latest 2021-11-15 22:36:57 -08:00
Paul Eggert
1b988ffa95 maint: fix nonnull decl
* gl/lib/randread.h (randread_new): Do not mark with
_GL_ATTRIBUTE_RETURNS_NONNULL, since it can return NULL.
2021-11-15 22:22:24 -08:00
Paul Eggert
0f4d9e849b build: update gnulib submodule to latest 2021-11-15 15:26:19 -08:00
Pádraig Brady
2378a53143 tests: avoid false failure in env-signal-handler.sh
* tests/misc/env-signal-handler.sh: Use retry_delay_ to
avoid a false failure under load, where env hasn't setup
the SIGINT handling before timeout(1) sends the SIGINT.
Fixes https://bugs.gnu.org/51793
2021-11-13 14:38:08 +00:00
Pádraig Brady
a0468760ff maint: fix recent syntax-check failures
* cfg.mk (exclude_file_name_regexp--sc_system_h_headers):
Add chown-core.h to the regexp, to better decouple from system.h.
* src/env.c: Remove minmax.h include already included in system.h.
* src/libstdbuf.c: Likewise.
* src/prog-fprintf.h: Remove doubled semicolon.
2021-11-01 13:45:15 +00:00
Paul Eggert
ea02406748 maint: use minmax.h instead of rolling our own
* gl/lib/mbsalign.c, gl/lib/randread.c, src/system.h (MAX, MIN):
Remove; include minmax.h instead.
* gl/modules/mbsalign, gl/modules/randread (Depends-on): Add minmax.
* src/factor.c (MIN): Remove.
2021-10-31 22:36:46 -07:00
Paul Eggert
9f8a38414b maint: add function attributes to .h files
Add _GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_MALLOC,
_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DALLOC_FREE,
_GL_ATTRIBUTE_RETURNS_NONNULL to .h files when appropriate.
* gl/lib/mbsalign.h, gl/lib/randperm.h, src/chown-core.h:
Include stdlib.h, for the benefit of _GL_ATTRIBUTE_DALLOC_FREE.
* gl/lib/randread.c (randread_free_body): New static function.
(randread_new, randread_free): Use it.
* src/copy.c (valid_options): Remove assert that is no longer
needed because it is now checked statically.
2021-10-31 22:36:46 -07:00
Paul Eggert
25e68323b9 maint: enable -Wsuggest-attribute=format
* configure.ac (WERROR_CFLAGS): Enable -Wsuggest-attribute=format
for lib/ and src/.
* src/copy.c (copy_attr_error, copy_attr_allerror):
Add ATTRIBUTE_FORMAT.
(copy_attr): Ignore -Wsuggest-attribute=format in the
small section of code that needs it ignored.
* src/test.c (test_syntax_error): Mark with ATTRIBUTE_FORMAT.
(binary_operator): Omit unnecessary NULL args, pacifying
-Wsuggest-attribute=format.
2021-10-31 22:36:46 -07:00
Paul Eggert
d16821975e maint: modernize attribute usage
* src/system.h (__attribute__): Remove.  Replace all uses that
rely on this by _GL_ATTRIBUTE_xxx or ATTRIBUTE_xxx.
(ATTRIBUTE_WARN_UNUSED_RESULT): Remove.  Replace all uses by
NODISCARD.
2021-10-31 22:36:46 -07:00
Paul Eggert
9287ce5bbc maint: remove unused __attribute__ defn
* gl/lib/randread.c (__attribute__): Remove; no longer
used after the recent _Noreturn change.
2021-10-31 22:36:46 -07:00
Paul Eggert
2a9bacee50 b2sum: simplify attribute usage
* src/blake2/blake2.h (BLAKE2_PACKED): Simplify, and port better
to older GCC, by using _GL_ATTRIBUTE_PACKED.
2021-10-31 22:36:46 -07:00
Paul Eggert
389e766367 maint: prefer attribute.h in .c files
This will help us make the transition to C2x, where some
attributes must come at the start of function decls.
Leave the attributes alone in .h files for now,
as the Gnulib tradition is to not expose attribute.h to users.
* bootstrap.conf (gnulib_modules): Add ‘attribute’.
* gl/lib/randperm.c, src/make-prime-list.c, src/system.h:
Include attribute.h.
* gl/lib/strnumcmp.c (strnumcmp): Remove _GL_ATTRIBUTE_PURE here,
as this belongs in the .h file.
* gl/lib/strnumcmp.h (strnumcmp): Add _GL_ATTRIBUTE_PURE here.
* src/sort.c (human_numcompare, numcompare): Now ATTRIBUTE_PURE;
discovered due to strnumcmp.h change.
* gl/lib/randperm.c, src/copy.c, src/dd.c, src/df.c, src/digest.c:
* src/env.c, src/expr.c, src/factor.c, src/ls.c:
* src/make-prime-list.c, src/numfmt.c, src/od.c, src/pathchk.c:
* src/pinky.c, src/pr.c, src/ptx.c, src/realpath.c, src/relpath.c:
* src/seq.c, src/sort.c, src/stat.c, src/stty.c, src/system.h:
* src/tr.c, src/uniq.c, src/wc.c:
In .c files, crefer ATTRIBUTE_CONST to _GL_ATTRIBUTE_CONST, and
similarly for ATTRIBUTE_FORMAT and ATTRIBUTE_PURE.
* src/system.h (FALLTHROUGH): Remove; attribute.h defines it.
2021-10-31 22:36:46 -07:00
Pádraig Brady
bafff0019c sort: --debug: add warnings about sign, radix, and grouping chars
New warnings are added related to the handling
of thousands grouping characters, decimal points, and sign characters.
Examples now diagnosed are:

$ printf '0,9\n1,a\n' | sort -nk1 --debug -t, -s
sort: key 1 is numeric and spans multiple fields
sort: field separator ‘,’ is treated as a group separator in numbers
1,a
_
0,9
___

$ printf '1,a\n0,9\n' | LC_ALL=fr_FR.utf8 sort -gk1 --debug -t, -s
sort: key 1 is numeric and spans multiple fields
sort: field separator ‘,’ is treated as a decimal point in numbers
0,9
___
1,a
__

$ printf '1.0\n0.9\n' | LC_ALL=fr_FR.utf8 sort -s -k1,1g --debug
sort: note numbers use ‘,’ as a decimal point in this locale
0.9
_
1.0
_

$ LC_ALL=fr_FR.utf8 sort -n --debug /dev/null
sort: text ordering performed using ‘fr_FR.utf8’ sorting rules
sort: note numbers use ‘,’ as a decimal point in this locale
sort: the multi-byte number group separator in this locale \
      is not supported

$ sort --debug -t- -k1n /dev/null
sort: key 1 is numeric and spans multiple fields
sort: field separator ‘-’ is treated as a minus sign in numbers
sort: note numbers use ‘.’ as a decimal point in this locale

$ sort --debug -t+ -k1g /dev/null
sort: key 1 is numeric and spans multiple fields
sort: field separator ‘+’ is treated as a plus sign in numbers
sort: note numbers use ‘.’ as a decimal point in this locale

* src/sort.c (key_warnings): Add the warnings above.
* tests/misc/sort-debug-warn.sh: Add test cases.
Also check that all sort invocations succeed.
* NEWS: Mention the improvement.
Addresses https://bugs.gnu.org/51011
2021-10-31 23:19:05 +00:00
Paul Eggert
aa31b919ca maint: modernize README-{hacking,prereq} 2021-10-30 16:28:25 -07:00
Paul Eggert
1753012b8d cp: revert unnecessary FreeBSD workaround
That was a false alarm due to a bug in FreeBSD 9.1 truss;
see Pádraig Brady’s report (Bug#51433#29).
* src/copy.c (lseek_copy, infer_scantype): Don’t bother checking
whether lseek returned -1.  This doesn’t entirely revert the
previous change, as it keeps the code simplification of the
previous change while reverting the check for -1.
2021-10-30 10:04:54 -07:00
Paul Eggert
a9e31457bf cp: defend better against FreeBSD 9.1 zfs bug
Problem reported by Pádraig Brady (Bug#51433#14).
* src/copy.c (lseek_copy, infer_scantype): Report an error if
lseek with SEEK_DATA or SEEK_HOLE returns less than -1,
as this is an lseek bug.
2021-10-29 18:23:54 -07:00
Pádraig Brady
f60a3981c3 doc: say that printf(1) is preferred over echo(1)
* src/echo.c (usage): Say printf(1) is preferred
due to being more standard and robust.
* man/echo.x [SEE ALSO]: Reference printf(1).
* doc/coreutils.texi (echo invocation): Mention in the
summary that echo is not robust when outputting
any string, and that printf is preferred.
Also expand on the examples showing how to
output a single '-n' string.
Addresses https://bugs.gnu.org/51311
2021-10-22 15:12:33 +01:00
Pádraig Brady
13af84d09a doc: timeout --kill-after: clarify disabled timeouts
* doc/coreutils.texi (timeout invocation): Clarify
that -k is ignored if either its duration or the
main timeout duration is 0.
Addresses https://bugs.gnu.org/51128
2021-10-12 14:47:44 +01:00
Pádraig Brady
0750fcdf34 timeout: ensure --foreground -k exits with status 137
* src/timeout.c (main): Propagate the killed status from the child.
* doc/coreutils.texi (timeout invocation): Remove the
description of the --foreground specific handling of SIGKILL,
now that it's consistent with the default mode of operation.
* tests/misc/timeout.sh: Add a test case.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/51135
2021-10-12 14:32:57 +01:00
Pádraig Brady
d085678bd6 doc: timeout --foreground: add clarification on exit status
* doc/coreutils.texi (timeout invocation): Add detail on
how --foreground allows timeout(1) to use more standard
exit status as the uncatchable SIGKILL is not sent to itself.
Fixes https://bugs.gnu.org/51135
2021-10-11 22:15:52 +01:00
Paul Eggert
6cafb122fa sort: fix unlikely bug when '\377' < 0
* gl/lib/strintcmp.c (strintcmp): Don’t assume that the input
cannot contain ((char) -1), as this equals '\377' when char is
signed (assuming 8-bit char).
* src/sort.c (decimal_point): Now char, to make it clear
that it’s always in char range now.
(NON_CHAR): New constant.
(traverse_raw_number): Return char not unsigned char;
this is simpler and could be faster.  All callers changed.
(main): Do not convert decimal_point and thousands_sep to
unsigned char, as this can mishandle comparisons on
machines where char is signed and the input data contains
((char) -1).  Use NON_CHAR, not -1, as an out-of-range value for
thousands_sep.
2021-10-10 16:06:28 -07:00
Paul Eggert
5b43b8e9ce build: update gnulib submodule to latest 2021-10-02 18:55:01 -07:00
Paul Eggert
b31a6a09ad maint: switch to C11-style _Noreturn
Use C11-style _Noreturn instead of the old ATTRIBUTE_NORETURN
macro.  This pacifies clang on OpenBSD 6.9, which otherwise
complains "'noreturn' function does return" in some places.
* gl/lib/randread.c, src/system.h (ATTRIBUTE_NORETURN):
Remove.  All uses either removed as GCC no longer needs them, or
changed to C11-style _Noreturn since Gnulib arranges for _Noreturn
globally nowadays.
2021-10-02 18:44:21 -07:00
Paul Eggert
4cfd48481d ls: port to OpenBSD
Problem reported by Brian Callahan (Bug#50972).
* src/ls.c (decode_switches): Don’t assume __GNUC_PREREQ.
2021-10-02 18:08:33 -07:00
Pádraig Brady
0475ce9f84 doc: adjust ls --zero option order in texinfo
* doc/coreutils.texi (ls invocation - general output formatting):
The option ordering was not changed when the option was renamed
from --null to --zero.
2021-09-26 13:48:03 +01:00
Pádraig Brady
61c81ffaac tests: cp/sparse-perf: make more robust and add zfs comments
* init.cfg (seek_data_capable_): Add a timeout to ensure failure for
slow lseek(...SEEK_DATA) calls (even if that syscall isn't interrupted).
* tests/cp/sparse-perf.sh: Run the SEEK_DATA check on the
1TiB empty file to exclude both FreeBSD 9.1 which takes 35s,
and ZFS which requires a delay of about 5s between file creation
and use of SEEK_DATA to correctly determine it's empty (return ENXIO).
Also remove the stat size checks as they invalidate the test
due to cp never writing data due to it being always zeros,
and thus converted to holes in the output.
2021-09-25 22:40:01 +01:00
Pádraig Brady
e8b56ebd53 chmod: fix exit status when ignoring symlinks
* src/chmod.c: Reorder enum so CH_NOT_APPLIED
can be treated as a non error.
* tests/chmod/ignore-symlink.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/50784
2021-09-24 23:42:20 +01:00
Pádraig Brady
6f38c4b279 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-09-24 13:58:11 +01:00
Pádraig Brady
725bb111bd version 9.0
* NEWS: Record release date.
2021-09-24 13:35:26 +01:00
Pádraig Brady
bfedefd872 tests: sparse-perf: avoid false failure
* tests/cp/sparse-perf.sh: Avoid the case where
we saw SEEK_DATA take 35s to return a result
against a 1TB sparse file.  This happened on
a FreeBSD 9.1 VM at least.
Reported by Nelson H. F. Beebe.
2021-09-24 12:17:58 +01:00
Pádraig Brady
56bff500c5 cksum: fix -a crc on 64 bit big endian systems
* src/cksum.c (crc_sum_stream): On sparc64 for example,
a crc of 0 was printed due to mismatch in size of
variable copied between generator and output functions.
uint_fast32_t is generally 64 bits on 64 bit systems,
so we copy through an int to ensure we don't use the wrong
end of a 64 bit variable.
Reported by Nelson H. F. Beebe
2021-09-24 00:39:05 +01:00
Pádraig Brady
a656db664d tail: fix detection of closed stdout on macOS
* bootstrap.conf: We only need poll on Linux and AIX
where poll is not replaced.  Also resinstate dependence
on select so we can use it unconditionally.
* src/tail.c (check_output_alive): Reinstate use of select()
by default as poll was seen to be ineffective for this
application on macOS.
Fixes https://bugs.gnu.org/50714
2021-09-21 17:50:54 +01:00
Pádraig Brady
f8819b657f maint: clean up c++ style comments
* src/expand-common.h: Remove commented variables.
* src/remove.h: Change to C style comment.
* src/tail.c: Likewise.
2021-09-21 16:22:18 +01:00
Pádraig Brady
23953cecf9 tests: date-debug: avoid a false failure on solaris
* tests/misc/date-debug.sh: Use a dynamic time format,
as the C locale on solaris uses %T rather than %H:%M:%S
for the time component.
2021-09-20 23:42:03 +01:00
Jim Meyering
f6fc52a828 doc: drop extraneous single quotes in help
* src/digest.c (usage) [cksum --help]: Drop single quotes
around each checksum name.
* src/tee.c (usage) [tee --help]: Likewise.
2021-09-20 21:42:28 +01:00
Jim Meyering
971aebfacc cksum: list Pádraig as coauthor
* src/digest.c (AUTHORS) [HASH_ALGO_CKSUM]: Add Pádraig as
cksum coauthor.
* AUTHORS: Likewise.
2021-09-20 21:42:26 +01:00
Jim Meyering
7b0db3c69c tests: env-s.pl: avoid spurious failure on OS X
* tests/misc/env-S.pl: The __CF_USER_TEXT_ENCODING envvar
would cause many of these sub-tests to fail. Ignore it.
2021-09-20 10:01:53 -07:00
Pádraig Brady
4382207c1d build: update gnulib submodule to latest
* gnulib: Update to latest.
Fixes "extern inline" and "rpl_free" issues.
2021-09-20 16:31:48 +01:00
Pádraig Brady
22d3751e0f doc: fix --help formatting for checksum utils
* src/digest.c (usage): Indicate that --length and --algorithm
require arguments.  Emit corresponding emit_mandatory_arg_note().
Use consistent alignment.
2021-09-20 16:27:39 +01:00
Pádraig Brady
88b7ff98fe cksum: support more transparent emulation of older utils
* src/digest.c: Allow using the --untagged option with --check,
so that `cksum -a md5 --untagged` used to emulate md5sum for example,
may be augmented with the --check option.  Also support the --tag
option with cksum, to allow overriding a previous --untagged setting.
* doc/coreutils.texi: Adjust accordingly.
* tests/misc/cksum-a.sh: Likewise.
2021-09-20 16:21:15 +01:00
Pádraig Brady
f80c6c267d tests: avoid rare race in tail-2/F-vs-rename.sh
* tests/tail-2/F-vs-rename.sh: Keep stdout and stderr separate,
so that interspersion doesn't impact regex checks.  Also wait
for each file's data to be printed to avoid multiple writes
to a file to be printed in a single iteration, which would
impact the regex checks.  Also we refactor the check function,
rather than repeatedly redefining variations.
2021-09-20 11:19:53 +01:00
Pádraig Brady
6946f9e47d maint: remove duplicate from THANKS.in
* THANKS.in: Now that Tianjia Zhang has a commit in the repo.
2021-09-17 13:38:45 +01:00
Tianjia Zhang
a2b5e9f85b tests: fix typo in cksum-a.sh
* tests/misc/cksum-a.sh: fix typo md5um to md5sum.
2021-09-17 12:08:19 +01:00
Pádraig Brady
8922ee206c tests: fix rare false failure in tail-2/F-vs-rename
This is wrong fix really, as only introducing delay I think.

* tests/tail-2/F-vs-rename.sh: Avoid a rare false failure
due to a race in the test.  Now wait until tail has noticed
that b is replaced before writing to a, so that the subsequent
write of "y" to b will be displayed independently from
current contents of b ("x").
2021-09-17 01:28:14 +01:00
Pádraig Brady
5134612fa7 tests: port removed-directory test to FreeBSD
* tests/ls/removed-directory.sh: On FreeBSD 9.1 at least,
one gets ENOENT when trying to traverse the current removed dir
with ../, so instead reference the parent dir directly.
2021-09-17 00:18:03 +01:00
Pádraig Brady
14ed8b8810 rmdir: fix uninitialized memory causing incorrect error
* src/rmdir.c (main): Only inspect the returned stat structure,
when stat(2) returns success.
2021-09-16 23:45:16 +01:00
Jim Meyering
3283cc7725 build: avoid new chmod.c warnings from upcoming GCC12
Here are the warnings:
src/chmod.c:175:3: error: 'ch.new_mode' may be used uninitialized in\
    this function [-Werror=maybe-uninitialized]
  175 |   strmode (ch->new_mode, perms);
src/chmod.c:178:3: error: 'ch.old_mode' may be used uninitialized in\
    this function [-Werror=maybe-uninitialized]
  178 |   strmode (ch->old_mode, old_perms);

* src/chmod.c (process_file): Initialize ch.  Its new_mode and
old_mode fields could indeed be used uninitialized to form mode
strings, but those are used only when built from initialized members.
2021-09-16 15:22:15 -07:00
Pádraig Brady
e6c57cf19b digest: ignore empty lines when checking
* src/digest.c (digest_check): Treat empty lines like comments,
as commented checksum files very often have empty lines.
* tests/misc/md5sum.pl: Adjust accordingly.
2021-09-16 20:39:28 +01:00
Pádraig Brady
7ebcd88fb2 factor: sync longlong.h adjustments from upstream
* src/longlong.h: Sync changes from:
https://gmplib.org/repo/gmp/log/tip/longlong.h
2021-09-16 15:42:33 +01:00
Pádraig Brady
92ffc842dc stat,tail: add support for the secretmem file system
* src/stat.c (human_fstype): Add case for the 'secretmem'
file system type.
* NEWS: Mention the Improvement.
2021-09-16 15:21:05 +01:00
Pádraig Brady
cca434a4a5 maint: sync help2man to latest version
* man/help2man: sync to changes from version 1.48.5.
Note this doesn't materially change the generated man pages.
2021-09-16 15:03:23 +01:00
Pádraig Brady
3215736685 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.25 which is now about 5 years old.
2021-09-16 14:49:19 +01:00
Pádraig Brady
814cbd5698 tests: ensure returns_ check failures are propagated
* tests/misc/cksum-a.sh: Set fail=1 if returns_ check fails.
* tests/misc/sync.sh: Likewise.
* tests/misc/yes.sh: Likewise.
2021-09-16 12:21:16 +01:00
Pádraig Brady
73f8fd760d cksum: fix --check with non tagged format checksums
* src/digest.c: Always set the digest_length, so that
we check the correct number of hex digits when parsing
non tagged format checksums.
* tests/misc/cksum-a.sh: Add a test case.  Also fix
up this test which was ineffective due to fail=1
being set in a subshell and ignored.
2021-09-16 12:20:24 +01:00
Paul Eggert
121f74dfc2 cksum: fix off-by-1 bug with \r stripping
Problem reported by Jim Meyering (Bug#50611).
* src/digest.c (digest_check): When stripping trailing \r,
avoid subscript error before start of line.
2021-09-16 00:25:26 -07:00
Paul Eggert
2715aba08a maint: prefer rawmemchr to memchr when easy
* bootstrap.conf (gnulib_modules): Add rawmemchr.
* src/csplit.c: Include idx.h.
* src/csplit.c (record_line_starts):
* src/head.c (elide_tail_lines_pipe):
* src/shuf.c (next_line):
* src/split.c (lines_split):
* src/tail.c (pipe_lines):
* src/wc.c (wc_lines):
Prefer rawmemchr to memchr when rawmemchr is easy.
* src/csplit.c (load_buffer):
* src/head.c (struct linebuffer):
Make room for a 1-byte sentinel.
2021-09-15 15:08:28 -07:00
Paul Eggert
f8dc5a6215 split: avoid NULL + 1
* src/split.c (lines_chunk_split): Don’t add to a null pointer.
It’s undefined behavior, and it’s unnecessarily confusing
regardless.
2021-09-15 15:08:28 -07:00
Pádraig Brady
ed1c58427d digest: support windows format checksum files
Support checksum files with CRLF line endings,
which is a common gotcha for using --check on windows,
or with checksum files generated on windows.
Note we escape \r here to support the original coreutils format
(with file name at EOL), and file names with literal
\r characters as the last character of their name.

* src/digest.c (filename_unescape): Convert \\r -> \r.
(print_filename): Escape \r -> \\r.
(output_file): Detect \r chars in file names.
(digest_check): Ignore literal \r char at EOL.
* tests/misc/md5sum.pl: Add a test case.
* tests/misc/sha1sum.pl: Likewise.
* NEWS: Mention the improvement.
2021-09-15 20:44:18 +01:00
Pádraig Brady
7b8f38aa87 doc: improve --help indenting in checksum utils
* src/digest.c (usage): Indent multi-line descriptions for clarity.
2021-09-15 20:44:18 +01:00
Pádraig Brady
8d5038af05 cksum: operate in binary mode only
This only practically matters on windows.
But given there are separate text handling options in cygwin,
keep the interface simple, and avoid exposing the
confusing binary/text difference here.

* doc/coreutils.texi (md5sum invocation): Mention that
--binary and --text are not supported by the cksum command.
* src/digest.c: Set flag to use binary mode by default.
(output_file): Don't distinguish text and binary modes with
' ' and '*', and just use ' ' always.
2021-09-15 20:44:18 +01:00
Pádraig Brady
f9a787656b cksum: use --tag format by default
This format is a better default, since it results in simpler usage,
as you don't need to specify --tag on generation or -a on
checking invocations.  Also it's a more general format supporting
mixed and length adjusted digests.

* doc/coreutils.texi (cksum invocation): Document a new --untagged
option, to use the older coreutils format.
(md5sum invocation): Mention that cksum doesn't support --tag.
* src/digest.c: Adjust cksum(1) to default to --tag,
and accept the new --untagged option.
* tests/misc/b2sum.sh: Adjust accordingly.
* tests/misc/cksum-a.sh: Likewise.
* tests/misc/cksum-c.sh: Likewise.
2021-09-15 20:44:18 +01:00
Pádraig Brady
d9b78a2329 cksum: support --zero in default mode
* src/cksum.h: Thread DELIM through the output functions.
* src/digest.c: Likewise.
* src/sum.c: Likewise.
* src/sum.h: Likewise.
* src/cksum.c: Likewise. Also adjust check to allow -z
with traditional output modes.  Also ajust the global variable
name to avoid shadowing warnings.
* tests/misc/cksum-a.sh: Adjust accordingly.
2021-09-15 20:44:18 +01:00
Pádraig Brady
8e411226f9 digest: support -length specifiers on all digest tags
This will be generally useful going forward, for sha3-256 etc.

* src/digest.c: Rename b2_length to digest_length, and
adjust/simplify the code to operate on this for both
b2sum and cksum -a blake2b.
2021-09-15 20:44:18 +01:00
Pádraig Brady
772173a832 cksum: support digest detection for tagged format
Support `cksum --check FILE` without having to specify a digest
algorithm, allowing for more generic file check instructions.
This also supports mixed digest checksum files, supporting
more robust multi digest checks.

* src/digest.c (algorithm_from_tag): A new function to
identify the digest algorithm from a tagged format line.
(split3): Set the algorithm depending on tag, and update
the expected digest length accordingly.
* tests/misc/cksum-c.sh: Add a new test.
* tests/local.mk: Reference the new test.
* tests/misc/md5sum.pl: Adjust to more generic error.
* tests/misc/sha1sum.pl: Likewise.
* doc/coreutils.texi (md5sum invocation): Mention the new -c feature.
* NEWS: Mention the new feature.
2021-09-15 20:44:18 +01:00
Pádraig Brady
217cd278ec maint: simplify b2sum to only handle BLAKE2b
Any further variants will use the cksum -a table driven mechanism.

* src/digest.c: Remove BLAKE2 specific table driven code.
2021-09-15 20:44:18 +01:00
Pádraig Brady
8362f2552a digest: add support for sm3
Add message digest sm3, which uses the OSCCA SM3 secure
hash (OSCCA GM/T 0004-2012 SM3) generic hash transformation.

* bootstrap.conf: Add the sm3 module.
* doc/coreutils.texi: Mention the cksum -a option.
* src/digest.c: Provide support for --algorithm='sm3'.
* tests/misc/sm3sum.pl: Add a new test (from Tianjia Zhang)
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.

Tested-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
2021-09-15 20:44:18 +01:00
Pádraig Brady
ad6c8e1181 cksum: add --algorithm option to select digest mode
* src/digest.c: Organize HASH_ALGO_CKSUM to be table driven,
and amalgamate all digest algorithms.
(main): Parse all options if HASH_ALGO_CKSUM, and disallow
--tag, --zero, and --check with the traditional bsd, sysv, and crc
checksums for now.
* src/local.mk: Reorganize to include all digest modules in cksum.
* tests/misc/cksum-a.sh: Add a new test.
* tests/misc/b2sum.sh: Update to default to checking with cksum,
as b2sum's implementation diverges a bit from the others.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (cksum invocation): Adjust the summary to
identify the new mode, and document the new --algorithm option.
* man/cksum.x: Adjust description to be more general.
* man/*sum.x: Add [See Also] section referencing cksum(1).
* NEWS: Mention the new feature.
2021-09-15 20:44:16 +01:00
Pádraig Brady
6a5c561b4f digest: refactor cksum(1) into digest.c
* cfg.mk: Adjust cksum.c to not require config.h
and support a main (for crctab) without calling bindtextdomain().
* po/POTFILES.in: Remove cksum_pclmul.c since it no longer
concerns itself with diagnostics.
* src/cksum.c: Refactor to just providing stream digest,
and digest printing functionality.
* src/cksum.h: Adjust to the new interface.
* src/cksum_pclmul.c: Remove diagnostics, and determine errors
internally.
* src/crctab.c: Separate from cksum.h since that's now included
multiple times.
* src/digest.c: Provide cksum(1) functionality if -DHASH_ALGO_CKSUM
* src/local.mk: Adjust to new crctab.c and HASH_ALGO_CKSUM define.
2021-09-15 15:35:53 +01:00
Pádraig Brady
2aab794c84 cksum: document the --debug option
This should have been part of commit v8.32-113-gb73b9fcb1

* doc/coreutils.texi (cksum invocation): Add the --debug description.
* src/cksum.c (usage): Likewise.
(main): Also give explicit indication when using generic hardware.
2021-09-15 15:35:53 +01:00
Pádraig Brady
97f98b63a4 sum: handle EOVERFLOW for too large inputs
* src/sum.c (bsd_sum_stream): Detect overflow when updating length.
(sysv_sum_stream): Likewise.
2021-09-15 15:35:53 +01:00
Pádraig Brady
eb17c610d4 digest: refactor sum(1) into digest.c
Since digest will be providing all digest functionality,
refactor sum.c into it.

* po/POTFILES.in: sum.c no longer has translatable strings so remove.
* src/digest.c: Call out to new stream interfaces in sum.c
* src/local.mk: Adjust sources for the sum binary.
* src/sum.c: Provide a stream interface for BSD and SYSV digests.
* src/sum.h: A new file to declare the exported functions in sum.c
2021-09-15 15:35:53 +01:00
Pádraig Brady
51268b5dbb digest: add LENGTH parameter to digest to support cksum
* src/digest.c (digest_file): Add a LENGTH param,
to support cksum(1), and sum(1) which output the
length as part of their output.
2021-09-15 15:35:53 +01:00
Pádraig Brady
f0b32e79cc maint: rename md5sum.c to more general digest.c
md5sum.c will be the base for all digest functions,
so rename accordingly.

* src/md5sum.c: Rename to ...
* src/digest.c: ... renamed from md5sum.c
* scripts/git-hooks/commit-msg: Allow digest: commit prefix.
* po.POTFILES.in: Adjust to new name.
* src/local.mk: Likewise.
2021-09-15 15:35:53 +01:00
Pádraig Brady
f76a568313 doc: fix ambiguities in logname(1) and whoami(1)
* doc/coreutils.texi (whoami invocation): Clarify it prints names,
not numeric IDs.
* man/whoami.x: Likewise.
* man/logname.x: Reference getlogin(3).
* src/logname.c: Clarify that it prints the login name,
rather than the name of the effective user ID.

Fixes https://bugs.gnu.org/48894
2021-09-15 15:26:22 +01:00
nl6720
7f303de877 dircolors: add *direct* to TERM matching
Search for "direct color" at:
https://invisible-island.net/xterm/terminfo.html

* src/dircolors.hin: Add *direct* to match terminals that
support direct colors (24-bit color / TrueColor).
The trailing * will match entries like xterm-direct2.

Addresses https://bugs.gnu.org/39827
2021-09-15 14:51:11 +01:00
Pádraig Brady
0cfb60e90d tests: stat-vs-dirent.sh: avoid a false failure
* tests/ls/stat-vs-dirent.sh: Skip the test if we can't stat(1),
as the file may have been removed, or have a malformed name
due to '\n' etc. in the file name.
2021-09-12 23:16:18 +01:00
Pádraig Brady
ac4841298e tests: add new stdin reading programs to tty-eof test
* tests/misc/tty-eof.pl: Add b2sum and basenc.
2021-09-09 21:35:52 +01:00
Pádraig Brady
4af4d61d53 build: update gnulib submodule to latest
* gnulib: Update to latest. This fixes a gnulib test failure in base64,
among other fixes.
* cfg.mk: Disable sc_indent as auto indent is too invasive for now.
2021-09-09 21:35:03 +01:00
Pádraig Brady
91feded51c doc: fix repeated word
A proposed change to gnulib's sc_prohibit_doubled_word
was made to detect this in future.

* README: s/can can/can/.
Fixes https://bugs.gnu.org/50484
2021-09-09 16:25:36 +01:00
Paul Eggert
588790a38c doc: can “can can”
Problem reported by Akbarkhon Variskhanov (Bug#50484).
2021-09-09 08:05:14 -07:00
Paul Eggert
3c855eb572 doc: add missing "as" (thanks to Nelson H.F. Beebe) 2021-09-07 16:15:40 -07:00
Justin Tracey
1d5dbb8203 tests: narrow scope of faulty join args
* tests/misc/join.pl: Only test invalid-j with an invalid -j field,
not with missing operands as well.
2021-09-05 12:10:41 +01:00
Pádraig Brady
669d45de0f doc: indicate the default algorithm in the sum(1) man page
* src/sum.c (usage): Indicate that -r (BSD algorithm) is the default.
2021-08-31 11:33:29 +01:00
Pádraig Brady
e1c21f39cc sum: always output a file name if one passed
Adjust to output the file name if any name parameter is passed.
This is consistent with sum -s, cksum, and sum implementations
on other platforms.  This should not cause significant compat
issues, as multiple fields are already output, and so already
need to be parsed.

* src/sum.c (bsd_sum_file): Output the file name
if any name parameter is passed.
* tests/misc/sum.pl: Adjust accordingly.
* doc/coreutils.texi (sum invocation): Likewise.
* NEWS: Mention the change in behavior.
2021-08-31 11:33:26 +01:00
Paul Eggert
cff4ce7a5e tests: port better to NetBSD
* tests/misc/help-version.sh: Test that /dev/full causes
shell printf to fail.  This ports better to NetBSD 9.88.46,
where it doesn’t.  Problem reported by Nelson H. F. Beebe.
2021-08-30 17:02:06 -07:00
Paul Eggert
549cb8d901 tests: merge help-version changes back from gzip
* tests/misc/help-version.sh: Merge gzip-related changes
back from gzip/tests/help-version.  This fixes problems
when TERM is not 'dumb', and should simplify maintenance.
2021-08-30 17:02:06 -07:00
Assaf Gordon
709d1f8253 basenc: fix bug49741: using wrong decoding buffer length
Emil Lundberg <lundberg.emil@gmail.com> reports in
https://bugs.gnu.org/49741 about a 'basenc --base64 -d' decoding bug.
The input buffer length was not divisible by 3, resulting in
decoding errors.

* NEWS: Mention fix.
* src/basenc.c (DEC_BLOCKSIZE): Change from 1024*5 to 4200 (35*3*5*8)
which is divisible by 3,4,5,8 - satisfying both base32 and base64;
Use compile-time verify() macro to enforce the above.
* tests/misc/basenc.pl: Add test.
2021-08-29 22:06:32 -06:00
Paul Eggert
97d8dcc5ca basenc: prefer signed to unsigned integers
This patch modifies basenc to prefer signed integers to
unsigned, as signed are less error-prone.
This patch also updates Gnulib to to latest, which updates Gnulib’s
base32 and base64 modules to prefer signed to unsigned integers.
* src/basenc.c: Include idx.h.
(struct base2_decode_context): Use unsigned char, not unsigned
for an octet that must fit in an unsigned char.
(base_encode, struct base_decode_context)
(base64_decode_ctx_wrapper, prepare_inbuf, base64url_encode)
(base64url_decode_ctx_wrapper, base32_decode_ctx_wrapper)
(base32hex_encode, base32hex_decode_ctx_wrapper, base16_encode)
(base16_decode_ctx, z85_encode, Z85_HI_CTX_TO_32BIT_VAL)
(z85_decoding, z85_decode_ctx, base2msbf_encode)
(base2lsbf_encode, base2lsbf_decode_ctx, base2msbf_decode_ctx)
(wrap_write, do_encode, do_decode, main):
Prefer signed integers to unsigned.
(main): Treat extremely large wrap columns as if they were
infinite; that’s good enough.  Since we’re now using xstrtoimax,
this allows ‘-w -0’ (same as ‘-w 0’).
* tests/misc/base64.pl (gen_tests): -w-0 is no longer an error.
2021-08-27 17:12:27 -07:00
Jim Meyering
88562dc9c7 maint: avoid new syntax-check failure
find-mount-point.h rightly includes <stdlib.h> for its use
of _GL_ATTRIBUTE_DEALLOC_FREE, which uses free, yet that new
inclusion provoked a syntax-check failure. Exempt this header
file as we've done for others.
* cfg.mk (exclude_file_name_regexp--sc_system_h_headers):
Add find-mount-point.h to the regexp.
(sc_system_h_headers): Use grep -E, for a more readable regexp.
2021-08-25 08:45:39 -07:00
Pádraig Brady
c431893b96 tests: avoid reflinks when testing SEEK_DATA logic
This better tests the SEEK_HOLE logic which
replaced the original fiemap hole identification logic.
Also it avoids a false failure in sparse-2.sh
on reflink supporting file systems, where we
try to correlate the file sizes produced by cp and dd.

* tests/cp/sparse-2.sh: s/cp/cp --reflink=never/
* tests/cp/sparse-extents-2.sh: Likewise.
* tests/cp/sparse-extents.sh: Likewise.
* tests/cp/sparse-perf.sh: Likewise.
* tests/cp/sparse.sh: Likewise.

Fixes https://github.com/coreutils/coreutils/issues/54
2021-08-25 12:37:57 +01:00
Paul Eggert
b020d456d1 df: pacify -Wsuggest-attribute=malloc
Problem found with latest Gnulib and GCC 11.2.1.
* src/find-mount-point.h (find_mount_point):
Add _GL_ATTRIBUTE_MALLOC and _GL_ATTRIBUTE_DEALLOC_FREE.
2021-08-22 13:10:26 -07:00
Paul Eggert
3c18082822 build: update gnulib submodule to latest 2021-08-22 13:10:26 -07:00
Paul Eggert
88846befff maint: use clearerr on stdin when appropriate
This is so that commands like ‘fmt - -’ read from stdin
both times, even when it is a tty.  Fix some other minor
issues that are related.
* src/blake2/b2sum.c (main):
* src/cksum.c (cksum):
* src/cut.c (cut_file):
* src/expand-common.c (next_file):
* src/fmt.c (fmt):
* src/fold.c (fold_file):
* src/md5sum.c (digest_file, digest_check):
* src/nl.c (nl_file):
* src/od.c (check_and_close):
* src/paste.c (paste_parallel, paste_serial):
* src/pr.c (close_file):
* src/sum.c (bsd_sum_file):
Use clearerr on stdin so that stdin can be read multiple times
even if it is a tty.  Do not assume that ferror preserves errno as
POSIX does not guarantee this.  Coalesce duplicate diagnostic
calls.
* src/blake2/b2sum.c (main):
* src/fmt.c (main, fmt):
Report read error, even if it's merely fclose failure.
* src/fmt.c: Include die.h.
(fmt): New arg FILE.  Close input (reporting error) if not stdin.
All callers changed.
* src/ptx.c (swallow_file_in_memory): Clear stdin's EOF flag.
* src/sort.c (xfclose): Remove unnecessary feof call.
2021-08-22 13:10:26 -07:00
Paul Eggert
4d355e5270 doc: spell out stdin, stdout, stderr
* doc/coreutils.texi: Spell out words like “stdin” in
English prose.
2021-08-22 13:10:24 -07:00
Paul Eggert
bbb19b1868 chmod: fix use of uninitialized var if -v
Problem reported by Michael Debertol (Bug#50070).
* NEWS: Mention the fix.
* src/chmod.c (struct change_status): New struct, replacing the
old enum Change_status.  All uses changed.
(describe_change): Distinguish between cases depending on
whether 'stat' or its equivalent succeeded.  Report a line
of output even if 'stat' failed, as that matches the documentation.
Rework to avoid casts.
(process_file): Do not output nonsense modes computed from
uninitialized storage, removing a couple of IF_LINTs.  Simplify by
defaulting to CH_NO_STAT.
2021-08-15 21:32:09 -07:00
Pádraig Brady
29079b9aa2 maint: update .gitignore
* .gitignore: ignore new lib/malloc gnulib directory.
2021-08-14 22:23:11 +01:00
Pádraig Brady
a0f205ba92 maint: allow hook script accept "Signed-off-by:"
* scripts/git-hooks/commit-msg: Relax this constraint.
2021-08-14 21:40:54 +01:00
Paul Eggert
a3c04f8da1 df: fix bug with automounted
If the command-line argument is automounted, df would use
stat info that became wrong after the following open.
* NEWS: Mention the fix (bug#50012).
* src/df.c (automount_stat_err): New function.
This fixes the hang on fifos in a better way, by using O_NONBLOCK.
(main): Use it.
2021-08-11 11:22:40 -07:00
Pádraig Brady
a574283c7a cat: with -E fix handling of \r\n spanning buffers
We must delay handling when \r is the last character
of the buffer being processed, as the next character
may or may not be \n.

* src/cat.c (pending_cr): A new global to record whether
the last character processed (in -E mode) is '\r'.
(cat): Honor pending_cr when processing the start of the buffer.
(main): Honor pending_cr if no more files to process.
* tests/misc/cat-E.sh: Add test cases.
Fixes https://bugs.gnu.org/49925
2021-08-08 00:09:38 +01:00
Paul Eggert
02fc0e3f68 maint: update .gitignore 2021-07-31 13:36:31 -07:00
Paul Eggert
ba5a3b21b5 build: update gnulib submodule to latest 2021-07-31 13:36:31 -07:00
Paul Eggert
ffbd64ec86 uniq: pacify GCC -fanalyzer
Pacify GCC 11.1 -fanalyzer.
* src/uniq.c (check_file): Use simpler test to check whether this
is the first time through the loop.  Although the old test was
correct, the new one is easier to understand and perhaps a tiny
bit more efficient.
2021-07-31 11:17:18 -07:00
Paul Eggert
84da62974d numfmt: omit unnecessary pointer test
Caught by GCC 11.1 -fanalyzer.
* src/numfmt.c (simple_strtod_int): Remove unnecessary test of
*endptr vs NULL.  Presumably this was a typo and **endptr was
intended instead of *endptr, but an **endptr test is also
unnecessary since c_isdigit (0) returns false.
2021-07-31 11:17:18 -07:00
Pádraig Brady
d1316583b2 doc: add options summary list to tr texinfo
* doc/coreutils.texi (tr invocation): Provide a summary
list of the available options, which is useful to
provide a quick reminder for those already familiar
with the functionality of tr.
Fixes https://bugs.gnu.org/49764
2021-07-29 13:19:33 +01:00
Pádraig Brady
dcd6e4172c tests: augment new ls --zero test cases
* tests/ls/zero-option.sh: Check for the disabled, disallowed,
and allowed option combinations.
2021-07-28 23:17:34 +01:00
Pádraig Brady
eca33373ce maint: avoid syntax-check failures in recent ls changes
* src/ls.c: Fix ifdef indenting and long line.
2021-07-28 23:16:50 +01:00
Paul Eggert
d60b2922ff doc: modernize usage of “disk” and “core”
In documentation and comments, don’t assume that secondary storage
devices are disk devices.  Similarly, don’t assume that main memory
uses magnetic cores, which became obsolete in the 1970s.
* src/du.c (usage):
* src/ls.c (usage):
* src/shred.c (usage): Reword to avoid “disk” in usage messages.
2021-07-28 12:30:12 -07:00
Paul Eggert
1625916a1b doc: improve ls documentation
* doc/coreutils.texi (ls invocation): Document implementation more
closely.  Be more consistent about style.  Omit some needless words.
* src/ls.c (usage): Don’t overdocument -f, as the details were wrong.
Omit -1 advice as it’s a bit obsolete now that we have --zero and
is a bit much for --usage output anyway.
2021-07-28 12:30:12 -07:00
Paul Eggert
c75779cac3 ls: rename --null to --zero (Bug#49716)
* NEWS, doc/coreutils.texi (General output formatting):
* src/ls.c (usage):
Document this.
* src/ls.c (ZERO_OPTION): Rename from NULL_OPTION.
All uses changed.
(long_options): Rename --null to --zero.
(dired_dump_obstack, main, print_dir): Use '\n' instead of
eolbyte where eolbyte must equal '\n'.
(decode_switches): Decode --zero instead of --null.
--zero also implies -1, -N, --color=none, --show-control-chars.
Use easier-to-decipher code to set ‘format’ and ‘dired’.
Reject attempts to combine --dired and --zero.
* tests/local.mk: Adjust to test script renaming.
* tests/ls/zero-option.sh: Rename from tests/ls/null-option.sh,
and test --zero instead of --null.
2021-07-27 18:08:39 -07:00
Paul Eggert
9e4a6101f2 ls: compute defaults more lazily
* src/ls.c (enum time_type, enum sort_type, enum indicator_style)
(enum Dereference_symlink, ignore_mode):
Put ‘= 0’ after default values, since the code relies
on static storage defaulting to zero.
(enum sort_type): Reorder so that -1 can be used to represent unset.
(main): Test print_with_color after parse_ls_color may have reset it.
(decode_line_length): Return the line length instead of setting
static storage.  All uses changed.  Treat line lengths exceeding
PTRDIFF_MAX as infinite, to avoid pointer-subtraction glitches.
(stdout_isatty): New function, to avoid calling isatty twice.
(decode_switches): Calculate defaults more lazily, to avoid using
syscalls or getenv during startup unless the results are more
likely to be needed.  Use -1 to indicate options that haven’t been
set on the command line yet.  Move print_with_color test from
here to ‘main’.  Suppress bogus GCC warning.
(getenv_quoting_style): Return the quoting style instead of
setting static storage.
(init_column_info): New arg MAX_COLS, to avoid recalculating it.
Caller changed.
2021-07-27 18:08:38 -07:00
Pádraig Brady
e094d2e3e1 maint: avoid recent syntax-check issues
* .gitignore: Cater for recently added poll module.
* src/stdbuf.c: Avoid false positive from sc_prohibit_readlink.
2021-07-26 15:42:29 +01:00
Paul Eggert
7d44ac224c ls: add --null option (Bug#49716)
* NEWS, doc/coreutils.texi (General output formatting):
* src/ls.c (usage): Document this.
* src/ls.c (NULL_OPTION): New constant.
(long_options): Add --null.
(eolbyte): New static var.
(dired_dump_obstack, main, print_dir, print_current_files)
(print_many_per_line, print_horizontal, print_with_separator):
Output eolbyte instead of '\n'.
(decode_switches): Decode --null.
* tests/ls/null-option.sh: New file.
* tests/local.mk (all_tests): Add it.
2021-07-26 00:59:37 -07:00
Paul Eggert
39673b6d4c ls: port to wider off_t, uid_t, gid_t
* src/ls.c (dired_pos): Now off_t, not size_t, since it counts
output file offsets.
(dired_dump_obstack): This obstack's file offsets are now
off_t, not size_t.
(format_user_or_group, format_user_or_group_width):
ID arg is now uintmax_t, not unsigned long, since uid_t and
gid_t values might exceed ULONG_MAX.
(format_user_or_group_width): Use snprintf with NULL instead of
sprintf with a discarded buffer.  This avoids a stack buffer,
and so should be safer.
2021-07-26 00:59:37 -07:00
Paul Eggert
0a41ad2cfb ls: demacroize
Prefer functions or constants to macros where either will do.
That’s cleaner, and nowadays there’s no performance reason to
prefer macros.  All uses changed.
* src/ls.c (INITIAL_TABLE_SIZE, MIN_COLUMN_WIDTH):
Now constants instead of macros.
(file_or_link_mode): New function, replacing the old macro
FILE_OR_LINK_MODE.
(dired_outbyte): New function, replacing the old macro DIRED_PUTCHAR.
(dired_outbuf): New function, replacing the old macro DIRED_FPUTS.
(dired_outstring): New function, replacing the old macro
DIRED_FPUTS_LITERAL.
(dired_indent): New function, replacing the old macro DIRED_INDENT.
(push_current_dired_pos): New function, replacing the old macro
PUSH_CURRENT_DIRED_POS.
(assert_matching_dev_ino): New function, replacing the old macro
ASSERT_MATCHING_DEV_INO.
(do_stat, do_lstat, stat_for_mode, stat_for_ino, fstat_for_ino)
(signal_init, signal_restore, cmp_ctime, cmp_mtime, cmp_atime)
(cmp_btime, cmp_size, cmp_name, cmp_extension)
(fileinfo_name_width, cmp_width, cmp_version):
No longer inline; compilers can deduce this well enough nowadays.
(main): Protect unused assert with ‘if (false)’ rather than
commenting it out, so that the compiler checks the code.
(print_dir): Output the space and newline in the same buffer
as the human-readable number they surround.
(dirfirst_check): New function, replacing the old macro
DIRFIRST_CHECK.  Simplify by using subtraction.
(off_cmp): New function, replacing the old macro longdiff.
(print_long_format): No need to null-terminate the string now.
(format_user_or_group): Let printf count the bytes.
2021-07-26 00:59:37 -07:00
Paul Eggert
c09b25dd3f ls: simplify sprintf usage
* src/ls.c (format_user_or_group_width, print_long_format):
Use return value from sprintf instead of calling strlen on
the resulting buffer, or inferring the length some other way.
2021-07-26 00:59:36 -07:00
Paul Eggert
558959daa9 build: update gnulib submodule to latest 2021-07-26 00:59:36 -07:00
Paul Eggert
5622ab450e maint: fix white space 2021-07-26 00:59:36 -07:00
Paul Eggert
3753c706b7 env: fix usage typo
* src/env.c (usage): Fix pluralization typo.
2021-07-26 00:59:36 -07:00
Kamil Dudka
d6125af095 df: fix duplicated remote entries due to bind mounts
As originally reported in <https://bugzilla.redhat.com/1962515>,
df invoked without -a printed duplicated entries for NFS mounts
of bind mounts.  This is a regression from commit v8.25-54-g1c17f61ef99,
which introduced the use of a hash table.

The proposed patch makes sure that the devlist entry seen the last time
is used for comparison when eliminating duplicated mount entries.  This
way it worked before introducing the hash table.

Patch co-authored by Roberto Bergantinos.

* src/ls.c (struct devlist): Introduce the seen_last pointer.
(devlist_for_dev): Return the devlist entry seen the last time if found.
(filter_mount_list): Remember the devlist entry seen the last time for
each hashed item.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/49298
2021-07-02 17:32:46 +01:00
Paul Eggert
da0d448bca tail: use poll, not select
This fixes an unlikely stack out-of-bounds write reported by
Stepan Broz via Kamil Dudka (Bug#49209).
* bootstrap.conf (gnulib_modules): Replace select with poll.
* src/tail.c: Do not include <sys/select.h>.
[!_AIX]: Include poll.h.
(check_output_alive) [!_AIX]: Use poll instead of select.
(tail_forever_inotify): Likewise.  Simplify logic, as there is no
need for a ‘while (len <= evbuf_off)’ loop.
2021-06-26 18:40:26 -07:00
Paul Eggert
177bfdd7ca tail: fix abuse2 test race
* tests/tail-2/inotify-hash-abuse2.sh (fastpoll):
Fix race where tailed file ‘f’ temporarily did not exist.
2021-06-26 18:40:26 -07:00
Paul Eggert
53bb0235d5 maint: while (1) → while (true) 2021-06-26 18:40:26 -07:00
Nikolay Nechaev
18dbcae25a maint: remove redundant checks on buffer sizes in tail
* src/tail.c: remove redundant size checks before calls to
`xwrite_stdout`
2021-06-21 13:17:06 +01:00
Pádraig Brady
5f8e6fc202 stat: use decomposed decimal device numbers by default
* src/stat.c (default_format): Use decomposed decimal
representation (major,minor) in the default format.
This is least ambiguous for human interpretation,
and more consistent with ls for example.
Fixes https://bugs.gnu.org/48960
2021-06-21 12:03:42 +01:00
Pádraig Brady
4a8278229e stat: support more device number representations
In preparation for changing the default device number
representation (to decomposed decimal), provide more
formatting options for device numbers.

These new (FreeBSD compat) formatting options are added:

   %Hd  major device number in decimal (st_dev)
   %Ld  minor device number in decimal (st_dev)
   %Hr  major device type in decimal (st_rdev)
   %Lr  minor device type in decimal (st_rdev)
   %r   (composed) device type in decimal (st_rdev)
   %R   (composed) device type in hex (st_rdev)

* doc/coreutils.texi (stat invocation): Document new formats.
* src/stat.c (print_it): Handle the new %H and %L modifiers.
(print_statfs): Adjust to passing the format as two chars
rather than an int.  Using an int was introduced in commit db42ae78,
but using separate chars is cleaner and more extensible.
(print_stat): Likewise.  Handle any modifiers and the new 'r' format.
(usage): Document the new formats.
* tests/misc/stat-fmt.sh: Add a test case for new modifiers.
Addresses https://bugs.gnu.org/48960
2021-06-21 12:01:04 +01:00
Paul Eggert
4edad9e121 build: update gnulib submodule to latest
Coreutils mistakenly did not list xstrndup as a module
that it depends on directly.  When the latest Gnulib removed
the dirname module's dependency on xstrndup, this mistake
caused coreutils to not build.  Since all of Coreutils's
uses of xstrndup know the string length, xmemdup0 is a better
match for what's needed.  Since the size args are typically
signed or derived from subtracting pointers, the new Gnulib
ximemdup0 function is a better match yet.
So, use ximemdup0 instead of xstrndup.
* src/cut.c, src/dircolors.c, src/expand-common.c, src/expand.c:
* src/numfmt.c, src/set-fields.c, src/unexpand.c:
Do not include xstrndup.h; no longer needed.
* src/dircolors.c (parse_line):
* src/expand-common.c (parse_tab_stops):
* src/numfmt.c (parse_format_string):
* src/set-fields.c (set_fields):
Use ximemdup0 instead of xstrndup.
2021-06-11 18:05:57 -07:00
Jim Meyering
370c294018 maint: bootstrap: remove reference to unused hash-pjw module
* bootstrap.conf (gnulib_modules): Remove hash-pjw. No longer used.
2021-05-28 13:10:46 -07:00
Pádraig Brady
d1b0257077 build: update gnulib submodule to latest
Fixes a false test failure with MALLOC_CHECK_ set.

* gnulib: Update to latest.
2021-05-15 20:33:26 +01:00
Pádraig Brady
26eccf6c98 copy: remove fiemap logic
This is now only used on 10 year old linux kernels,
and performs a sync before each copy.

* src/copy.c (extent_copy): Remove function and all callers.
* src/extent-scan.c: Remove.
* src/extent-scan.h: Remove.
* src/fiemap.h: Remove.
* src/local.mk: Adjust for removed files.
* NEWS: Adjust to say fiemap is removed.
2021-05-15 16:14:11 +01:00
Pádraig Brady
ba5e6885d2 copy: disallow copy_file_range() on Linux kernels before 5.3
copy_file_range() before Linux kernel release 5.3 had many issues,
as described at https://lwn.net/Articles/789527/, which was
referenced from https://lwn.net/Articles/846403/; a more general
article discussing the generality of copy_file_range().
Linux kernel 5.3 was released in September 2019, which is new enough
that we need to actively avoid older kernels.

* src/copy.c (functional_copy_file_range): A new function
that returns false for Linux kernels before version 5.3.
(sparse_copy): Call this new function to gate use of
copy_file_range().
2021-05-13 00:14:22 +01:00
Pádraig Brady
6b499720fe tests: fix tests/cp/sparse-2.sh false failure on some systems
* tests/cp/sparse-2.sh: Double check cp --sparse=always,
with dd conv=sparse, in the case where the former didn't
create a sparse file.  Now that this test is being newly run
on macos, we're seeing a failure due to seek() not creating
holes on apfs unless the size is >= 16MiB.
2021-05-12 22:14:11 +01:00
Pádraig Brady
4eb2e9c11a tests: ensure we test SEEK_DATA where used
fiemap is no longer the default copy implementation,
so check for SEEK_DATA support instead as that's preferred.
This will ensure better test coverage on systems without fiemap.

* init.cfg: Replace fiemap_capable_ with seek_data_capable_.
This is best supported with python 3 so prefer that.
* tests/seek-data-capable: A new test script checking for
SEEK_DATA support on the passed file name,
called from seek_data_capable_.
* tests/fiemap-capable: Remove no longer used probing script.
* tests/cp/fiemap-perf.sh: Renamed to tests/cp/sparse-perf.sh
* tests/cp/fiemap-2.sh: Renamed to tests/cp/sparse-2.sh
* tests/cp/fiemap-extents.sh: Renamed to tests/cp/sparse-extents.sh
* tests/cp/sparse-fiemap.sh: Renamed to tests/cp/sparse-extents-2.sh
* tests/cp/fiemap-FMR.sh: Renamed to tests/cp/copy-FMR.sh
* tests/local.mk: Reference the renamed tests.
2021-05-12 22:14:11 +01:00
Pádraig Brady
2e66e1732f copy: handle system security config issues with copy_file_range()
* src/copy.c (sparse_copy): Upon EPERM from copy_file_range(),
fall back to a standard copy, which will give a more accurate
error as to whether the issue is with the source or destination.
Also this will avoid the issue where seccomp or apparmor are
not configured to handle copy_file_range(), in which case
the fall back standard copy would succeed without issue.
This specific issue with seccomp was noticed for example in:
https://github.com/golang/go/issues/40900
2021-05-12 22:14:11 +01:00
Pádraig Brady
017877bd08 copy: handle EOPNOTSUPP from SEEK_DATA
* src/copy.c (infer_scantype): Ensure we don't error out
if SEEK_DATA returns EOPNOTSUPP, on systems where this value
is distinct from ENOTSUP.  Generally both of these should be checked.
2021-05-12 22:14:11 +01:00
Pádraig Brady
8ec0d1799e copy: handle ENOTSUP from copy_file_range()
* src/copy.c (sparse_copy): Ensure we fall back to
a standard copy if copy_file_range() returns ENOTSUP.
This generally is best checked when checking ENOSYS,
but it also seems to be a practical concern on Centos 7,
as a quick search gave https://bugzilla.redhat.com/1840284
2021-05-12 22:14:11 +01:00
Pádraig Brady
e35e4d1757 build: update gnulib submodule to latest
Fixes a bits/long-double.h include build issue on some systems.

* bootstrap: Sync new --version option from gnulib.
* gnulib: Update to lastest.
Reported by Carl Edquist
2021-05-10 17:44:57 +01:00
Carl Edquist
bf483155e5 build: fix __get_cpuid_count check to catch link failure
The test program will compile successfully even if __get_cpuid_count
is not declared.  The error for the missing symbol will only show up
at link time.  Thus, use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE.

* configure.ac (__get_cpuid_count check): Use C_LINK_IFELSE instead
of AC_COMPILE_IFELSE.
(__get_cpuid check): Likewise.
2021-05-10 13:35:20 +01:00
Pádraig Brady
09bbb2b703 maint: consistently free hash structures in dev mode
Ensure we call hash_free() to avoid valgrind and leak_sanitizer
"definitely lost" warnings.  These were not real leaks as
we terminate immediately after, but we should avoid these
"definitely lost" warnings where possible.

* src/copy.c: Add dest_info_free() and src_info_free().
* src/copy.h: Declare the above.
* src/cp-hash.c: Don't define unless "lint" is defined.
* src/install.c: Call dest_info_free() in dev mode.
* src/mv.c: Likewise.
* src/cp.c: Likewise. Also call src_info_free().
* src/ln.c: Call hash_free() in dev mode.
* src/tail.c: Call hash_free() even if about to exit, in dev mode.

Fixes https://bugs.gnu.org/48189
2021-05-08 14:57:33 +01:00
Bernhard Voelker
65e4d0f71e maint: fix sc_space_before_open_paren failure
* src/copy.c (dest_info_init): Add space before parens.
(src_info_init): Likewise.
Syntax-check failure introduced in the previous commit.
2021-05-06 23:42:57 +02:00
Pádraig Brady
f1d2e8e289 copy: exit immediately upon failure to allocate hash memory
* src/copy.c (dest_info_init, src_info_init): Terminate immediately
upon memory exhaustion.
2021-05-03 18:53:35 +01:00
Pádraig Brady
ea9af99234 copy: ensure we enforce --reflink=never
* src/copy.c (sparse_copy): Don't use copy_file_range()
with --reflink=never as copy_file_range() may implicitly
use acceleration techniques like reflinking.
(extent_copy): Pass through whether we allow reflinking.
(lseek_copy): Likewise.
Fixes https://bugs.gnu.org/48164
2021-05-02 21:27:17 +01:00
Pádraig Brady
e7fff54c92 wc: add --debug to diagnose which implementation used
* src/wc.c: (main): Handle the new --debug option.
Only call avx2_supported if needed.
(avx2_supported): Diagnose various failures and attempts.
* NEWS: Mention the new wc improvement and --debug option.
2021-05-02 20:51:37 +01:00
Kristoffer Brånemyr
4064c57380 wc: use avx2 optimization when counting only lines
Use cpuid to detect CPU support for avx2 instructions.
Performance was seen to improve by 5x for a file with only newlines,
while the performance for a file with no such characters is unchanged.

* configure.ac [USE_AVX2_WC_LINECOUNT]: A new conditional,
set when __get_cpuid_count() and avx2 compiler intrinsics are supported.
* src/wc.c (avx2_supported): A new function using __get_cpuid_count()
to determine if avx2 instructions are supported.
(wc_lines): A new function refactored from wc(),
which implements the standard line counting logic,
and provides the fallback implementation for when avx2 is not supported.
* src/wc_avx2.c: A new module to implement using avx2 intrinsics.
* src/local.mk: Reference the new module.  Note we build as a separate
lib so that it can be portably built with separate -mavx2 etc. flags.
2021-05-02 20:51:37 +01:00
Paul Eggert
d435cfc0bc touch: fix wrong diagnostic (Bug#48106)
Problem reported by Roland (Bug#48106).
* src/touch.c (touch): Take more care when deciding whether
to use open_errno or utime_errno in the diagnostic.
Stop worrying about SunOS 4 (which as part of the problem),
as it’s long obsolete.  For Solaris 10, verify that EINVAL
really means the file was a directory.
2021-05-01 15:47:13 -07:00
Paul Eggert
62a7ce5f50 maint: port to Autoconf 2.71
* configure.ac: Use AC_PROG_CC, not AC_PROG_CC_STDC.
* gl/modules/smack (configure.ac):
* m4/jm-macros.m4 (coreutils_MACROS):
* m4/xattr.m4 (gl_FUNC_XATTR):
Use AS_HELP_STRING, not AC_HELP_STRING.
* m4/check-decl.m4 (gl_CHECK_DECLS):
Do not require AC_HEADER_TIME; we no longer care about it directly.
* m4/jm-macros.m4 (coreutils_MACROS):
Do not require AC_ISC_POSIX, which became obsolete in 2006.
Use AC_LINK_IFELSE instead of AC_TRY_LINK.
2021-04-26 23:32:45 -07:00
Paul Eggert
8527942835 csplit: size_t overflow check
* src/csplit.c (get_new_buffer): Fix unlikely size_t overflow.
2021-04-26 23:32:45 -07:00
Paul Eggert
5fcf8c6487 build: update gnulib submodule to latest
* src/csplit.c (load_buffer):
* src/pinky.c (create_fullname):
Use intprops-based checks rather than xalloc_oversized,
since Gnulib xalloc.h no longer includes xalloc-oversized.h.
2021-04-26 23:32:45 -07:00
Zorro Lang
785478013b copy: do not refuse to copy a swap file
* src/copy.c (sparse_copy): Fallback to read() if copy_file_range()
fails with ETXTBSY.  Otherwise it would be impossible to copy files
that are being used as swap.  This used to work before introducing
the support for copy_file_range() in coreutils.  (Bug#48036)
2021-04-26 18:00:58 -07:00
Bernhard Voelker
b7091093bb tests: fix FP in ls/stat-free-color.sh
On newer systems like Fedora 34 and openSUSE Tumbleweed, ls(1) calls
newfstatat(STDOUT_FILENO, ...), but only when there is something to
output.

* tests/ls/stat-free-color.sh: Add -a option to the reference invocation
of ls, thus enforcing something gets output.
2021-04-22 20:14:32 +02:00
Pádraig Brady
34a48bf0f0 doc: clarify that ln --relative requires --symbolic to be specified
* doc/coreutils.texi (ln invocation): State --symbolic is required.
* src/ln.c (usage): Explicitly state -s is not implied.
Fixes https://bugs.gnu.org/47703
2021-04-11 19:23:37 +01:00
Pádraig Brady
512fe04902 doc: clarify what's counted by wc
* src/wc.c (usage): State that only printable characters are considered
when counting words.  This also disambiguates wether we're talking
about bytes or characters in this context.
* doc/coreutils.texi (wc invocation): Likewise.  Also clarify
that --characters counts valid locale aware characters,
and that --lines does not count a trailing "line" unless
it ends with a newline character.
Fixes https://bugs.gnu.org/47702
2021-04-11 19:23:13 +01:00
Pádraig Brady
ef772bf97f maint: use "char const *" rather than "const char *"
* cfg.mk (sc_prohibit-const-char): Add a new syntax-check to
enforce this style.
* *.[ch]: sed -i 's/const char \*/char const */g'
2021-04-11 18:33:45 +01:00
Pádraig Brady
34ed19eed8 ls: cache name width determination
This is especially important now for --sort=width,
as that can greatly increase how often this
expensive quote_name_width() function is called per file.

This also helps the default invocation of ls,
or specifically the --format={across,vertical} cases
(when --width is not set to 0),
to avoid two calls to this function per file.

Note the only case where we later compute the width,
is for --format=commas.  That's only done once though,
so we leave the computation close to use to
maximize hardware caching.

* src/ls.c (struct fileinfo): Add a WIDTH member to cache
the screen width of the file name.
(update_current_files_info): Set the WIDTH members for cases
they're needed multiple times.  Note we do this explicitly here,
rather than caching at use, so that the fileinfo
structures can remain const in the sorting and presentation functions.
(sort_files): Call the new update_current_files_info() in this
initialization function.
(fileinfo_name_width): Renamed from fileinfo_width,
and adjusted to return the cached value if available.
2021-04-11 14:58:45 +01:00
Carl Edquist
751ad58e00 ls: add --sort=width option to sort by file name width
This helps identify the outliers for long filenames, and also produces
a more compact display of columns when listing a directory with many
entries of various widths.

* src/ls.c (sort_type, sort_types, sort_width): New sort_width sort
type.
(sort_args): Add "width" sort arg.
(cmp_width, fileinfo_width): New sort function and helper for file name
width.
(quote_name_width): Add function prototype declaration.
(usage): Document --sort=width option.
* doc/coreutils.texi: Document --sort=width option.
* tests/ls/sort-width-option.sh: New test for --sort=width option.
* tests/local.mk: Reference new test.
* NEWS: Mention the new feature.
2021-04-11 14:58:38 +01:00
Paul Eggert
e3766c5db1 env: simplify --split-string memory management
* bootstrap.conf (gnulib_modules): Add idx.
* src/env.c: Include idx.h, minmax.h.
Prefer idx_t to ptrdiff_t when values are nonnegative.
(valid_escape_sequence, escape_char, validate_split_str)
(CHECK_START_NEW_ARG):
Remove; no longer needed now that we validate as we go.
(struct splitbuf): New type.
(splitbuf_grow, splitbuf_append_byte, check_start_new_arg)
(splitbuf_finishup): New functions.
(build_argv): New arg ARGC.  Validate and process in one go, using
the new functions; this is simpler and more reliable than the old
approach (as witness the recent bug).  Avoid integer overflow in
the unlikely case where the string contains more than INT_MAX
arguments.
(parse_split_string): Simplify by exploiting the new build_argv.
2021-03-29 21:44:58 -07:00
Paul Eggert
5b5622f605 build: update gnulib submodule to latest 2021-03-29 21:44:58 -07:00
Pádraig Brady
9f1bda18f2 tests: add a test case for recent env fix
* tests/misc/env-S.pl: Add a test case for recent commit ec6904f0.
2021-03-29 15:48:39 +01:00
Pádraig Brady
f20797f1d7 maint: ignore all .a files in .gitignore
* .gitignore: Rather than add the new src/libcksum_pclmul.a,
just ignore any such libs.
* src/.gitignore: Likewise.
Reported by Kristoffer Brånemyr.
2021-03-29 14:10:09 +01:00
Paul Eggert
12abdb757a env: prefer ptrdiff_t
* src/env.c (usvars_used, vnlen, unset_envvars, expansion)
(build_argv): Prefer ptrdiff_t to size_t when either will do.
2021-03-26 15:17:28 -07:00
Paul Eggert
5f99c7533d env: improve whitespace warning
* src/env.c (main): Issue -S warning for any whitespace,
not just space.
2021-03-26 15:17:28 -07:00
Paul Eggert
7fc887299e env: use GNU coding style
* src/env.c: Use GNU coding style for recentish changes.
2021-03-26 15:17:28 -07:00
Paul Eggert
52f11d8b7c env: remove asserts
The assertions didn’t help catch the most recent bug which
was in their area, and kind of get in the way.
* src/env.c: Do not include <assert.h>, and remove all assertions.
These seem to have been put in to pacify gcov, but surely there’s
a better way.
(escape_char): Pacify GCC with 'assume' instead.
2021-03-26 15:17:28 -07:00
Paul Eggert
6c4efdc0f5 doc: document env fix
* NEWS, doc/coreutils.texi (env invocation): Document recent change.
2021-03-26 15:17:28 -07:00
Paul Eggert
ec6904f0ed env: fix address violation with '\v' in -S
Problem reported by Frank Busse (Bug#47412).
* src/env.c (C_ISSPACE_CHARS): New macro.
(shortopts, build_argv, main): Treate all C-locale space
characters like space and tab, for compatibility with FreeBSD.
(validate_split_str, build_argv, parse_split_string):
Use the C locale, not the current locale, to determine whether a
byte is a space character.
2021-03-26 13:50:16 -07:00
Paul Eggert
4698e284f3 hostname: pacify valgrind
* src/hostname.c (main) [IF_LINT]: Free hostname (Bug#47384).
2021-03-25 11:21:15 -07:00
Paul Eggert
c7a588ac36 hostname: use puts
* src/hostname.c (main): Prefer puts to printf "%s\n".
2021-03-25 09:19:02 -07:00
Paul Eggert
8980b7c898 maint: indenting
* src/ln.c: Fix indenting.
2021-03-25 09:19:02 -07:00
Kamil Dudka
6e98f67758 ln: fix memory leaks in do_link
* src/ln.c (do_link): Free memory allocated by convert_abs_rel
on all code paths (Bug#47373).
2021-03-25 09:19:02 -07:00
Paul Eggert
238dd8eb76 stdbuf: port lib to macOS
* src/libstdbuf.c (fprintf, free, strtoumax): Undef these too,
since Gnulib might replace them.
2021-03-24 17:00:46 -07:00
Paul Eggert
1677294076 cksum: port recent changes to macOS
* src/cksum.c (cksum_slice8): Fix bug on little-endian
platforms lacking __bswap_32: the SWAP macro evaluates
its argument multiple times, but the macro has a side effect.
2021-03-24 16:47:50 -07:00
Bernhard Voelker
b5a6a56ffc maint: update bootstrap from gnulib
* bootstrap: Sync from gnulib/build-aux/bootstrap; the previous gnulib
update (commit 1a3eb6c30) missed to update that file.
2021-03-22 16:52:11 -07:00
Paul Eggert
a71539e628 ptx: remove use of diacrit module
The diacrit module is obsolete, and ptx’s use of it is obsolete
too; it assumes an 8-bit locale (not that common these days) and
that TeX cannot process the 8-bit characters (nowadays, it can).
* NEWS, doc/coreutils.texi (Charset selection in ptx): Document this.
* bootstrap.conf (gnulib_modules): Remove diacrit.
* src/ptx.c: Do not include diacrit.h.
(print_field, fix_output_parameters): Remove obsolete support
for 8-bit diacritics.
2021-03-21 14:01:15 -07:00
Paul Eggert
1a3eb6c305 build: update gnulib submodule to latest 2021-03-21 14:01:15 -07:00
Pádraig Brady
86c8dc2e85 cksum: don't exit immediately if a single file overflows
This behavior was introduced in commit FILEUTILS-4_0_44-4-g519b707b4.

* src/cksum.c (cksum_slice8): Only report the overflow, and continue.
* src/cksum_pclmul.c (cksum_pclmul): Likewise.
2021-03-15 13:12:29 +00:00
Pádraig Brady
b73b9fcb1d cksum: add --debug to diagnose which implementation used
* src/cksum.c: (main): Use getopt_long to parse options,
and handle the new --debug option.
(pclmul_supported): Diagnose various failures and attempts.
* NEWS: Mention the new option.
2021-03-15 12:44:27 +00:00
Kristoffer Brånemyr
4b9118cdb3 cksum: use pclmul hardware instruction for CRC32 calculation
Use cpuid to detect CPU support for hardware instruction.
Fall back to slice by 8 algorithm if not supported.
A 500MiB file improves from 1.40s to 0.67s on an i3-2310M

* configure.ac [USE_PCLMUL_CRC32]: A new conditional,
set when __get_cpuid() and clmul compiler intrinsics are supported.
* src/cksum.c (pclmul_supported): A new function using __get_cpuid()
to determine if pclmul instructions are supported.
(cksum): A new function refactored from cksum_slice8(),
which calls pclmul_supported() and then cksum_slice8()
or cksum_pclmul() as appropriate.
* src/cksum.h: Export the crctab array for use in the new module.
* src/cksum_pclmul.c: A new module to implement using pclmul intrinsics.
* po/POTFILES.in: Reference the new cksum_pclmul module.
* src/local.mk: Likewise.  Note we build it as a separate library
so that it can be portably built with separate -mavx etc. flags.
* tests/misc/cksum.sh: Add new test modes for pertinent buffer sizes.
2021-03-15 12:44:22 +00:00
Pádraig Brady
90c4ef1f7d maint: propagate DEPENDENCIES to libs in single binary mode
build-aux/gen-single-binary.sh (override_single): A new function
to refactor the existing mappings for dir, vdir, and arch.
This function now also sets the DEPENDENCIES variable so that these
dependencies can be maintained later in the script, where
we now propagate the automake generated $(src_$cmd_DEPENDENCIES)
to our equivalent src_libsinglebin_$cmd_a_DEPENDENCIES.
This will ensure that any required libs are built,
which we require in a following change to cksum that
builds part of it as a separate library.
2021-03-14 23:45:46 +00:00
Pádraig Brady
9de1d153f8 rmdir: diagnose non following of symlinks with trailing slash
GNU/Linux is unusual here in that rmdir("symlink/") returns ENOTDIR,
whereas Solaris and FreeBSD at least, will follow the symlink
and remove the target directory.  We don't make the behavior
on Linux kernels consistent, but at least clarify
the confusing error message.

* src/rmdir (main): Output a specific error message for the above case.
(remove_parents): In the error message, don't assume intermediate paths
are directories, as they could be symlinks.
* tests/rmdir/symlink-errors.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
2021-02-19 11:35:30 +00:00
Kamil Dudka
a5e0d8f387 stat,tail: add support for the exfat file system
Bug: https://bugzilla.redhat.com/1921427

* src/stat.c (human_fstype): Add case for the 'exfat' file system type.
* NEWS: Mention the Improvement.
Fixes https://bugs.gnu.org/46613
2021-02-18 13:50:29 +00:00
Erik Auerswald
bd6c97deed pr: fix alignment of input tabs to multiple columns
This regression was introduced in commit COREUTILS-6_8-58-g553d347d3

* src/pr.c (init_parameters): Process tabs for multiple columns.
* tests/pr/pr-tests.pl: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46422
2021-02-15 21:31:07 +00:00
Pádraig Brady
2de30c7350 cat: extend --show-ends to show \r\n as ^M$
- \r\n is common a line end combination
  - catting such a file without options causes it to display normally
  - overwriting the first char with $, loses info

* src/cat.c (cat): Convert \r preceeding a \n to ^M.
* tests/misc/cat-E.sh: New test.
* tests/local.mk: Reference new test.
* tests/misc/cat-proc.sh: Fix typo.
* doc/coreutils.texi (cat invocation): Mention the new behavior.
* NEWS: Mention the improvement.
2021-02-10 14:17:26 +00:00
Paul Eggert
735083ba24 expr: fix bug with unmatched \(...\)
Problem reported by Qiuhao Li.
* NEWS: Mention this.
* doc/coreutils.texi (String expressions):
Document the correct behavior, which POSIX requires.
* src/expr.c (docolon): Treat unmatched \(...\) as empty.
* tests/misc/expr.pl: New test.
2021-01-26 09:24:41 -08:00
Pádraig Brady
bb21daa125 split: fix --number=K/N to output correct part of file
This functionality regressed with the adjustments
in commit v8.25-4-g62e7af032

* src/split.c (bytes_chunk_extract): Account for already read data
when seeking into the file.
* tests/split/b-chunk.sh: Use the hidden ---io-blksize option,
to test this functionality.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46048
2021-01-25 21:39:09 +00:00
Paul Eggert
eebed78799 doc: rmdir --recursive substitutes
* doc/coreutils.texi (rmdir invocation): Add note on how to remove
empty subdirectories recursively.
2021-01-18 21:09:27 -08:00
Paul Eggert
e9789a1cf2 mkdir: fix bug when -m's more generous than umask
Problem reported by David McCall (Bug#45886).
I introduced this problem when fixing Bug#14371.
* NEWS: Mention the fix.
* src/mkdir.c (struct mkdir_options): New members umask_ancestor,
umask_self, replacing umask_value.
(make_ancestor): Use them when temporarily adjusting umask.
(main): Set them, and set the umask to umask_self instead
of leaving it alone.
* tests/mkdir/perm.sh (tests): Add test case for bug.
2021-01-15 02:59:24 -08:00
Paul Eggert
06f70d9ee6 doc: modernize and fix regexp xref
* doc/coreutils.texi: Fix regexp cross-reference that had become
out-of-date (Bug#45749).  Also, fix some obsolete references to
SunOS and to /usr/dict/words, and change “Linux” to “GNU/Linux”
where appropriate.  Unfortunately the pipeline example gets more
complicated since /usr/share/dict/words is not sorted the way that
‘comm’ wants.
2021-01-09 13:05:50 -08:00
Bernhard Voelker
ebf2c4dcc6 doc: make formatting of SEE ALSO in cat.1 and tac.1 consistent
None of the coreutils man pages - but the two above - are using bold
setting for the references to other man pages in the SEE ALSO section.

* man/cat.x (SEE ALSO): Remove '\fB...\fP' setting.
* man/tac.x: Likewise, and add a reference to cat(1).
2021-01-03 13:57:36 +00:00
Bernhard Voelker
f01d9e23db maint: exempt 'doc/fdl.texi' from 'make update-copyright'
This file is a copy from gnulib and therefore should not get changed
by the yearly update.

* .x-update-copyright: Add pattern for the above file.
* doc/fdl.texi: Revert the previous change.
2021-01-02 01:39:15 +01:00
Pádraig Brady
32ff1d1313 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.
2021-01-01 16:36:09 +00:00
Pádraig Brady
ffb7ebfa25 tests: add a test for cksum
* tests/misc/cksum.sh: Test basic operation.
* tests/local.mk: Reference the new test.
2020-12-28 16:21:38 +00:00
Kristoffer Brånemyr
a7533917e0 cksum: use more efficient slice by 8 algorithm
A 100MB file improves from 2.50s to 1.80s on a Sparc T5220
A 100MB file improves from 0.54s to 0.13s on an i3-2310M

* bootstrap.conf: Explicitly depend on byteswap,
since now used directly by coreutils.
* src/cksum.c (cksum): Process in multiples of 8 bytes.
(main): Adjust for generation of expanded crctab.
* src/cksum.h: Split now larger crctab to separate header.
* src/local.mk: Reference the new header.
* NEWS: Mention the improvement.
2020-12-28 16:21:38 +00:00
Paul Eggert
fb64712c4d build: update gnulib submodule to latest
* src/make-prime-list.c (free): Undef, since Gnulib's free-posix
module now defines this to rpl_free on some platforms.
2020-12-24 22:03:13 -08:00
Pádraig Brady
08b59f31a5 doc: remove extraneous ./src/ prefix from examples
* doc/coreutils.texi (numfmt invocation): s|./src/numfmt|numfmt|
2020-12-18 14:58:59 +00:00
Pádraig Brady
e5cb4aaa0b doc: add seq inf and sleep inf examples to texinfo
* doc/coreutils.texi (seq invocation): Mention "inf" is supported,
and describe that it's handled specially to generate infinite
whole integer sequences.  Also mention that such infinite generation
is supported for integer steps up to 200.
(sleep invocation): Give `sleep inf` as an example to sleep forever.
* src/seq.c: Add a comment on SEQ_FAST_STEP_LIMIT, to say it's
reflected in the texinfo description.
2020-12-18 14:54:57 +00:00
Paul Eggert
3e61d5dd31 doc: document mkdir -m -p better
Chris Colohan wrote that the man page did not do enough to dispel
a common misunderstanding that “contributed to one of the scariest
outages Google has ever seen” (Bug#45258).
* doc/coreutils.texi (mkdir invocation):
* src/mkdir.c (usage): Document -m vs -p better.
2020-12-15 11:58:48 -08:00
KOBAYASHI Takashi
567fc2c2ad nl: fix --section-delimiter handling of single characters
* src/nl.c (main): Enforce the POSIX specified
behavior of assuming ':' is specified after a single
character argument to -d.
* tests/misc/nl.sh: Add a test case.
* NEWS: Mention the bug fix.
2020-12-15 14:11:55 +00:00
Pádraig Brady
1935528ce9 doc: mention the GNU extensions to nl --section-delimiter
* doc/coreutils.texi (nl invocation): Mention the GNU extensions
of allowing arbitrary length and empty delimiter strings.
* src/nl.c (usage): Likewise.
* tests/misc/nl.sh: Add test cases for the GNU extensions.
2020-12-15 14:11:51 +00:00
Pádraig Brady
b0d527fb40 maint: refactor nl section delimiter handling
* src/nl.c (main): Update the default delimiter characters
when passed two characters with --section-delimiter.
Avoid redundant copies for the body and footer delimiter strings,
and instead, just offset into the header string.
(check_section): Avoid redundant comparing of 2 bytes of memory
for an empty delimiter.
2020-12-15 13:17:39 +00:00
Paul Eggert
d312696559 build: update gnulib submodule to latest 2020-12-11 19:04:04 -08:00
Arman Absalan
14562f8b20 chroot,comm,join: fix usage options style
* src/chroot.c (usage): Fix indentation of options.
* src/comm.c: Likewise.
* src/join.c: Likewise.
2020-12-08 18:08:17 +01:00
Pádraig Brady
e361bff8a5 date: with --debug, show the output format
The format can be determined from --options or the locale,
so it's useful to output the format string being used.

* src/date.c (show_date): Show the output format
along with the date being shown.
* tests/misc/date-debug.sh: Adjust accordingly.
Addresses https://bugs.gnu.org/44960
2020-12-01 13:51:06 +00:00
Tim Gates
5ed804a9b8 maint: fix typo, characteres -> characters
* src/expr.c: Fix typo in comment.
2020-11-27 19:56:02 +00:00
Nishant Nayan
6bf108358a rm: do not skip files upon failure to remove an empty dir
When removing a directory fails for some reason, and that directory
is empty, the rm_fts code gets the return value of the excise call
confused with the return value of its earlier call to prompt,
causing fts_skip_tree to be called again and the next file
that rm would otherwise have deleted to survive.

* src/remove.c (rm_fts): Ensure we only skip a single fts entry,
when processing empty dirs.  I.e. only skip the entry
having successfully removed it.
* tests/rm/empty-immutable-skip.sh: New root-only test.
* tests/local.mk: Add it.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/44883
2020-11-26 16:51:38 +00:00
Pádraig Brady
b886390947 maint: mention in NEWS about new df remote fs types
* NEWS: Mention new remote file system types
recognized since gnulib commit dd1fc46b.
2020-11-26 14:29:57 +00:00
Pádraig Brady
e53bb7ad05 maint: remove no longer needed se_const helper
This was needed before libselinux-2.3 (May 2014),
but modern releases have the correct const declarations.

* src/chcon.c: Remove se_const() wrapper.
* src/cp.c: Likewise.
* src/install.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
* src/system.h: Likewise.
* gnulib: update to pick up const correctness fixes in selinux stubs.
2020-11-23 22:25:55 +00:00
Pádraig Brady
382044196e maint: fix syntax-check failure
* po/POTFILES.in (src/selinux.c): Remove entry as this source doesn't
contain any translatable strings anymore; avoids a sc_po_check failure.
2020-11-23 14:09:51 +00:00
Paul Eggert
d12f5da6d4 install: suppress "Operation not supported" false alarms
At least, I *think* they are false alarms.  An SELinux expert eye
would be welcome.
* src/install.c (setdefaultfilecon): If selabel_lookup fails
due to either ENOTSUP or ENODATA, don’t diagnose the issue.
Problem reported by Kamil Dudka in:
https://lists.gnu.org/r/coreutils/2020-11/msg00050.html
2020-11-23 01:48:45 -08:00
Paul Eggert
b8a543fe02 maint: propagate errno better in selinux.c
* src/selinux.c: Don’t include die.h; no longer needed.
(computecon, defaultcon, restorecon): Propagate errno.
(defaultcon, restorecon): Don’t diagnose errors or exit, as that’s
the caller’s responsibility.
2020-11-23 01:00:23 -08:00
Pádraig Brady
7b341f084b maint: use absolute paths with selabel_lookup
* src/selinux.c: selabel_lookup requires absolute paths
(while only older matchpathcon before libselinux < 2.1.5 2011-0826 did).
* po/POTFILES.in: Readd src/selinux.c since we now have
a translatable error message.
2020-11-23 01:00:22 -08:00
Bernhard Voelker
344cf0ee5f maint: minor cleanup
The previous commit introduced a couple of syntax-check failures.

* .gitignore (/lib/se-label.h): Add entry to silence the
sc_gitignore_missing check.  Sort entries in C locale.
* po/POTFILES.in (src/selinux.c): Remove entry as this source doesn't
contain any translatable strings anymore; avoids a sc_po_check failure.
* src/mv.c: Replace tabs by spaces to avoid complaints by
sc_prohibit_tab_based_indentation.
2020-11-22 15:17:17 +01:00
Paul Eggert
fc372b4ba7 build: update gnulib submodule to latest 2020-11-21 19:13:11 -08:00
Paul Eggert
3aaa42deaa maint: port from matchpathcon to selabel_lookup
Ubuntu 20.10 is using a newer version of libselinux that
complains that matchpathcon is obsolete.  Rewrite the code
that it uses the recommended selabel_lookup instead.
* m4/jm-macros.m4 (coreutils_MACROS): Do not check for
matchpathcon_init_prefix, as it is no longer used.
* src/copy.c (set_file_security_ctx): Omit process_local arg,
as it is equivalent to !x->set_security_context.  All callers changed.
* src/copy.h (struct cp_options): set_security_context is now of
type struct selabel_handle *, not bool.  All uses changed.
* src/cp.c, src/install.c, src/mkdir.c, src/mkfifo.c, src/mknod.c:
* src/mv.c: Include selinux/label.h.
(main): Use selabel_open for set_security context.
* src/install.c (matchpathcon_init_prefix): Remove; now unused.
(get_labeling_handle): New static function.
(setdefaultfilecon, main): Use it.
(setdefaultfilecon): Do something regardless of
ENABLE_MATCHPATHCON, which seems to be a revenant macro.
(setdefaultfilecon): Use selabel_lookup instead of the obsolescent
matchpathcon.  Report an error unless it fails due to ENOENT.
* src/local.mk (src_ginstall_CPPFLAGS): Remove.
* src/selinux.c: Include selinux/label.h
Do not include die.h, error.h, canonicalize.h.
(defaultcon, restorecon_private, restorecon):
New arg HANDLE.  All callers changed.
Use selabel_lookup rather than matchpathcon.
(restorecon_private, restorecon): Don’t lose track of errno.
* src/selinux.c, src/selinux.h:
(restorecon): Don’t call ‘error’; that’s the caller’s job.
Use HAVE_SELINUX_LABEL_H, not HAVE_SELINUX_SELINUX_H,
in case there is some weird system with the former but not the latter.
* src/selinux.h (struct selinux_handle): Add forward decl.
2020-11-21 18:41:25 -08:00
Paul Eggert
5c8e2716b3 build: port to Solaris 10
* src/local.mk (src_ln_LDADD, src_mktemp_LDADD, src_tac_LDADD):
Add $(LIB_CLOCK_GETTIME), since these use tempname which uses
clock_gettime if getrandom fails.  On platforms like Solaris 10,
clock_gettime is not in the standard C library.
2020-11-21 18:41:25 -08:00
Paul Eggert
4c667a86d3 build: update gnulib submodule to latest 2020-11-21 18:41:24 -08:00
Pádraig Brady
c3a5280731 doc: mention that sort -g supports hex numbers
* doc/coreutils.texi (sort invocation): Mention explicitly
that --general-numeric-sort supports arbitrary format hex numbers,
but also mention that consistent case/width hex numbers can
be sorted faster with a standard sort.
2020-11-18 14:00:43 +00:00
Pádraig Brady
2bc66c5ea7 tr: fix crash validating -c with some case char classes
This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v8.5-163-g3f48829c2

* src/tr.c (validate_case_classes): Don't apply these
extra case alignment checks in the --complement case,
which is even more restrictive as to the contents of SET2.
* tests/misc/tr-case-class.sh: Add a test case,
for a large SET1, which caused the length adjustment
in validate_case_classes to underflow and trigger the assert.
* NEWS: Mention the bug fix.
2020-11-14 16:51:49 +00:00
Ben Pfaff
1833f51aaa doc: clarify in texinfo that test == ... is non portable
* doc/coreutils.texi (test invocation): Mention non portability
of the double equals form.
2020-11-12 18:59:31 +00:00
Pádraig Brady
6fc695cb4a ls: fix crash printing SELinux context for unstatable files
This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v6.9.90-11-g4245876e2

* src/ls.c (gobble_file): Ensure scontext is initialized
in the case where files are not statable.
* tests/ls/selinux-segfault.sh: Renamed from proc-selinux-segfault.sh,
and added test case for broken symlinks.
* tests/local.mk: Adjust for the renamed test.
* NEWS: Mention the bug fix.
2020-11-11 17:28:54 +00:00
Pádraig Brady
beafa5c0a3 timeout: support sub-second timeouts on macOS
* m4/jm-macros.m4: Check for setitimer.
* src/timeout.c: Use setitimer if timer_settime is not available.
* NEWS: Mention the improvement.
2020-11-07 21:35:01 +00:00
Pádraig Brady
165a80f6e6 maint: avoid strncat warning on GCC
GCC 10.1.1 without optimization gives:

  error: ‘strncat’ argument 2 declared attribute ‘nonstring’
    [-Werror=stringop-overflow=]
    strncat (comment, UT_ID (utmp_ent), utmpsize);

Note the strncat man page says that:
  "src does not need to be null-terminated
   if it contains n or more bytes."
And the POSIX spec says that the second (source) parameter
is an array not a string.
So I think it's incorrect for strncat to require src be a string type.
This constraint seems to be being added to the gcc builtin strncat,
as specifiying -fno-builtin also avoids the warning.
Note specifying any optimization level also avoids the warning.

* src/who.c (make_id_equals_comment): Avoid the issue by using
stpcpy + stzncpy, instead of strcpy + strncat.
This pattern is used elsewhere in who.c
2020-11-07 21:34:34 +00:00
Pádraig Brady
ff80b6b0a0 stat,tail: sync file system constants from the linux kernel
* src/stat.c: Add magic constants for "devmem", and
"zonefs" file systems.
* NEWS: Mention the improvement.
2020-10-28 14:16:29 +00:00
Pádraig Brady
53324dd611 maint: cleanup operation of fs-magic-compare
* src/local.mk: Ensure we map 2 hex digits to 4,
so that we don't output already handled Z3FOLD file system (0x33).
Also hide the generation command for src/fs.h.
2020-10-28 14:16:12 +00:00
Pádraig Brady
51cfaef655 doc: make blank lines before --help consistent
* src/basenc.c (usage): Remove extraneous blank line,
to be consistent with other utilities that have options.
* src/realpath.c: Likewise.
* src/runcon.c: Likewise.
Addresses https://bugs.gnu.org/44248
2020-10-27 19:23:46 +00:00
Jim Meyering
cc816fb978 maint: avoid new sort.c warning from upcoming GCC11
gcc version 11.0.0 20201025 (experimental) warns that
src/sort.c:1655:1: warning: function might be candidate for attribute \
  'pure' if it is known to return normally [-Wsuggest-attribute=pure]
* src/sort.c (limfield): Mark as pure.
2020-10-26 07:47:36 -07:00
Kamil Dudka
4278e6615f dd: drop old workaround for lseek() bug in Linux kernel
The workaround triggers warnings from newer kernel versions in case
a user does not have sufficient privileges for the MTIOCGET ioctl.

* src/dd.c (skip_via_lseek): Drop wrapper function no longer needed.
(skip): Use lseek() directly.
(advance_input_after_read_error): Likewise.

Reported-by: Nir Soffer at https://bugzilla.redhat.com/1876840
Fixes https://bugs.gnu.org/44235
2020-10-26 13:31:36 +00:00
KOBAYASHI Takashi
2c898597ea nl: support a negative --line-increment
* src/nl.c (main): Allow -i to accept down to INTMAX_MIN.
* tests/misc/nl.sh: Add test cases.
* NEWS: Mention the new feature.
2020-10-26 13:15:46 +00:00
Pádraig Brady
fe41d6c651 nl: only fail if need to output overflowed numbers
Previously we would have failed immediately upon internal overflow,
which didn't output the full line being processed, and assumed
there would be another numbered line.

* src/nl.c (line_no_overflow): A new global to track overflow.
(print_lineno): Only fail if about to output an overflowed number.
(reset_lineno): A new function to refactor resetting of the number,
and which also clears line_no_overflow.
* tests/misc/nl.sh: Add a test case.
2020-10-25 16:57:19 +00:00
Pádraig Brady
175c7c6a60 maint: add lib/parse-datetime-gen.h to .gitignore
* .gitignore: update to ignore new file
generated by the latest gnulib update.
2020-10-25 13:35:40 +00:00
Pádraig Brady
f803c0e92d maint: sync help2man to latest version
* man/help2man: sync to changes from version 1.47.16.
Note this doesn't materially change the generated man pages.
Addresses https://bugs.gnu.org/44105
2020-10-25 13:31:37 +00:00
Paul Eggert
00ea4bacf6 build: update gnulib submodule to latest
* gl/lib/randperm.c, src/cp-hash.c, src/ls.c, src/sort.c, src/tail.c:
Change all instaces of hash_delete to hash_remove to accommodate
change to Gnulib API.
2020-10-19 10:58:53 -07:00
Grigorii Sokolik
d9b33b1535 maint: remove already handled FIXME in tail.c
* src/tail.c: Remove FIXME to follow a file name in a recreated
directory. The comment was added in commit v8.5-191-g61b77891c
while the fix (albeit not using inotify) was added in
commit v8.27-21-gba5fe2d4b
2020-10-17 16:54:17 +01:00
Grigorii Sokolik
db3131adb8 maint: update docs for build prerequisites
* README-prereq: Explicitly pull tags,
and update the xz git repo url.
2020-10-17 16:53:35 +01:00
Benno Schulenberg
ebaffa5094 doc: fix punctuation in stat --help
* src/stat.c (usage): Replace a mistaken semicolon with a colon,
and replace mistaken backticks with single quotes.  Also reorder
some words, for clarity.
Fixes https://bugs.gnu.org/43707
2020-09-29 21:57:30 +01:00
Pádraig Brady
5b8161ee4d doc: clarify timeout --foreground description
* doc/coreutils.texi (timeout invocation): Avoid any implication
that `timeout --foreground` could be used to retroactively
timeout commands not already invoked by timeout(1).
Fixes bug https://bugs.gnu.org/42831
2020-08-12 18:40:17 +01:00
Emanuele Giacomelli
7cf45f4f6a csplit: fix regex suppression with specific match count
* src/csplit.c (process_regexp): Process the line suppression
in all invocations so that the last match is suppressed.
Previously with a non infinite match count,
the last regex pattern was not suppressed.
* NEWS: Mention the bug fix.
* tests/misc/csplit-suppress-matched.pl: Add a test case.
Fixes https://bugs.gnu.org/42764
2020-08-08 21:50:13 +01:00
Bernhard Voelker
c0e5f8c59b tests: skip some parts of 'tests/rmdir/ignore.sh' if run as root
Parts of this test expect that the rmdir syscall returns with EPERM,
but the root user does not see that.

* tests/rmdir/ignore.sh: Add uid_is_privileged_ guards around parts
of the test which expect rmdir() to fail with EPERM.

Reported by Nick Alcock <nix@esperi.org.uk> in
https://bugs.gnu.org/42633
2020-07-31 19:49:35 +02:00
Bernhard Voelker
881c3f20ec doc: show version in title of HTML manual
* doc/coreutils.texi (@include version.texi): Move before ...
(@settitle): ... this.  Add the version after the package name.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-07/msg00021.html
2020-07-28 23:30:11 +02:00
Paul Eggert
fd0fdeff94 build: update gnulib submodule to latest
* src/local.mk (src_expr_LDADD, src_factor_LDADD):
Adjust to Gnulib renaming of LIB_GMP to LIBGMP.
2020-07-28 13:45:47 -07:00
Pádraig Brady
97757b5eba doc: fix typo in env --split-string documentation
* doc/coreutils.texi: Fix grammar.
2020-07-27 13:16:42 +01:00
Paul Eggert
fa7a5074d7 date: clarify the Epoch
* src/date.c (usage): Mention the Epoch under %s for clarity,
and capitalize.
2020-07-24 13:33:40 -07:00
Paul Eggert
3f06bde222 doc: modernize date examples
* doc/coreutils.texi: Use more-modern date examples.
Capitalize “Epoch” to be consistent with POSIX.
2020-07-24 13:33:40 -07:00
Paul Eggert
7b3a62e016 build: update gnulib submodule to latest
* bootstrap.conf (gnulib_modules): Add hash-triple.
2020-07-24 13:33:40 -07:00
Bernhard Voelker
49bd08aea5 doc: clarify 'timeout -k' behavior
* doc/coreutils.texi (timeout invocation): Document that the the
duration of --kill-after=DURATION begins when sending the initial
signal.  Also mention that -k does not have any effect if timeout's
duration is 0.

Suggested by Jonny Grant <jg@jguk.org>.
2020-07-20 22:02:02 +02:00
Paul Eggert
9462c1202d factor: port to --without-libgmp
* src/factor.c (mp_factor_using_division): Use mpz_fdiv_q_2exp
instead of its no-longer-documented mpz_div_2exp alias.
(print_factors): Use mpz_out_str instead of gmp_printf.
2020-07-18 18:46:35 -07:00
Paul Eggert
6b6f0f54c0 build: be less aggressive about -fanalyzer
* configure.ac: Don’t enable -fanalyzer unless configured with the
new --enable-gcc-warnings=expensive option.  See thread at:
https://lists.gnu.org/r/coreutils/2020-07/msg00011.html
2020-07-10 17:38:31 -07:00
Paul Eggert
55d985064c factor: explain why non-GMP code (Bug#42269)
* doc/coreutils.texi (factor invocation):
* src/factor.c: Explain why the two-word algorithm is useful.
2020-07-08 18:59:41 -07:00
Paul Eggert
67fc55d636 doc: mention expr and factor bignums
* NEWS:
* doc/coreutils.texi (expr invocation, factor invocation):
Mention bignum support on all platforms.  Modernize timings.
2020-07-08 08:11:57 -07:00
Paul Eggert
95955e6746 factor: treat ' +bignum' like non-bignum
* src/factor.c (strto2uintmax): Instead of here ...
(print_factors): ... skip spaces and '+' here, so that
bignums are treated like non-bignums.
* tests/misc/factor.pl (bug-gmp-plus_2_sup_128_plus_1): New test.
2020-07-08 08:11:57 -07:00
Paul Eggert
af941bc523 tests: simplify since expr now works on bignums
* cfg.mk (sc_prohibit_expr_unsigned): Remove.
* tests/dd/skip-seek-past-dev.sh (DEV_OFLOW):
* tests/id/setgid.sh (gp1):
* tests/misc/cut-huge-range.sh (CUT_MAX):
* tests/misc/expr.pl:
* tests/misc/sort-discrim.sh:
Assume expr works on bignums.
* tests/misc/cut-huge-range.sh (subtract_one):
Remove; no longer needed.
2020-07-08 08:11:57 -07:00
Paul Eggert
712855a77d factor: simplify tests by assuming libgmp
* tests/misc/factor.pl: Test bignums even if !HAVE_GMP.
2020-07-08 08:11:57 -07:00
Paul Eggert
1304644488 maint: use Gnulib libgmp module
This lets use assume multiple-precision arithmetic on all
platforms, simplifying the code.
* bootstrap.conf (gnulib_modules): Add libgmp.
* configure.ac: Don’t call cu_GMP, as this is now done by Gnulib.
* m4/gmp.m4: Remove.
* src/expr.c, src/factor.c: Use gmp.h unconditionally.
* src/factor.c: Use the simpler ‘#ifndef mpz_inits’ to
determine whether there is an mpz_inits macro.
2020-07-07 14:48:21 -07:00
Paul Eggert
4c8495cf11 build: update gnulib submodule to latest 2020-07-07 14:48:21 -07:00
Bernhard Voelker
b1c6ef230c doc: add timeout examples
* doc/coreutils.texi (timeout invocation): Add examples.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-06/msg00018.html
2020-07-04 00:19:31 +02:00
Andreas Schwab
6a3d2883fe tests: avoid spurious testsuite failure
* tests/dd/stats.sh: Increase timeout.
Fixes https://bugs.gnu.org/42135
2020-06-30 13:44:34 +01:00
Pádraig Brady
947c553ff9 tests: fix false failure with valgrind and reflink
* tests/cp/fiemap-FMR.sh: Avoid FICLONE ioctl,
which would avoid the point of the test (fiemap testing).
Also it avoids a valgrind bug with this ioctl:
https://bugs.kde.org/show_bug.cgi?id=397605
2020-06-26 19:57:09 +01:00
Paul Eggert
4b04a0c3b7 cp: use copy_file_range if available
* NEWS: Mention this.
* bootstrap.conf (gnulib_modules): Add copy-file-range.
* src/copy.c (sparse_copy): Try copy_file_range if not
looking for holes.
2020-06-25 18:53:43 -07:00
Paul Eggert
a6eaee501f cp: use SEEK_DATA/SEEK_HOLE if available
If it works, prefer lseek with SEEK_DATA and SEEK_HOLE to FIEMAP,
as lseek is simpler and more portable (will be in next POSIX).
Problem reported in 2011 by Jeff Liu (Bug#8061).
* NEWS: Mention this.
* src/copy.c (lseek_copy) [SEEK_HOLE]: New function.
(enum scantype): New constants ERROR_SCANTYPE, LSEEK_SCANTYPE.
(union scan_inference): New type.
(infer_scantype): Last arg is now union scan_inference *,
not struct extent_scan *.  All callers changed.
Prefer SEEK_HOLE to FIEMAP if both work, since
SEEK_HOLE is simpler and more portable.
(copy_reg): Do the fdadvise after initial scan, in case the scan
fails.  Report an error if the initial scan fails.
(copy_reg) [SEEK_HOLE]: Use lseek_copy if scantype says so.
2020-06-25 18:53:43 -07:00
Paul Eggert
2fcd0f3328 cp: avoid copy_reg goto
* src/copy.c (copy_reg): Redo to avoid label and goto.
2020-06-25 18:53:43 -07:00
Paul Eggert
761ba28400 cp: refactor extent_copy
* src/copy.c (extent_copy): New arg SCAN, replacing
REQUIRE_NORMAL_COPY.  All callers changed.
(enum scantype): New type.
(infer_scantype): Rename from is_probably_sparse and return
the new type.  Add args FD and SCAN.  All callers changed.
2020-06-25 18:53:43 -07:00
Paul Eggert
d80820b3b5 maint: typo fix
* NEWS: Fix typo.
2020-06-25 18:53:42 -07:00
Paul Eggert
eac715a412 chmod: man page fixes
* man/chmod.x: Mention -6000 too.  Use .BR to fix trailing period.
2020-06-23 08:41:40 -07:00
Pádraig Brady
6de819a2e3 doc: fix punctuation in man pages
* man/chmod.x: Add missing punctuation.
* src/expand-common.c: Likewise.
* src/numfmt.c: Likewise.
* src/rm.c: Likewise.

Fixes https://bugs.gnu.org/41962
2020-06-21 22:43:20 +01:00
Bernhard Voelker
f5644c986c stat,tail: add support for the VBOXSF file system
* src/stat.c (human_fstype): Add case for the 'vboxsf' file system type
which is used for VirtualBox Shared Folders mounted in VirtualBox guest
VMs.
* NEWS: Mention the Improvement.
Fixes https://bugs.gnu.org/41935
2020-06-20 16:07:19 +02:00
Paul Eggert
25725f9d41 cp: default to COW
Likewise for ‘install’.  Proposed in Bug#24400, and long past due.
* NEWS:
* doc/coreutils.texi (cp invocation):
* src/copy.h (enum Reflink_type): Document this.
* src/cp.c (cp_option_init):
* src/install.c (cp_option_init): Implement this.
2020-06-18 22:38:06 -07:00
Tobias Stoeckmann
0fe9fdece7 maint: avoid signed integer overflows
Since -LONG_MIN results in LONG_MIN again, the operation itself is
a signed integer overflow.

This can be observed with the following calls (best if compiled
with -ftrapv or -fsanitize=undefined):

  $ numfmt --padding=-9223372036854775808
  $ seq 1e-9223372036854775808

Technically, the change in seq "reduces" the precision, but a double
or long double that small would be represented as 0 anyway.

* src/numfmt.c: Explicitly disallow --padding=LONG_MIN.
* src/seq.c: Treat 1e$LONG_MIN as 1e-$LONG_MAX.
* tests/misc/numfmt.pl: Add a test case.
* tests/misc/seq-precision.sh: Likewise.

Fixes https://bugs.gnu.org/41850
2020-06-15 23:07:03 +01:00
Bernhard Voelker
189776ff3b doc: timeout: improve documentation of the exit status
* doc/coreutils.texi (timeout invocation): Document that the exit
status is 137 when the KILL signal is used, regardless of whether that
signal is sent to COMMAND or timeout.
* src/timeout.c (usage): Likewise. Also split out and expand
on the possible exit status values to a separate table.

Discussed at https://bugs.gnu.org/41634
2020-06-07 15:41:48 +02:00
Paul Eggert
b4ab357e42 maint: use getrandom, not getentropy
This makes for one Gnulib module less, and at runtime there’s
typically just one getrandom syscall instead of several for large
nonces.
* gl/lib/randread.c: Include sys/random.h instead of sys/time.h
and unistd.h.
(get_nonce): Use getrandom, not getentropy.
* gl/modules/randread (Depends-on):
Depend on getrandom, not getentropy.
* src/shred.c (main):
* src/shuf.c (main):
* src/sort.c (random_md5_state_init):
Say "getrandom" rather than "getentropy" in (unlikely) diagnostic.
2020-06-01 15:54:50 -07:00
Paul Eggert
b3ff4113fd maint: use getentropy and new tempname modules
Update gnulib submodule to latest and use its new features.
Gnulib’s new getentropy module means coreutils can now assume
getentropy instead of approximating it, badly in some cases.
Gnulib’s improvements to the tempname module mean coreutils no
longer needs to maintain private patches.
* bootstrap.conf (gnulib_modules): Remove gettimeofday.
* gl/lib/randread.c (NAME_OF_NONCE_DEVICE): Remove.
(get_nonce): Return success indicator.  Remove bytes_bound arg.
All callers changed.  Rewrite by using getentropy instead of
reading the nonce device and falling back on gettimeofday.
Fail if getentropy fails.
(randread_new): Return NULL (setting errno) if get_nonce fails.
All callers changed.
* gl/lib/tempname.c.diff, gl/lib/tempname.h.diff:
* gl/modules/tempname.diff: Remove.
* gl/modules/randread (Depends-on):
Depend on getentropy, not gettimeofday.
* src/ptx.c (swallow_file_in_memory):
* src/shuf.c (read_input):
Adjust to read_file changes in Gnulib.
* src/shred.c (main):
* src/shuf.c (main):
* src/sort.c (random_md5_state_init):
Diagnose the new form of randread_new failures: randread_new can
fail now when !random_source, meaning getentropy failed.
2020-05-31 22:39:48 -07:00
Paul Eggert
c229285ceb echo: pacify Oracle Studio 12.6
* src/echo.c (main): Don’t assign pointer to bool.
This is well-defined in C99, but is arguably bad style
and Oracle Studio 12.6 complains.
2020-05-31 22:39:48 -07:00
Bernhard Voelker
aefd434e56 maint: copy FDL from gnulib instead of using it as module
Since the previous gnulib update, bootstrap outputs this warning:

  Notice from module fdl:
    Don't use this module! Instead, copy the referenced license file \
    into your version control repository.

See gnulib commit:
  https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=88fc5afbccc9

* bootstrap.conf (gnulib_modules): Remove 'fdl'.
* doc/fdl.texi: Add file as a copy of 'gnulib/doc/fdl.texi'.
* doc/.gitignore (/fdl.texi): Remove entry.
* cfg.mk (FILTER_LONG_LINES): Add pattern for the 'fdl.texi' file.
2020-05-25 16:31:08 +02:00
Bernhard Voelker
46e0ce5e5d maint: fix syntax-check failure from recent adjustment
* cfg.mk (old_NEWS_hash): Regenerate after commit v8.32-15-g6d0107a37
2020-05-23 03:53:59 +02:00
Bernhard Voelker
9dbaf54eed tests: fix removed-directory test
The previous attempt to skip that test on NFS (commit 4181fc5183)
made the test fail; it introduced two problems:
a) In the good case, i.e., when the subshell returns with exit status 0,
the test ran into framework_failure_.
b) As the subshell also runs with 'set -x', the later comparison of
/dev/null with 'err' would fail.

* tests/ls/removed-directory.sh: Revert to the style without subshell,
and add 'test -d .' to verify that 'ls' can read the removed dir.
2020-05-23 03:42:24 +02:00
Paul Eggert
6d0107a37f date: document +%-N change
Suggested by Kamil Dudka in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00205.html
* NEWS: Mention the change for coreutils 8.23.
* doc/coreutils.texi (Padding and other flags):
Document it.
2020-05-20 17:32:53 -07:00
Paul Eggert
4181fc5183 ls: port removed-directory test to NFS
* tests/ls/removed-directory.sh:
Port test to NFS, where one gets a stale file handle
when looking at a removed directory.
2020-05-20 17:32:53 -07:00
Paul Eggert
dc7aac9c7e dd: omit unnecessary vars when !lint
* src/dd.c (real_ibuf, real_obuf) [!lint]:
Remove, as they're needed only when lint checking.
All uses removed when 'lint' is not defined.
2020-05-20 17:32:53 -07:00
Paul Eggert
e18efcfd04 maint: omit unnecessary pragmas and fix tsort.c
* src/chown-core.c, src/comm.c:
* src/tsort.c (record_relation):
Remove GCC 10 pragmas that are not needed in GCC 10.1.0 (the first
public GCC 10 release) and that in some cases cause diagnostics
with GCC 10.1.0.  The tsort.c change fixes a bug that was
inadvertantly introduced when these pragmas were added.
2020-05-20 17:32:52 -07:00
Paul Eggert
1bbb0827db build: update gnulib submodule to latest 2020-05-20 17:32:52 -07:00
Pádraig Brady
c7194b43fc maint: avoid warnings from GCC's -fanalyzer
* src/env.c (build_argv): Add an assert() to avoid:
  warning: use of NULL 'n' where non-null expected
  [CWE-690] [-Wanalyzer-null-argument]
  note: argument 1 of 'getenv' must be non-null
* src/dd.c (alloc_ibuf): Don't discard the allocated pointer, to avoid:
  [CWE-401] [-Wanalyzer-malloc-leak]
(alloc_obuf): Likewise.
(cleanup): Deallocate the now tracked buffers which
also avoids "possibly lost" warnings from valgrind.
* src/tsort.c (search_item): Add asserts to avoid:
  [CWE-690] [-Wanalyzer-null-dereference]
(record_relation): An assert doesn't suffice here,
so disable the warning for this function.
* src/comm.c: Suppress the following false positive for the whole file:
  [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
* src/chown-core.c: Suppress the following false positive for the file:
  [CWE-415] [-Wanalyzer-double-free]
2020-05-11 21:18:47 +01:00
Jason Kim
9c8a385aa4 ls: allow --classify to be ignored for non tty output
Have the `ls` `--classify` option take an optional argument for when to
classify ("always", "auto", "never"), just like the optional argument
for `--color`.  When the optional argument is not specified, default to
"always" for backwards compatibility.

* src/ls.c (usage): Update help text.
(decode_switches): Support an optional argument for --classify.
* tests/ls/classify.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2020-04-27 13:48:32 +01:00
Bernhard Voelker
f38bd362d9 build: update gnulib to latest - to avoid du(1) crash on XFS
Pull in a fix for FTS to avoid a crash when traversing a heavily
changed XFS file system:

> fts: remove NOSTAT_LEAF_OPTIMIZATION

* NEWS (Bug fixes): Mention the fix.
* gnulib: Update to latest.
* bootstrap: Sync from gnulib/build-aux/bootstrap.

Discussed at:
<https://lists.gnu.org/r/bug-gnulib/2020-04/msg00068.html>
2020-04-22 19:45:36 +02:00
Pádraig Brady
730876d067 maint: clean up recently added test
* tests/misc/uniq-collate.sh: Remove logic that
was already refactored into gen_input().
2020-04-02 16:10:05 +01:00
Pádraig Brady
7b5f0fa47c cp: ensure --attributes-only doesn't remove files
* src/copy.c (copy_internal): Ensure we don't unlink the destination
unless explicitly requested.
* tests/cp/attr-existing.sh: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/40352
2020-04-02 15:44:55 +01:00
Paul Eggert
271b217045 build: update gnulib submodule to latest
* src/selinux.c: Do not include dosname.h; not needed, since
system.h does that for us via dirname.h.
2020-03-28 13:05:32 -07:00
Bernhard Voelker
9b4bb9d28a maint: add texi2dvi build directory to doc/.gitignore
* doc/.gitignore (/coreutils.t2p/): Add entry for the build directory
left behind after 'make pdf'.
While at it, sort the file.
2020-03-15 11:20:41 +01:00
Paul Eggert
672819c73f ls: improve removed-directory test
* tests/ls/removed-directory.sh: Remove host_triplet test.
Skip this test if one cannot remove the working directory.
From a suggestion by Bernhard Voelker (Bug#39929).
2020-03-07 10:30:56 -08:00
Paul Eggert
10fcb97bd7 ls: restore 8.31 behavior on removed directories
* NEWS: Mention this.
* src/ls.c: Do not include <sys/sycall.h>
(print_dir): Don't worry about whether the directory is removed.
* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
behavior.
2020-03-07 10:19:57 -08:00
Pádraig Brady
da589f1d63 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-03-05 14:04:42 +00:00
Pádraig Brady
8d13292a73 version 8.32
* NEWS: Record release date.
2020-03-05 13:23:50 +00:00
Pádraig Brady
c8539d36c7 tests: don't rely on system env(1) being present
* tests/misc/env-S.pl: `env -i env` will call the system env
due to the path being cleared, so pass the absolute path
of our env binary under test to avoid that.  This was seen
to be an issue on Guix where /usr/bin/env was not available.
2020-03-04 18:00:38 +00:00
Pádraig Brady
0ea65e29dc basenc: avoid undefined behaviour in z85 processing
* src/basenc.c (z85_decode_ctx_init): Ensure we're working
with unsigned, as otherwise ubsan triggers with:
  src/basenc.c:767:18: runtime error: signed integer overflow:
  43 * 52200625 cannot be represented in type 'int'
(z85_encode): Likewise to avoid the usban error:
  src/basenc.c:630:26: runtime error:
  left shift of 134 by 24 places cannot be represented in type 'int'
2020-03-04 12:38:27 +00:00
Pádraig Brady
f2034aa9bb tests: avoid a false failure on OpenIndiana 11
* tests/misc/timeout-parameters.sh: Split the large timeout
handling to ...
* tests/misc/timeout-large-parameters.sh: ... here, so that
the 3 second delay is contained in its own test, and if
the test is skipped due invalid handling within timeout(1),
it will be more apparent.
Also adjust the check so we skip whenever the kernel timer
fires immediately, to handle the buggy OpenIndiana 11 kernel also.
Reported by Bruno Haible.
2020-03-01 23:36:05 +00:00
Pádraig Brady
ab305f746e tests: avoid a hang on GNU/Hurd from 2019
* tests/du/8gb.sh: Add a timeout around:
`dd bs=1 seek=8G of=big < /dev/null`
2020-03-01 22:04:20 +00:00
Pádraig Brady
04e2b9b1a6 tests: use bash in some scripts to avoid false failures
* init.cfg (require_bash_as_SHELL_): A new function to replace
SHELL for the current test, with bash if available.
This is useful on OpenIndiana 11 where /bin/sh was seen
to have races in handling of SIGPIPE.
* tests/misc/seq-epipe.sh: Use the new function to enforce bash.
* tests/misc/env-signal-handler.sh: Likewise.
Reported by Bruno Haible
2020-03-01 22:02:39 +00:00
Pádraig Brady
5cdab9f26b tests: improve test coverage for ls stat checks
* tests/ls/stat-free-color.sh: Check for the availability
of various stat calls individually, and add statx() and fstatat64()
to the list to check.  Fix the stat counting logic to
ignore lines like "+++ exited with 0 +++".
* tests/ls/stat-free-symlinks.sh: Check syscalls other than stat().
2020-03-01 13:06:01 +00:00
Bruno Haible
e840c78685 tests: enable 4 more tests to be executed on FreeBSD
* init.cfg (gcc_shared_libs_): New variable.
(gcc_shared_): Use it, instead of hardcoding -ldl.
(require_gcc_shared_): Determine the suitable value
for gcc_shared_libs_.
2020-03-01 10:56:12 +00:00
Pádraig Brady
ea1c1b7515 tests: fix incorrect || fail pattern in tests
* tests/ls/stat-free-symlinks.sh: s/|| fail/|| fail=1/.
* tests/misc/tee.sh: Likewise.
* tests/touch/relative.sh: Likewise.
* cfg.mk (sc_prohibit_or_fail): A new syntax-check to avoid this.
2020-02-29 22:45:00 +00:00
Pádraig Brady
de73a867ca tests: avoid false failures on darwin 19.2.0
With these adjustments, all tests pass on macOS Catalina.

* tests/dd/sparse.sh: Adjust so that systems like apfs that
don't create holes < 16 MiB do not fail erroneously.
* tests/touch/trailing-slash.sh: Darwin was seen to dereference
symlinks to files when given a trailing slash, so avoid
that particular case.
2020-02-29 22:45:00 +00:00
Bruno Haible
54bf2c2f1a tests: fix test failure on FreeBSD 12
* tests/misc/csplit-io-err.sh: Limit the effect of the fwrite
override to streams != stderr, as fwrite is in the error() path there.
2020-02-29 22:39:47 +00:00
Jan Nieuwenhuizen
516cdf38af build: once again distribute .tar.gz files
* configure.ac: Reenable distribution of gzip-compressed
tarballs, for Guix bootstrapping reasons as discussed at:
https://lists.gnu.org/r/coreutils/2020-02/msg00042.html
* THANKS.in: Remove me, as now a committer.
* NEWS (Build-related): Mention this.
2020-02-27 21:55:57 +00:00
Pádraig Brady
cc4c55e4bc maint: ensure .deps/ in the project root is ignored by git
* .gitignore: s|*/.deps/|.deps|
2020-02-27 16:44:03 +00:00
Pádraig Brady
8de80feb51 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.23 which is now about 5 years old.
2020-02-27 16:11:42 +00:00
Colin Watson
05a99f7d7f ls: issue error message on removed directory
If the current directory has been removed, then "ls" confusingly
produced no output and no error message, indistinguishable from
running on an empty directory.

* src/ls.c (print_dir): Report ENOENT on GNU/Linux if readdir
finds no directory entries at all, not even "." or "..",
and a recheck with the getdents syscall returns ENOENT.
We recheck with getdents() as POSIX states that
"The directory entries for dot and dot-dot are optional".
* tests/ls/removed-directory.sh: New file.
* tests/local.mk (all_tests): Add new test.
* NEWS: Mention the change in behavior.
Reported by Owen Thomas.
2020-02-27 14:11:37 +00:00
Pádraig Brady
93db70867d build: update to latest gnulib
* bootstrap.conf: Adjust for changes to fchmodat and fchownat,
which are now separated from chmodat and chownat respectively.
2020-02-25 14:26:39 +00:00
Pádraig Brady
ead8464e3a b2sum: sync better with upstream
* src/blake2/blake2-impl.h: Sync load16() implementation,
which doesn't change code generation.
Also leverage (builtin) memcpy to more efficiently
move data on little endian systems,
giving a 2% win with GCC 9.2.1 on an i3-2310M.
2020-02-25 13:51:21 +00:00
Pádraig Brady
9134993562 factor: sync longlong.h adjustments from upstream
* src/longlong.h: Sync changes from:
https://gmplib.org/repo/gmp/log/tip/longlong.h
mips64: Provide r6 asm code as default expression yields.
arm32: Define sub_ddmmss separately for non-thumb (no rsc instruction).
powerpc: Add "CLOBBER" descriptions for some registers.
x86: Fix criterion for when to use mulx in umul_ppmm.
2020-02-25 11:55:38 +00:00
Pádraig Brady
75f79010cd stat,tail: sync file system constants from the linux kernel
* src/stat.c: Add magic constants for "binderfs", "dma-buf-fs",
"erofs", "ppc-cmm-fs", and "z3fold".
* NEWS: Mention the improvement.
2020-02-25 00:03:40 +00:00
Pádraig Brady
8e81d44b52 uniq: avoid strcoll() to improve performance and consistency
strcoll() is only significant to uniq(1) if it returns 0,
and it generally only does so with buggy locales or mismatched
locales and data.  Some systems may have strcoll()
return 0 for equivalent normalized unicode forms,
but for consistency across platforms strcoll() is avoided.
The various cases are defined in the new test.
This is consistent with newer POSIX standards as discussed at:
https://www.austingroupbugs.net/view.php?id=963

* src/uniq.c: s/xstrcoll/memcmp/.
* tests/local.mk: Reference the new test.
* tests/misc/uniq-collate.sh: Add a new test.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/38627
2020-02-24 10:12:42 +00:00
Pádraig Brady
61c49d3693 doc: clarify that '%a' stat format outputs mode bits
* src/stat.c (usage): Mention permission bits rather than
"access" so there is no confusion with ACLs etc.
Also indicate we output the file type with '%A'.
* doc/coreutils.texi (stat invocation): Likewise.
Also indicate '%A' is similar to `ls -ld` output.
Addresses https://bugs.gnu.org/39613
2020-02-15 11:24:15 +00:00
Pádraig Brady
3150f4a82e tests: fix test for symlink
* tests/cp/preserve-gid.sh: s/-l/-L/.
Reported by Kamil Dudka
2020-02-10 15:06:21 +00:00
Kamil Dudka
b96b1a4728 tests: ensure tests/cp/preserve-gid.sh works with single binary
* tests/cp/preserve-gid.sh: If configured with --enable-single-binary
copy the coreutils single binary, instead of the cp one-line launcher.

Discussed at https://bugzilla.redhat.com/1800597
Fixes https://bugs.gnu.org/39485
2020-02-09 14:19:35 +00:00
Pádraig Brady
304bc557af maint: avoid syntax-check failure in previous commit
* configure.ac: Restrict lines to 80 chars.
2020-02-09 14:19:35 +00:00
Jim Meyering
d7da53c47e build: suppress new FP warning from gcc-10.0.1
* configure.ac (GNULIB_WARN_CFLAGS): Add -Wno-return-local-addr
to avoid FP warning about careadlinkat.c. Discussed starting in
https://lists.gnu.org/r/coreutils/2020-02/msg00006.html
2020-02-08 17:52:48 -08:00
Pádraig Brady
fa6d154b7b build: update to latest gnulib
Pick up recent build fixes to avoid sysctl.h inclusion on glibc systems,
restrict the max file size supported by read-file to PTRDIFF_MAX,
and to avoid a -Werror=unused failure in test-canonicalize.
2020-02-04 19:12:33 +00:00
Pádraig Brady
ab108667ba tests: avoid false failure due to varying /proc/kallsyms
* tests/cp/proc-short-read.sh: Switch to using /proc/cpuinfo,
rather than /proc/kallsyms which was seen to vary in some cases.
Fixes https://bugs.gnu.org/39357
2020-02-04 19:11:37 +00:00
Pádraig Brady
1f443fe572 rmdir: fix --ignore-fail-on-non-empty with permissions errors
Since v6.10-21-ged5c4e7 `rmdir --ignore-fail-on-non-empty`
had reversed the failure status for directories that failed
to be removed for permissions reasons.  I.E. it would have
returned a failure status for such non empty dirs, and vice versa.

* src/rmdir.c (errno_may_be_non_empty): Rename from the
more confusing errno_may_be_empty(), and remove the EEXIST
case (specific to Solaris), which is moot here since
handled in errno_rmdir_non_empty().
(ignorable_failure): Fix the logic error so that
_non_ empty dirs are deemed to have ignorable failures.
(main): Fix clobbering of errno by is_empty_dir().
(remove_parents): Likewise.
* tests/rmdir/ignore.sh: Add a test case.
* THANKS.in: Add reporter who fixed the errno handling.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/39364
2020-02-04 19:11:37 +00:00
Pádraig Brady
709b4d9d8d build: avoid vector performance warnings in randperm
* configure.ac: Add -Wno-vector-operation-performance to suppress the
following gcc-9.2 error in gl/lib/randperm.c:
  error: vector operation will be expanded piecewise
2020-02-03 19:38:02 +00:00
Pádraig Brady
18c9382801 build: avoid including sysctl.h on glibc
* src/uname.c: Avoid unneeded header with GLIBC,
which has been deprecated since glibc-2.30.
* src/uptime.c: Likewise.
2020-02-03 19:38:02 +00:00
Pádraig Brady
2cecc3cc99 ls: support --time=creation to show/sort birth time
* src/ls.c (usage): Reorganize help for --time,
and add description for --time=birth.
(do_statx): Store btime in mtime if available.
(get_stat_btime): A new function to read the creation time
from the appropriate stat structure member.
(cmp_btime): A new function to compare birth time.
(print_long_format): Output '?' when birth time unavailable.
* doc/coreutils.texi: Document --time={birth,creation}.
* tests/local.mk: Reference the new test.
* tests/ls/birthtime.sh: Add a new test.
* NEWS: Mention the new feature.
2020-02-03 19:37:56 +00:00
Chris Meyering
dda53d75a8 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
2020-01-30 18:38:18 +00:00
Emil Engler
fbbf81ec00 maint: add lib/iconv_open-zos.h to .gitignore
* .gitignore: Add file newly generated by gnulib commit 49e78fc
2020-01-01 23:59:40 +00:00
Pádraig Brady
0d77e1b7ea 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.
2020-01-01 22:14:45 +00:00
Pádraig Brady
ff2f85273a maint: adjust to split out xstrtol-error gnulib module
* bootstrap.conf: Depend on the new module split from xstrtol.
* src/df.c: Include "xstrtol-error.h" for xstrtol_fatal.
* src/du.c: Likewise.
* src/ls.c: Likewise.
* src/od.c: Likewise.
* src/pr.c: Likewise.
* src/sort.c: Likewise.
2020-01-01 14:36:12 +00:00
Pádraig Brady
aaba82431c 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.
2020-01-01 14:16:56 +00:00
Bernhard Voelker
7490e94aa7 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
2019-12-08 17:44:37 +01:00
Pádraig Brady
ec5ab42604 maint: fix syntax-check failure from recent adjustment
* cfg.mk (old_NEWS_hash): Regenerate after commit v8.31-56-gc1e1965.
2019-12-02 16:21:08 +00:00
Kamil Dudka
5118a2e392 chcon: do not validate security context if SELinux is disabled
* src/chcon.c (main): Skip call of security_check_context()
in case SELinux is disabled to avoid unnecessary failure.

Bug: https://bugzilla.redhat.com/1777831
2019-12-02 16:21:05 +00:00
Paul Eggert
ad591a52b4 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.
2019-11-11 16:54:19 -08:00
Paul Eggert
0103fb0244 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.
2019-11-11 16:54:19 -08:00
Paul Eggert
04b136e298 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.
2019-10-22 15:04:43 -07:00
Paul Eggert
ed2db6886b stdbuf: improve size checking
* bootstrap.conf (gnulib_modules): Add minmax.
* src/libstdbuf.c: Include stdint.h, minmax.h.
(apply_mode): Don’t assume SIZE_MAX <= ULONG_MAX.
Improve checking for invalid sizes.
2019-10-22 15:04:43 -07:00
Paul Eggert
74163ea677 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.
2019-10-22 15:04:43 -07:00
Paul Eggert
565dd395c3 build: don’t worry about logical-op checking
* configure.ac: Remove code tailoring --enable-gcc-warnings
to GCC 4.7 and earlier, as developers no longer need to worry
about GCCs that old.
2019-10-22 15:04:43 -07:00
Paul Eggert
6716a79773 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.
2019-10-22 15:04:42 -07:00
Paul Eggert
c1e19656c8 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.
2019-10-21 13:20:35 -07:00
Jeff Layton
a99ab26611 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:

Baseline -- no activity on the second client:

WRITE: bw=76.7MiB/s (80.4MB/s), 76.7MiB/s-76.7MiB/s (80.4MB/s-80.4MB/s),
       io=4600MiB (4824MB), run=60016-60016msec

Without this patch series, we see a noticable performance hit:

WRITE: bw=70.4MiB/s (73.9MB/s), 70.4MiB/s-70.4MiB/s (73.9MB/s-73.9MB/s),
       io=4228MiB (4433MB), run=60012-60012msec

With this patch series, we gain most of that ground back:

WRITE: bw=75.9MiB/s (79.6MB/s), 75.9MiB/s-75.9MiB/s (79.6MB/s-79.6MB/s),
       io=4555MiB (4776MB), run=60019-60019msec

* 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.
2019-10-09 22:07:42 +01:00
Paul Eggert
86ee5548c1 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.
2019-10-03 12:41:51 -07:00
Paul Eggert
ba1ea8caee numfmt: avoid unlikely integer overflow
* src/numfmt.c (parse_format_string): Report overflow if
pad < -LONG_MAX, since that can’t be negated.
2019-10-03 12:41:51 -07:00
Paul Eggert
ac2b4a43e6 nl: fix integer-overflow bug
Problem reported by Roland Illig (Bug#37585)
* src/nl.c (print_lineno): Don’t rely on undefined behavior when
checking for integer overflow.
2019-10-03 12:41:51 -07:00
Paul Eggert
bb23a7563f cp: simplify integer overflow checking
* src/copy.c (sparse_copy): Use INT_ADD_WRAPV instead
of doing overflow checking by hand.
2019-10-03 12:41:51 -07:00
Pádraig Brady
1c8050cc4d 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
2019-09-08 18:59:24 +01:00
Pádraig Brady
49b1010cc0 maint: use consistent header ordering and spacing in NEWS
* NEWS: Move "Changes in behavior" before "New features",
and ensure there is only a single blank line between sections.
2019-09-08 18:59:21 +01:00
Paul Eggert
f2dfea7e99 build: update gnulib submodule to latest 2019-08-15 02:50:33 -07:00
Assaf Gordon
b8609c7cf2 scripts: document how to build older versions on newer systems
Based on https://lists.gnu.org/r/coreutils/2019-08/msg00011.html .

* scripts/build-older-versions/README.older-versions: Documentation
* scripts/build-older-versions/build-older-versions.sh: Helper script.
* scripts/build-older-versions/.gitignore: Ignore build directory.
* scripts/build-older-versions/coreutils-5.0-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-5.97-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.10-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.11-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.12-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-7.2-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.13-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.17-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.18-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.24-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.4-on-glibc-2.28.diff: Patches.
2019-08-15 01:15:20 -06:00
Bruno Haible
a3d070fa32 build: adjust for recent gnulib pthread changes
Discussed in https://lists.gnu.org/r/coreutils/2019-08/msg00030.html .

* bootstrap.conf (gnulib_modules): Replace 'pthread' with
pthread-* modules.
* src/sort.c: Remove GNULIB_defined_pthread_functions conditional.
2019-08-12 15:10:46 -06:00
Assaf Gordon
725c8d6bed date: mention military timezone changes from gnulib
Gnulib commits f1f10d47be8762e4ca17c8957a0520b08d28abfb and
0673d8ab42c9bb0cf618a21b537cdd8fb976fb73 negated the meaning of
military timezones parsed in gnu date.
See https://lists.gnu.org/r/bug-gnulib/2019-08/msg00005.html and
https://lists.gnu.org/r/coreutils/2019-08/msg00021.html

* NEWS: Mention this user-visible change.
* tests/misc/date.pl: Add tests for the new behavior.
2019-08-10 21:14:20 -06:00
Bernhard Voelker
3cbddd58fd maint: add lib/argmatch.h to po/POTFILES.in
* po/POTFILES.in (lib/argmatch.h): Add to avoid sc_po_check error:
    "maint.mk: you have changed the set of files with translatable \
     diagnostics;"
2019-08-10 21:07:59 -06:00
Assaf Gordon
961d668eea gnulib: update to latest 2019-08-10 21:07:59 -06:00
Pádraig Brady
becf0db0da doc: clarify that truncate creates sparse files
* src/truncate.c (usage): Explicitly mention "sparse".
* doc/coreutils.texi (truncate invocation): Likewise.
Addresses https://bugs.gnu.org/36963
2019-08-08 13:34:54 +01:00
Mike Swanson
eb5a9ebaf1 dircolors: recognize the WebP image format
* src/dircolors.hin: Add .webp for the WebP image format.
Fixes https://bugs.gnu.org/36899
2019-08-07 07:17:27 +02:00
Bernhard Voelker
a574029110 maint: fix error in syntax-check checking
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'.
2019-08-06 16:11:01 -07:00
Akim Demaille
0e2d4e1425 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.
2019-08-04 11:11:16 -07:00
Assaf Gordon
07f811a3c0 seq: fix superfluous output line
Under certain circumstances seq prints an extra line when the output
format has custom format with characters following the printed numbers:

    $ seq -f "%g " 1000000 1000000
     1e+06
     1e+06

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.
2019-08-02 18:29:25 -06:00
Bernhard Voelker
c0f2219d3a 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/
2019-07-22 08:52:52 +02:00
Assaf Gordon
3264d4ca0d 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.
2019-07-15 13:28:20 -06:00
Andreas Dilger
a1a5e9a32e 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.
2019-07-12 19:51:09 +01:00
Paul Eggert
3ae38a5995 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.
2019-06-19 18:48:54 -07:00
Paul Eggert
a3a454b9d9 doc: mention ls -l user/group justification
* doc/coreutils.texi (What information is listed):
Document justification of user and group columns in ls -l output
(Bug#36220).
2019-06-18 00:32:25 -07:00
Jeff Layton
0b9bac90d8 stat: fix enabling of statx logic
* src/stat.c: STATX_INO isn't defined until stat.h is included.
Move the test down so it works properly.
2019-06-14 22:43:46 +01:00
Assaf Gordon
0251229bfd 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.
2019-06-12 21:14:34 -06:00
Jeff Layton
6cc35de16f 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.
2019-06-10 22:59:28 +01:00
Pádraig Brady
bb481a0c1d doc: fix description of tail -f on truncated files
* doc/coreutils.texi (tail invocation): Update to match
the new behavior following commit v8.23-189-gb28ff6a
2019-06-09 12:42:15 +01:00
Pádraig Brady
738a746d82 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
2019-06-08 22:58:01 +01:00
Paul Eggert
00d72e6122 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.
2019-05-30 13:54:18 -07:00
Paul Eggert
4c223ab4b6 maint: fix version number in NEWS 2019-05-29 16:45:16 -07:00
Paul Eggert
3b1046f80f 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.
2019-05-28 13:44:40 -07:00
Kevin Locke
3a87ad5124 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.

[1]: https://superuser.com/a/1136358
2019-05-26 12:53:26 +01:00
Martin Castillo
4f38974aaf doc: fix typo in sort set operations example
* doc/coreutils.texi (sort invocation): Add a missing -u
option to uniq.
Addresses https://bugs.gnu.org/35849
2019-05-22 14:44:56 +01:00
Paul Eggert
a60af87f24 b2sum: port blake2b-ref.c to HP-UX aCC
Continue the fix for Bug#35650.
* src/blake2/blake2b-ref.c [HAVE_CONFIG_H]: Include <config.h>.
2019-05-17 07:58:32 -07:00
Paul Eggert
de54e1a809 b2sum: sync better with upstream
* src/blake2/b2sum.c: Reorder source code to minimize diffs from:
https://github.com/BLAKE2/BLAKE2/blob/master/b2sum/b2sum.c
2019-05-15 12:58:13 -07:00
Paul Eggert
5f261e239f 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.
2019-05-15 12:42:58 -07:00
Paul Eggert
5b96efab90 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.
2019-05-14 09:21:33 -07:00
Paul Eggert
6e97d361b4 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.
2019-05-11 13:55:54 -07:00
Paul Eggert
6f4c2e06ae cp: port fiemap.h to C99
* src/extent-scan.c (extent_scan_read): Adjust to change in
struct fiemap.
* src/fiemap.h (struct fiemap): Use FLEXIBLE_ARRAY_MEMBER
to port to C99.
2019-05-11 13:55:54 -07:00
Paul Eggert
2fd0be3621 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.
2019-05-11 13:55:54 -07:00
Paul Eggert
a970a97737 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.
2019-05-11 13:55:54 -07:00
Paul Eggert
39073add8f build: update gnulib submodule to latest 2019-05-11 13:55:54 -07:00
Bernhard Voelker
7d8adb20f6 gnulib: update to the latest
* gnulib: Update to latest, mainly for:
  > mountlist: make parsing /proc/self/mountinfo more robust
* NEWS: Mention the fix.

Fixes https://bugs.gnu.org/33468
2019-04-19 10:21:43 +02:00
Shugo Maeda
6d78a28078 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
2019-03-31 15:49:48 -07:00
Pádraig Brady
ebf70f297c maint: fix syntax check failure
* src/ln.c: Remove leading TAB.
2019-03-30 15:07:14 -07:00
Martin Castillo
ba36d5118f maint: tee: use STDIN_FILENO rather than 0
* src/tee.c (tee_files): Use the name rather than the value.
Addresses https://bugs.gnu.org/35041
2019-03-30 15:04:42 -07:00
Paul Eggert
59e01d13e6 dd: improve doc of stderr output
* doc/coreutils.texi (dd invocation):
Document stderr output more carefully.
Say that conv=block can lose input data.
2019-03-19 20:09:02 -07:00
Kamil Dudka
ae61b10663 md5sum,b2sum,sha*sum: --help: add note about binary/text mode
* src/md5sum.c (usage): Make it clear that there is no difference
between binary mode and text mode on GNU systems.

Bug: https://bugzilla.redhat.com/406981
Bug: https://bugzilla.redhat.com/1688740
2019-03-18 08:48:57 +01:00
Paul Eggert
1a69508711 doc: add NEWS item for Solaris symlink fix 2019-03-17 13:25:10 -07:00
Paul Eggert
3e0dff3925 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.
2019-03-17 13:22:32 -07:00
Pádraig Brady
4a21102470 doc: add a NEWS entry for the ln O_DIRECTORY fix
* NEWS: Mention the bugfix.
2019-03-16 14:21:40 -07:00
Paul Eggert
6a707feee8 ln: port to platforms lacking O_DIRECTORY
* src/ln.c (main): Port to older platforms lacking
support for POSIX.1-2008’s O_DIRECTORY flag (Bug#34876).
2019-03-16 11:24:58 -07:00
Kamil Dudka
6bd78f27fd doc: improve wording of the --kibibytes option description
Bug: https://bugzilla.redhat.com/1527391 , https://bugs.gnu.org/33646

* doc/coreutils.texi (General output formatting): Improve wording of
'--kibibytes' option.
2019-03-15 12:26:02 -06:00
Bernhard Voelker
5b9d747261 maint: sync extra files from gnulib
Some files are physically copied from gnulib, and should get sync'ed
after each update to latest gnulib.  This was forgotten during recent
updates.

* COPYING: Merge from gnulib/doc/COPYINGv3.
* tests/init.sh: Merge from gnulib/tests/init.sh.
2019-03-11 11:39:29 +01:00
Pádraig Brady
ab8c604765 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-03-10 17:08:36 -07:00
Pádraig Brady
cf28242fd5 version 8.31
* NEWS: Record release date.
2019-03-10 16:34:41 -07:00
Pádraig Brady
5f47cda3ab 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.
2019-03-10 15:05:26 -07:00
Pádraig Brady
a971cd4ff7 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()
2019-03-09 20:59:21 -08:00
Pádraig Brady
66e2daa689 tests: tail-2/pipe-f: avoid false failure closing stdout
* tests/tail-2/pipe-f.sh: Check closing stdout with >&-
is effective, which avoids a false failure on NetBSD 7.1
Reported by Assaf Gordon
2019-03-06 22:26:30 -08:00
Pádraig Brady
a376de95c3 tests: tac-2-nonseekable: ensure we don't block indefinitely
* tests/misc/tac-2-nonseekable.sh: Add a timeout to both
protect and check whether we can close stdin correctly.
2019-03-06 22:00:53 -08:00
Pádraig Brady
daa46dbe7d 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.
2019-03-06 22:00:53 -08:00
Pádraig Brady
b918a20234 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`.
2019-03-06 22:00:53 -08:00
Assaf Gordon
bf2f64c7d5 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.
2019-03-06 21:59:27 -08:00
Pádraig Brady
4bb49f04a1 build: avoid statx related build failure on AIX
* src/stat.c (get_birthtime): Check also for STATX_BTIME define,
as a different statx is available on AIX 7.2.
2019-03-06 10:53:00 -08:00
Pádraig Brady
16358bc19c 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.
2019-03-06 10:52:17 -08:00
Pádraig Brady
4bbbe49074 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.
2019-03-06 09:00:44 -08:00
Pádraig Brady
efa3e5dda6 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.22 which is now about 5 years old.
2019-03-04 01:28:42 -08:00
Pádraig Brady
7c35a36bf4 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.
2019-03-04 01:15:51 -08:00
Pádraig Brady
6bf6d7f461 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.
2019-03-04 00:37:42 -08:00
Assaf Gordon
95adadd9a4 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.
2019-03-04 00:37:07 -08:00
Martin Bukatovic
186896d65f 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.
2019-03-03 23:33:51 -08:00
Pádraig Brady
811493e2a9 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.
2019-03-03 22:31:08 -08:00
Pádraig Brady
0d6be4b01f maint: tidy up recent additions to NEWS
* NEWS: Move date change to improvements and fix nohup grammar.
2019-03-03 19:21:37 -08:00
Bernhard Voelker
4ae1369516 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.
2019-02-27 18:51:30 +01:00
Pádraig Brady
a5202bd585 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.
2019-02-25 22:49:44 -08:00
Paul Eggert
2ab2f7a422 doc: more date +%F clarifications
* doc/coreutils.texi (Date conversion specifiers):
Plain %F is actually like %+4Y-%m-%d.
(Padding and other flags): Mention POSIX restrictions.
* src/date.c (usage): Document recent changes.
2019-02-25 10:21:07 -08:00
Paul Eggert
d5c820109e doc: give date +%+F example
* doc/coreutils.texi (Padding and other flags):
Give example for + conversion specification.
2019-02-25 08:03:38 -08:00
Paul Eggert
3e7fd6650e doc: fix typo in previous patch 2019-02-25 00:25:25 -08:00
Paul Eggert
b1e7af28eb 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.
2019-02-24 23:59:55 -08:00
Paul Eggert
c50c4ab9e1 build: update gnulib submodule to latest 2019-02-24 23:59:55 -08:00
Bernhard Voelker
44af84263e 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.

Discussed in https://bugs.gnu.org/33468 .

* NEWS: Mention change.
* src/cksum.c, src/dd.c, src/hostid.c, src/hostname.c, src/link.c,
src/logname.c, src/nohup.c, src/sleep.c, src/tsort.c, src/unlink.c,
src/uptime.c, src/users.c, src/whoami.c, src/yes.c (main): Replace
parse_long_options() + getopt_long() calls with
parse_gnu_standard_options_only(); Remove <getopt.h> inclusion;
Remove empty 'struct long_options' variable;
* tests/misc/help-version-getopt.sh: Add test.
* tests/local.mk (all_tests): Reference it.
2019-02-24 19:32:29 +01:00
Pádraig Brady
36b99b6113 gnulib: update to the latest
update to a version with parse_gnu_standard_options_only()
2019-02-23 18:55:53 -08:00
Martin Castillo
f473489f48 doc: fix join examples in texinfo
* doc/coreutils.texi (join invocation): Fix various errors.
Fixes https://bugs.gnu.org/34583
Fixes https://bugs.gnu.org/34584
2019-02-19 23:29:04 -08:00
Daming Yang
b1ac478653 ls: better align month abbreviations containing digits
* src/ls.c (abmon_init): Align numeric abbreviations right.
* NEWS: Mention the improvement.
2019-02-18 20:06:05 -08:00
Pádraig Brady
5e1a554712 sort: clarify in --debug; only text comparisons affected
* src/sort.c (main): Adjust the debug info regarding locales,
to clarify that only textual comparisons are affected.
* tests/misc/sort-debug-warn.sh: Adjust accordingly.
Fixes https://bugs.gnu.org/34490
2019-02-17 19:17:17 -08:00
Pádraig Brady
636cbdb77b comm,join: ensure warnings are apparent upon exit
* src/comm.c (main): Output a warning right before exit,
in case previous errors have scrolled from view.
* src/join.c (main): Likewise.
* tests/misc/comm.pl: Addjust accordingly.
* tests/misc/join.pl: Likewise.
Fixes https://bugs.gnu.org/34347
2019-02-11 22:56:21 -08:00
Filipp Gunbin
620112526b doc: fix typo referencing RFC 2822
* doc/coreutils.texi (date invocation): s/822/2822/.
Fixes https://bugs.gnu.org/34438
2019-02-11 22:56:08 -08:00
Pádraig Brady
2193e0b9fb gnulib: update to use new strtold module
* gnulib: Update to make the new strtold module available.
* bootstrap.conf: strtod is now a dependency of c-strtod,
which in turn is a dependency of cl-strtod.  This treats
strtold and strtod similarly.
* gl/lib/cl-strtod.c: Adjust to assume strtold is available.
* tests/misc/sort-float.sh: Likewise.
* src/sort.c: Likewise.
(nan_compare): Adjust comment to indicate
we still have to init padding bits as per
https://sourceware.org/bugzilla/show_bug.cgi?id=13246
2019-02-10 20:32:59 -08:00
Pádraig Brady
03fbb5ecec seq: output decimal points consistently with invalid locales
* src/seq.c (print_numbers): Only reset the locale if it
was successfully set originally.
* tests/misc/seq-locale.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
2019-02-03 17:18:08 -08:00
Pádraig Brady
027eeec7b0 build: ensure sys/select.h is included
bootstrap.conf: Explicitly depend on select, rather than transitively.
* src/tail.c: Unconditionally include select.h as we use select()
outside inotify contexts now.
2019-02-03 17:18:08 -08:00
Pádraig Brady
2e8f885a2a stat,tail: fix android build and support inotify
* src/extract-magic: Treat android like linux,
which fixes the build by ensuring the constants are defined.
* src/stat.c: Support all constants on android, including
the android specific "sdcardfs".
* src/tail.c: Fix inclusion of statfs headers to be independent
of inotify availability, as fremote() is used on linux even
if inotify has been disabled.  Also enable fremote() on android.
* NEWS: Mention the improvment.
Fixes https://bugs.gnu.org/34239
2019-02-03 17:18:08 -08:00
Pádraig Brady
90933c8eb0 tests: add test for locale decimal processing
* tests/misc/sleep.sh: Check locale processing of printf, sleep,
and timeout, when the french locale data is available.
2019-01-30 17:49:05 -08:00
Pádraig Brady
001897e7e2 build: fix recent build failure on systems without strtold
Recently introduced in commit v8.30-50-geb73e23

* gl/lib/cl-strtod.c: Fall back to strtod() on systems
without strtold() (like we already do in sort).
2019-01-30 17:49:05 -08:00
Pádraig Brady
ca80339454 maint: fix new syntax-check failure from recent change
* cfg.mk: Exclude cl-strtold.c wrapper from requiring config.h
2019-01-27 20:42:09 -08:00
Paul Eggert
8adc7ccf7c printf,seq: remove c-strtod dependency
* gl/modules/cl-strtold (Files): Add lib/cl-strtod.c, lib/cl-strtod.h.
(Depends-on): Remove cl-strtod.
(configure.ac): Redquire AC_C_RESTRICT.
2019-01-26 23:19:47 -08:00
Paul Eggert
eb73e23f31 printf,seq: improve long double accuracy
This fixes a thinko in the previous patch.
* gl/lib/cl-strtod.c (STRTOD): New macro.
(CL_STRTOD): Use it.
2019-01-26 23:19:47 -08:00
Paul Eggert
3fe8bc09be printf,seq,sleep,tail,timeout: accept current-locale floats
These commands now accept floating-point numbers in the
current locale, as well as in the C locale.
Compatibility problem reported by Robert Elz.
* NEWS: Document this.
* bootstrap.conf (gnulib_modules): Add cl-strtod, cl-strtold.
Remove c-strtold.
* doc/coreutils.texi (Floating point, tail invocation)
(printf invocation, timeout invocation, sleep invocation)
(seq invocation): Document this.
* gl/lib/cl-strtod.c, gl/lib/cl-strtod.h, gl/lib/cl-strtold.c:
* gl/modules/cl-strtod, gl/modules/cl-strtold: New files.
* src/printf.c, src/seq.c, src/sleep.c, src/tail.c, src/timeout.c:
Include cl-strtod.h instead of c-strtod.
* src/printf.c (vstrtold):
* src/seq.c (scan_arg, print_numbers):
* src/sleep.c (main):
* src/tail.c (parse_options):
* src/timeout.c (parse_duration):
Use cl_strtold instead of c_strtold.
2019-01-26 22:41:09 -08:00
Paul Eggert
3cd48057c7 doc: update Goldberg URL
* doc/coreutils.texi (Floating point): Update URL.
2019-01-25 11:32:46 -08:00
Paul Eggert
643a7325ec sleep: improve doc
Problem reported by Robert Elz.
* doc/coreutils.texi (sleep invocation):
Say that arguments must be non-negative, which means they cannot
be arbitrary floating-point numbers.  Mention POSIX, not
“historical implementations” that are no longer of practical
interest.  List the extensions to POSIX.
* src/sleep.c (usage): Omit needless words, removing dubious
commentary about “most implementations” and incorrect commentary
about “arbitrary”.  Details about exactly which numbers are
allowed can be found in the documentation.
2019-01-25 11:17:18 -08:00
Pádraig Brady
fa50623394 tail: fix handling of broken pipes with SIGPIPE ignored
* init.cfg (trap_sigpipe_or_skip_): A new function refactored from...
* tests/misc/printf-surprise.sh: ...here.
* tests/misc/seq-epipe.sh. Likewise.
* src/tail.c (die_pipe): Ensure we exit upon sending SIGPIPE.
* tests/tail-2/pipe-f.sh: Ensure we exit even if SIGPIPE is ignored.
* NEWS: Mention the bug fix.
2019-01-20 12:53:24 -08:00
Ayappan
17983b2cb3 tail: fix recent ineffective AIX change
* src/tail.c: Fix commit v8.30-40-gd5ab4cb which was ineffective.
Fixes http://bugs.gnu.org/33946
2019-01-20 00:45:32 -08:00
Pádraig Brady
d26dece5d8 build: ensure VLAs are not used
Fail developer builds if VLAs are used,
as there are portability concerns to consider with them.

* configure.ac: Enable -Wvla which is implicit in the full list added.
* m4/jm-macros.m4: Define GNULIB_NO_VLA which disables use of
VLAs within gnulib code.
2019-01-19 21:15:01 -08:00
Pádraig Brady
94fa0aa0d0 gnulib: update to the latest
* gnulib: Update to a version supporting GNULIB_NO_VLA
* bootstrap: Sync with latest
2019-01-19 21:07:04 -08:00
Bernhard Voelker
f114495e3e build: use distributed man pages when running with --help fails
When building against an incompatible GLIBC version compared to that
on the build host, then running the just-built binary might fail
although it is the same platform - thus CROSS_COMPILING is false.
As a result, generating the man pages fails.

* man/local.mk (.x.1): Add a check to verify that running the utility
with --help succeeds, otherwise falling back to using 'dummy-man'.
2019-01-16 08:26:01 +01:00
Pádraig Brady
39ca7731e2 ls: with --group-directories-first, also group symlinked dirs
* src/ls.c (is_linked_directory): A new function to
also consider symlinked directories.
(main): Rename check_symlink_color to check_symlink_mode,
and enable that with --group-directories-first.
(DIRFIRST_CHECK): Adjust to use is_linked_directory,
rather than just is_directory.
(gobble_file): Simplify to always update f->linkmode
if the stat() succeeds.
* tests/ls/group-dirs.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
Suggested by Amin Bandali in
https://lists.gnu.org/r/coreutils/2018-12/msg00017.html
2019-01-12 19:23:45 -08:00
Pádraig Brady
d5ab4cbe42 tail: don't exit immediately with filters on AIX
* src/tail.c: Fix the check_output_available check on AIX.
Note we don't use poll for all systems as the overhead
of adding the gnulib poll module wouldn't be worth it
just for this single use.
* tests/tail-2/pipe-f.sh: Fix the test which always passed
due to only the exit code of sleep being checked.
* NEWS: Mention the bug fix and rearrange alphabetically.
Fixes http://bugs.gnu.org/33946
2019-01-12 19:23:41 -08:00
Assaf Gordon
d045ce5166 basenc: allocate buffers on heap
Allocate the encoding/decoding buffers dynamically on the heap instead
of using variable-length-array (VLA) on the stack.
Discussed in https://lists.gnu.org/r/coreutils/2019-01/msg00004.html .

* src/basenc.c (do_encode,do_decode): Allocate inbuf/outbuf using
xmalloc, and free if using LINT.
2019-01-05 17:14:07 -07:00
Pádraig Brady
daaae12e3b doc: adjust URLs in help to avoid wrapping
* src/system.h: Adjust lines containing URLs so that
they don't wrap on 80 column terminals.  One could also
use .UR macros, but these aren't universally available.
Note the adjustments here need to be compatible with
the pattern matching done in help2man.
Addresses https://bugs.gnu.org/33914
2019-01-04 08:15:56 -08:00
Assaf Gordon
8dfcf38af1 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.
2019-01-01 16:51:48 -07:00
Bernhard Voelker
1f9152a50f maint: mention base32 in the title line of common basenc.c
* src/basenc.c: Do the above, and remove a redundant comment.
2019-01-01 16:32:27 -07:00
Assaf Gordon
67c537b91c base64,base32: fix 'extra operand' error message
In the following invocation, 'a' is the input file, and 'b' is the extra
operand:

  $ base64 a b

Report 'b' in the error message instead of 'a':

  $ base64 a b
  base64: extra operand 'b'

Discussed in https://lists.gnu.org/r/coreutils/2018-12/msg00008.html .

* src/basenc.c (main): If there is more than one non-option operand,
report the second one (assuming the first is a the input file name).
* tests/misc/base64.pl: Add tests.
* tests/misc/basenc.pl: Adjust expectedc error message in tests.
* NEWS: Mention bugfix.
2019-01-01 16:32:27 -07:00
Pádraig Brady
d1de5857c7 doc: mention that more than 8 colors are supported by ls
* src/dircolors.hin: Mention any codes supported by the terminal
are allowed.
Addresses https://bugs.gnu.org/33915
2018-12-31 05:17:23 -08:00
Assaf Gordon
2f438fa9f5 basenc: A new program complementary to base64/base32
Encodes/decodes data in various common formats:
base64,base64url,base32,base32,base16,base2,z85.

Discussed here:
https://lists.gnu.org/r/coreutils/2018-11/msg00014.html
https://lists.gnu.org/r/coreutils/2018-12/msg00019.html

* AUTHORS: Add basenc.
* README: Reference the new program.
* NEWS: Mention the new program.
* build-aux/gen-lists-of-programs.sh: Add basenc.
* doc/coreutils.texi: (basenc invocation): Document the new command.
* man/.gitignore: Ignore the generated man page.
* man/basenc.x: A new template, with few examples.
* man/local.mk: Reference the new man page.
* scripts/git-hooks/commit-msg: Allow basenc as program prefix.
* src/.gitignore: Ignore the new binary.
* src/basenc.c:
(usage): Mention new options.
(main): Handle new options.
(isbase*, base*_length, base*_encode, base*_decode_ctx): Implement new
encoding/decoding formats.
* src/local.mk: Add new program.
* tests/local.mk: Add new test.
* tests/misc/basenc.pl: New tests.
* tests/misc/help-version.sh (basenc_setup): use '--version' for default
invocation (basenc errors with no parameters).
2018-12-27 23:46:02 -07:00
Assaf Gordon
21c59d6845 maint: rename base64.c to basenc.c
In preparation for adding 'basenc' program.
Suggested in https://lists.gnu.org/r/coreutils/2018-11/msg00019.html .

* src/base64.c: Rename to src/basenc.c.
* src/local.mk: Update base*_SOURCES definitions.
* po/POTFILEs.in: Rename base64 to basenc.
2018-12-21 15:26:11 -07:00
Paul Eggert
69df9e20e2 shred,sort,split: add NEWS item 2018-12-15 12:42:50 -08:00
Paul Eggert
a6756257ef shred,sort,split: fix ftruncate error reporting
Problem reported for split by Scott Worley (Bug#33761):
* src/shred.c (do_wipefd):
Also report an error if ftruncate fails	on a shared memory object.
* src/sort.c (get_outstatus): New function.
(stream_open, avoid_trashing_input): Use it.
* src/sort.c (stream_open):
* src/split.c (create):
If ftruncate fails, do not report an error
unless it is a regular file or a shared memory object.
2018-12-15 12:14:49 -08:00
Bernhard Voelker
4711c49312 sync: add NEWS and test for the fix in the previous commit
* NEWS (Bug fixes): Mention the fix in commit 94d364f157.
While at it, remove duplicate "Changes in behavior" heading.
* tests/misc/sync.sh: Add a test with a write-only file for the fix.
2018-11-06 17:02:26 -08:00
Paul Eggert
94d364f157 sync: fix open fallback bug
Problem caught by Coverity Analysis
and reported by Kamil Dudka (Bug#33287).
* src/sync.c (sync_arg): Fix typo in fallback code.
2018-11-06 10:35:31 -08:00
Paul Eggert
806b0d1580 ln: use linkat and symlinkat
Open a target directory and use its file descriptor in linkat,
symlinkat, etc. syscalls, instead of constructing long file names
by concatenating the target directory name to a basename.
This avoids O(N²) behavior with ‘ln F1 F2 ... Fn DIR’ when DIR is
a long file name with many slashes.  It also avoids some races if
DIR is renamed while ln is running.
* bootstrap.conf (gnulib_modules): Add openat-safer.
* src/ln.c: Include fcntl-safer.h.
(O_PATHSEARCH): New constant.
(errno_nonexisting, target_directory_operand): Remove; no longer used.
(atomic_link, do_link): New arg DESTDIR_FD.  All uses changed.
(do_link): New arg DEST_BASE.  All uses changed.
(main): Open target directory and use its file descriptor
as DESTDIR_FD.
2018-10-28 01:46:11 -07:00
Paul Eggert
d9a4d98371 build: update gnulib submodule to latest
* src/copy.c (copy_internal):
* src/cp.c (do_copy):
* src/ln.c (do_link):
Adjust to Gnulib API change.
2018-10-28 01:46:11 -07:00
Bernhard Voelker
bdd54b4ee0 tests: provide 100% coverage for echo
*  src/echo.c (usage): Assert that STATUS is always EXIT_SUCCESS.
* tests/misc/echo.sh: Add further tests for all hex and escape and
escape characters.

To get coverage statistics, run:
  make coverage -j 4 TESTS=tests/misc/echo.sh SUBDIRS=.
  xdg-open doc/coverage/src/echo.c.gcov.frameset.html
2018-10-27 05:02:54 -07:00
Pádraig Brady
8d328706c6 echo: always process escapes when POSIXLY_CORRECT is set
* src/echo.c (main): Always enable backslash processing if
POSIXLY_CORRECT is set.
* tests/misc/echo.sh: Add (the first) test for the echo command.
* tests/local.mk: Reference the new test.
* tests/misc/printf.sh: Update a stale comment.
* doc/coreutils.texi (echo invocation). Mention that POSIXLY_CORRECT
now always enables backslash processing.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/32703
Issue identified by Eric Blake.
2018-10-27 03:05:24 -07:00
Bernhard Voelker
1a674a036b test: add -N unary operator
Bash knows 'test -N FILE'.  Add it to GNU 'test' as well.

* src/test.c (unary_operator): Add a case for 'N'.
(usage): Document it.
* doc/coreutils.texi (node File characteristic tests): Likewise.
* NEWS (New features): Likewise.
* tests/misc/test-N.sh: Add a test.
* tests/local.mk (all_tests): Reference it.
2018-10-26 11:05:25 +02:00
Bernhard Voelker
7fd7709a7a test: simplify redundant code
Remove the function 'test_unop', as the cases therein are redundant to
those handled by 'unary_operator'; exception: the cases 'o' and 'N':
they had been present in test_unop and handling the commands
  test -N STR
  test -o STR
and
  test x = x -a -N STR
  test x = x -a -o STR
which ran into an error later on anyway.
With this commit, the error diagnostic will change from ...
  $ /usr/bin/test -N STR
  /usr/bin/test: extra argument '-N'
  $ /usr/bin/test -o STR
  /usr/bin/test: extra argument '-o'
... to ...
  $ src/test -N STR
  src/test: '-N': unary operator expected
  $ src/test -o STR
  src/test: '-o': unary operator expected

* src/test.c (test_unop): Remove.
(unary_operator): Fail with test_syntax_error in the default case.
(term): Directly call unary_operator.
(two_arguments): Likewise.
* tests/misc/test-diag.pl: Adjust error diagnostic.
2018-10-26 10:54:11 +02:00
Bernhard Voelker
88c32fa68e test: remove support for the ambigous -a unary operator
* src/test.c (unary_operator): Remove case 'a'.
(test_unop): Likewise.
* NEWS (Changes in behavior): Document the change.

Discussed at https://bugs.gnu.org/33097
2018-10-26 10:53:57 +02:00
Bernhard Voelker
6bc89f5f85 test: avoid FP in chroot-credentials.sh for different group list order
On my openSUSE:Tumbleweed system, I get a false positive test failure
in the above 'check-root' test because the group lists inside and
outside the chroot have a different order:

  ++ chroot --userspec=berny / id -G
  ++ id -G berny
  + test '100 454 457 480 492' = '100 480 492 457 454'
  + fail=1

* tests/misc/chroot-credentials.sh (num_sort): Add function to sort
group lists, and use it in the test cases which test multiple groups.
2018-10-21 14:55:51 +02:00
Paul Eggert
8ea92f2a1d doc: tidy up setuid commentary
* doc/perm.texi (Mode Structure): Improve wording.
(Numeric Modes): Don’t say “on execution” (Bug#9594).
2018-10-20 10:59:17 -07:00
Paul Eggert
571f63f501 ln: avoid directory hard-link races
Previously, 'ln A B' did 'stat("B"), lstat("A"), link("A","B")'
where the stat and lstat were necessary to avoid hard-linking
directories on systems that can hard-link directories.
Now, in situations that prohibit hard links to directories,
'ln A B' merely does 'link("A","B")'.  The new behavior
avoids some races and should be more efficient.
This patch was inspired by Bug#10020, which was about 'ln'.
* bootstrap.conf (gnulib_modules): Add unlinkdir.
* src/force-link.c (force_linkat, force_symlinkat): New arg for
error number of previous try.  Return error number, 0, or -1 if
error, success, or success after removal.  All callers changed.
* src/ln.c: Include priv-set.h, unlinkdir.h.
(beware_hard_dir_link): New static var.
(errnoize, atomic_link): New functions.
(target_directory_operand): Use errnoize for simplicity.
(do_link): New arg for error number of previous try.  All callers
changed.  Do each link atomically if possible.
(main): Do -r check earlier.  Remove linkdir privileges so we can
use a single linkat/symlinkat instead of a racy substitute for the
common case of 'ln A B' and 'ln -s A B'.  Set beware_hard_dir_link
to disable this optimization.
2018-10-19 12:38:34 -07:00
Paul Eggert
cbc427485e cp: 'cp -il A B' no longer fails if user OKs it
* NEWS: Mention the change.
* src/copy.c (copy_internal): Replace the link if the
user has okayed it.
2018-10-19 12:38:34 -07:00
Paul Eggert
9c3730e601 build: update gnulib submodule to latest
* gl/modules/tempname.diff: Update to match Gnulib.
2018-10-19 12:38:33 -07:00
Paul Eggert
4d5db7193c doc: add chmod examples
Discussed in https://bugs.gnu.org/11043 .

* doc/coreutils.texi (chmod invocation): Add examples.
2018-10-17 14:31:04 -06:00
Bjarni Ingi Gislason
dedb3973e3 doc: fix minor mistakes in "env.x"
* man/env.x (OPTIONS): Fix a spelling mistake.  Protect a period at the
beginning of a line.
2018-10-02 01:09:44 +02:00
Achilles Gaikwad
a32a756a58 id: support multiple specified users
$ id root nobody
  uid=0(root) gid=0(root) groups=0(root)
  uid=99(nobody) gid=99(nobody) groups=99(nobody)

* src/id.c (main): Make variables opt_zero, just_group_list,
just_group, use_real, just_user global to be used in a new
function.
(print_stuff): New function that will print user and group
information for the specified USER.
When using -G option delimit each record with two NULs.
Restructure the code in the file to have global variables
followed by functions.
* tests/id/zero.sh: Add test cases to check the usage
of -z option with multiple users.
* tests/id/uid.sh: Add a test case to ensure all users
are queried in the presence of errors.
* doc/coreutils.texi: Document the interface changes.
* NEWS: Mention the new feature.
2018-09-29 22:39:26 -07:00
Stéphane Campinas
7262994810 doc: csplit: clarify handling of regexps with negative offsets
* doc/coreutils.texi (csplit invocation): Detail the behavior
with regexp patterns and negative offsets, which differs from
line number patterns, to avoid looping on the input.  For example:
  $ seq 50 | csplit -s - /15/-5 /12/
  csplit: ‘/12/’: match not found
2018-09-24 23:48:56 -07:00
Pádraig Brady
f7b2502100 doc: csplit: clarify input may not be reproducible from output
* doc/coreutils.texi (csplit invocation): Clarify that
portions of the input may be skipped and thus the input
may not be reproducible by just concatenating the output files.
Fixes https://bugs.gnu.org/32317
2018-09-23 21:17:04 -07:00
Paul Eggert
e5dae2c6b0 df: omit redundant comparison
Trivial inefficiency reported by Bruno Haible in:
http://lists.gnu.org/r/bug-gnulib/2018-07/msg00109.html
* src/df.c (hide_problematic_chars): Omit redundant test.
2018-07-27 12:03:52 -07:00
Paul Eggert
25c74a37ca df: tune slightly
* src/df.c (get_header, get_dev):
Avoid calling mbswidth twice when once will do.
2018-07-26 18:19:45 -07:00
Paul Eggert
1ecf7abe4a df: avoid multibyte character corruption on macOS
This improves on the earlier fix for the problem reported by
Chih-Hsuan Yen (Bug#32236), by also looking for other control
characters and for encoding errors.
* src/df.c: Include wchar.h and wctype.h instead of c-ctype.h.
(hide_problematic_chars): Process the string as multibyte.
Use iswcntrl, not c_iscntrl.
2018-07-26 18:19:45 -07:00
Chih-Hsuan Yen
437555061c df: avoid multibyte character corruption on macOS
* src/df.c (hide_problematic_chars): Use c_iscntrl() as
passing 8 bit characters to iscntrl() is not supported on macOS.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/32236
2018-07-26 10:24:41 -07:00
Wodry
46d6bd0c0a doc: improve documentation of binary prefixes
* doc/coreutils.texi (Common options):
* src/dd.c, src/head.c, src/od.c, src/stdbuf.c, src/tail.c (usage):
* src/system.h (emit_size_note):
Mention binary prefixes (Bug#32242).
Copyright-paperwork-exempt: Yes
2018-07-22 08:37:15 -07:00
Pádraig Brady
49b682bdd8 tests: avoid false failure on sparc 32 bit
* tests/rm/rm-readdir-fail.sh: Skip the test entirely on 32 bit,
so we avoid conflating the 32bit and 64 bit types, as that
triggers alignment issues (SIGBUS) on Gentoo sparc.
Fixes https://bugs.gnu.org/29886
2018-07-21 12:36:46 -07:00
Paul Eggert
4397410532 build: update gnulib submodule to latest
* bootstrap.conf, src/copy.c, src/mv.c, src/shred.c:
Adjust to renaming of renameat2 to renameatu.
2018-07-05 09:52:14 -07:00
Pádraig Brady
351ac1256b tests: fix skipping in some tests
* tests/cp/cp-a-selinux.sh: Use 'skip_' rather than the probably
undefined 'skip'.
* tests/du/2g.sh: Likewise.
* tests/install/install-Z-selinux.sh: Likewise.
* tests/misc/chcon.sh: Likewise.
* tests/misc/selinux.sh: Likewise.
* tests/mkdir/restorecon.sh: Likewise.
* cfg.mk (sc_prohibit-skip): A new syntax check to catch the issue.
2018-07-04 17:48:41 -07:00
Jim Meyering
19ceb7b89e maint: init.cfg: fix a minor test-related quoting bug
* init.cfg (require_membership_in_two_groups_): This fixes a bug
introduced by me in v8.15-8-gdd0e4c562.  Luckily, the consequence
of low-probability triggering the bug was the mere added backslash
in the diagnostic: "...but running id -G\ either...".  It would be
triggered in a test failure for one who is a member of only one or
fewer groups.
2018-07-01 20:09:17 -07:00
Pádraig Brady
83322567de maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-07-01 18:28:37 -07:00
909 changed files with 23220 additions and 11420 deletions

View File

@@ -68,7 +68,7 @@ When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
<!--
Copyright (C) 2017-2018 Free Software Foundation, Inc.
Copyright (C) 2017-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -88,7 +88,7 @@ in this matter.
<!--
Copyright (C) 2017-2018 Free Software Foundation, Inc.
Copyright (C) 2017-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

27
.gitignore vendored
View File

@@ -4,9 +4,10 @@
*.gcda
*.gcno
*.o
*/.deps/
*.a
*~
._bootmp
.deps
.gdb-history
.kludge-stamp
.version
@@ -31,22 +32,25 @@
/build-aux/test-driver
/build-aux/texinfo.tex
/build-aux/ylwrap
/confdefs*
/config.cache
/config.log
/config.status
/configure
/conftest*
/coreutils-*.tar.gz
/coreutils-*.tar.gz.sig
/coreutils-*.tar.xz
/coreutils-*.tar.xz.sig
/doc/manual
/doc/coverage
/doc/manual
/gnulib-tests
/lib/.dirstamp
/lib/.gitignore
/lib/alloca.h
/lib/arg-nonnull.h
/lib/arpa/inet.h
/lib/assert.h
/lib/byteswap.h
/lib/c++defs.h
/lib/charset.alias
@@ -56,42 +60,48 @@
/lib/ctype.h
/lib/dirent.h
/lib/errno.h
/lib/error.h
/lib/fcntl.h
/lib/float.h
/lib/fnmatch.h
/lib/getopt.h
/lib/getopt-cdefs.h
/lib/getopt.h
/lib/glthread
/lib/gmp.h
/lib/iconv.h
/lib/iconv_open-aix.h
/lib/iconv_open-hpux.h
/lib/iconv_open-irix.h
/lib/iconv_open-osf.h
/lib/iconv_open-solaris.h
/lib/iconv_open-zos.h
/lib/inttypes.h
/lib/langinfo.h
/lib/libcoreutils.a
/lib/limits.h
/lib/link-warning.h
/lib/locale.h
/lib/malloc/
/lib/math.h
/lib/netdb.h
/lib/netinet/in.h
/lib/parse-datetime-gen.h
/lib/parse-datetime.c
/lib/poll.h
/lib/printf.c
/lib/pthread.h
/lib/ref-add.sed
/lib/ref-del.sed
/lib/sched.h
/lib/se-context.h
/lib/se-label.h
/lib/se-selinux.h
/lib/selinux
/lib/signal.h
/lib/spawn.h
/lib/stamp-h1
/lib/stdalign.h
/lib/stdarg.h
/lib/stdbool.h
/lib/stdckdint.h
/lib/stddef.h
/lib/stdint.h
/lib/stdio.h
@@ -101,13 +111,13 @@
/lib/sys/
/lib/termios.h
/lib/time.h
/lib/unictype
/lib/unistd.h
/lib/unistr
/lib/unistr.h
/lib/unitypes.h
/lib/uniwidth
/lib/uniwidth.h
/lib/unused-parameter.h
/lib/utime.h
/lib/warn-on-use.h
/lib/wchar.h
@@ -171,14 +181,13 @@
/po/remove-potcdate.sin
/po/stamp-po
/src/coreutils.h
/src/coreutils_symlinks
/src/coreutils_shebangs
/src/coreutils_symlinks
/src/cu-progs.mk
/src/fs-latest-magic.h
/src/fs-def
/src/fs-kernel-magic
/src/fs-latest-magic.h
/src/fs-magic
/src/libsinglebin_*.a
/src/make-prime-list
/src/primes.h
/src/single-binary.mk

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "gnulib"]
path = gnulib
url = git://git.sv.gnu.org/gnulib.git
url = https://git.savannah.gnu.org/git/gnulib.git

View File

@@ -1 +1 @@
8.29
9.2

View File

@@ -1,6 +1,6 @@
# Suppress valgrind diagnostics we don't care about.
# Copyright (C) 2003-2018 Free Software Foundation, Inc.
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,4 +1,5 @@
^COPYING$
^bootstrap$
^doc/fdl\.texi$
^man/help2man$
^tests/init\.sh$

View File

@@ -6,13 +6,14 @@ b2sum: Padraig Brady, Samuel Neves
base32: Simon Josefsson
base64: Simon Josefsson
basename: David MacKenzie
basenc: Simon Josefsson, Assaf Gordon
cat: Torbjorn Granlund, Richard M. Stallman
chcon: Russell Coker, Jim Meyering
chgrp: David MacKenzie, Jim Meyering
chmod: David MacKenzie, Jim Meyering
chown: David MacKenzie, Jim Meyering
chroot: Roland McGrath
cksum: Q. Frank Xia
cksum: Padraig Brady, Q. Frank Xia
comm: Richard M. Stallman, David MacKenzie
coreutils: Alex Deymo
cp: Torbjorn Granlund, David MacKenzie, Jim Meyering

View File

@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@@ -20,7 +20,7 @@ Use the latest upstream sources
Base any changes you make on the latest upstream sources.
You can get a copy of the latest with this command:
git clone git://git.sv.gnu.org/coreutils
git clone https://git.savannah.gnu.org/git/coreutils.git
cd coreutils
That downloads the entire repository, including revision control history
@@ -95,7 +95,7 @@ Make your changes on a private "topic" branch
=============================================
So you checked out coreutils like this:
git clone git://git.sv.gnu.org/coreutils
git clone https://git.savannah.gnu.org/git/coreutils.git
Now, cd into the coreutils/ directory and run:
@@ -617,7 +617,7 @@ and root only tests, is to follow these steps (requires lcov to be installed):
xdg-open doc/coverage/index.html
========================================================================
Copyright (C) 2009-2018 Free Software Foundation, Inc.
Copyright (C) 2009-2023 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -1,6 +1,6 @@
# Make coreutils. -*-Makefile-*-
# Copyright (C) 1990-2018 Free Software Foundation, Inc.
# Copyright (C) 1990-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@ EXTRA_DIST = \
.prev-version \
.version \
.vg-suppressions \
README-install \
THANKS.in \
THANKS-to-translators \
THANKStt.in \
@@ -93,7 +94,7 @@ dist-hook: gen-ChangeLog
$(AM_V_at)touch $(distdir)/doc/constants.texi \
$(distdir)/doc/coreutils.info
gen_start_ver = 8.20
gen_start_ver = 8.29
.PHONY: gen-ChangeLog
gen-ChangeLog:
$(AM_V_GEN)if test -d .git; then \

724
NEWS
View File

@@ -1,5 +1,721 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 9.3 (2023-04-18) [stable]
** Bug fixes
cp --reflink=auto (the default), mv, and install
will again fall back to a standard copy in more cases.
Previously copies could fail with permission errors on
more restricted systems like android or containers etc.
[bug introduced in coreutils-9.2]
cp --recursive --backup will again operate correctly.
Previousy it may have issued "File exists" errors when
it failed to appropriately rename files being replaced.
[bug introduced in coreutils-9.2]
date --file and dircolors will now diagnose a failure to read a file.
Previously they would have silently ignored the failure.
[This bug was present in "the beginning".]
md5sum --check again correctly prints the status of each file checked.
Previously the status for files was printed as 'OK' once any file had passed.
This also applies to cksum, sha*sum, and b2sum.
[bug introduced in coreutils-9.2]
wc will now diagnose if any total counts have overflowed.
[This bug was present in "the beginning".]
`wc -c` will again correctly update the read offset of inputs.
Previously it deduced the size of inputs while leaving the offset unchanged.
[bug introduced in coreutils-8.27]
Coreutils programs no longer fail for timestamps past the year 2038
on obsolete configurations with 32-bit signed time_t, because the
build procedure now rejects these configurations.
[This bug was present in "the beginning".]
** Changes in behavior
'cp -n' and 'mv -n' now issue an error diagnostic if skipping a file,
to correspond with -n inducing a nonzero exit status as of coreutils 9.2.
Similarly 'cp -v' and 'mv -v' will output a message for each file skipped
due to -n, -i, or -u.
** New features
cp and mv now support --update=none to always skip existing files
in the destination, while not affecting the exit status.
This is equivalent to the --no-clobber behavior from before v9.2.
* Noteworthy changes in release 9.2 (2023-03-20) [stable]
** Bug fixes
'comm --output-delimiter="" --total' now delimits columns in the total
line with the NUL character, consistent with NUL column delimiters in
the rest of the output. Previously no delimiters were used for the
total line in this case.
[bug introduced with the --total option in coreutils-8.26]
'cp -p' no longer has a security hole when cloning into a dangling
symbolic link on macOS 10.12 and later.
[bug introduced in coreutils-9.1]
'cp -rx / /mnt' no longer complains "cannot create directory /mnt/".
[bug introduced in coreutils-9.1]
cp, mv, and install avoid allocating too much memory, and possibly
triggering "memory exhausted" failures, on file systems like ZFS,
which can return varied file system I/O block size values for files.
[bug introduced in coreutils-6.0]
cp, mv, and install now immediately acknowledge transient errors
when creating copy-on-write or cloned reflink files, on supporting
file systems like XFS, BTRFS, APFS, etc.
Previously they would have tried again with other copy methods
which may have resulted in data corruption.
[bug introduced in coreutils-7.5 and enabled by default in coreutils-9.0]
cp, mv, and install now handle ENOENT failures across CIFS file systems,
falling back from copy_file_range to a better supported standard copy.
[issue introduced in coreutils-9.0]
'mv --backup=simple f d/' no longer mistakenly backs up d/f to f~.
[bug introduced in coreutils-9.1]
rm now fails gracefully when memory is exhausted.
Previously it may have aborted with a failed assertion in some cases.
[This bug was present in "the beginning".]
rm -d (--dir) now properly handles unreadable empty directories.
E.g., before, this would fail to remove d: mkdir -m0 d; src/rm -d d
[bug introduced in v8.19 with the addition of this option]
runcon --compute no longer looks up the specified command in the $PATH
so that there is no mismatch between the inspected and executed file.
[bug introduced when runcon was introduced in coreutils-6.9.90]
'sort -g' no longer infloops when given multiple NaNs on platforms
like x86_64 where 'long double' has padding bits in memory.
Although the fix alters sort -g's NaN ordering, that ordering has
long been documented to be platform-dependent.
[bug introduced 1999-05-02 and only partly fixed in coreutils-8.14]
stty ispeed and ospeed options no longer accept and silently ignore
invalid speed arguments, or give false warnings for valid speeds.
Now they're validated against both the general accepted set,
and the system supported set of valid speeds.
[This bug was present in "the beginning".]
stty now wraps output appropriately for the terminal width.
Previously it may have output 1 character too wide for certain widths.
[bug introduced in coreutils-5.3]
tail --follow=name works again with non seekable files. Previously it
exited with an "Illegal seek" error when such a file was replaced.
[bug introduced in fileutils-4.1.6]
'wc -c' will again efficiently determine the size of large files
on all systems. It no longer redundantly reads data from certain
sized files larger than SIZE_MAX.
[bug introduced in coreutils-8.24]
** Changes in behavior
Programs now support the new Ronna (R), and Quetta (Q) SI prefixes,
corresponding to 10^27 and 10^30 respectively,
along with their binary counterparts Ri (2^90) and Qi (2^100).
In some cases (e.g., 'sort -h') these new prefixes simply work;
in others, where they exceed integer width limits, they now elicit
the same integer overflow diagnostics as other large prefixes.
'cp --reflink=always A B' no longer leaves behind a newly created
empty file B merely because copy-on-write clones are not supported.
'cp -n' and 'mv -n' now exit with nonzero status if they skip their
action because the destination exists, and likewise for 'cp -i',
'ln -i', and 'mv -i' when the user declines. (POSIX specifies this
for 'cp -i' and 'mv -i'.)
cp, mv, and install again read in multiples of the reported block size,
to support unusual devices that may have this constraint.
[behavior inadvertently changed in coreutils-7.2]
du --apparent now counts apparent sizes only of regular files and
symbolic links. POSIX does not specify the meaning of apparent
sizes (i.e., st_size) for other file types, and counting those sizes
could cause confusing and unwanted size mismatches.
'ls -v' and 'sort -V' go back to sorting ".0" before ".A",
reverting to the behavior in coreutils-9.0 and earlier.
This behavior is now documented.
ls --color now matches a file extension case sensitively
if there are different sequences defined for separate cases.
printf unicode \uNNNN, \UNNNNNNNN syntax, now supports all valid
unicode code points. Previously is was restricted to the C
universal character subset, which restricted most points <= 0x9F.
runcon now exits with status 125 for internal errors. Previously upon
internal errors it would exit with status 1, which was less distinguishable
from errors from the invoked command.
'split -n N' now splits more evenly when the input size is not a
multiple of N, by creating N output files whose sizes differ by at
most 1 byte. Formerly, it did this only when the input size was
less than N.
'stat -c %s' now prints sizes as unsigned, consistent with 'ls'.
** New Features
cksum now accepts the --base64 (-b) option to print base64-encoded
checksums. It also accepts/checks such checksums.
cksum now accepts the --raw option to output a raw binary checksum.
No file name or other information is output in this mode.
cp, mv, and install now accept the --debug option to
print details on how a file is being copied.
factor now accepts the --exponents (-h) option to print factors
in the form p^e, rather than repeating the prime p, e times.
ls now supports the --time=modification option, to explicitly
select the default mtime timestamp for display and sorting.
mv now supports the --no-copy option, which causes it to fail when
asked to move a file to a different file system.
split now accepts options like '-n SIZE' that exceed machine integer
range, when they can be implemented as if they were infinity.
split -n now accepts piped input even when not in round-robin mode,
by first copying input to a temporary file to determine its size.
wc now accepts the --total={auto,never,always,only} option
to give explicit control over when the total is output.
** Improvements
cp --sparse=auto (the default), mv, and install,
will use the copy_file_range syscall now also with sparse files.
This may be more efficient, by avoiding user space copies,
and possibly employing copy offloading or reflinking,
for the non sparse portion of such sparse files.
On macOS, cp creates a copy-on-write clone in more cases.
Previously cp would only do this when preserving mode and timestamps.
date --debug now diagnoses if multiple --date or --set options are
specified, as only the last specified is significant in that case.
rm outputs more accurate diagnostics in the presence of errors
when removing directories. For example EIO will be faithfully
diagnosed, rather than being conflated with ENOTEMPTY.
tail --follow=name now works with single non regular files even
when their modification time doesn't change when new data is available.
Previously tail would not show any new data in this case.
tee -p detects when all remaining outputs have become broken pipes, and
exits, rather than waiting for more input to induce an exit when written.
tee now handles non blocking outputs, which can be seen for example with
telnet or mpirun piping through tee to a terminal.
Previously tee could truncate data written to such an output and fail,
and also potentially output a "Resource temporarily unavailable" error.
* Noteworthy changes in release 9.1 (2022-04-15) [stable]
** Bug fixes
chmod -R no longer exits with error status when encountering symlinks.
All files would be processed correctly, but the exit status was incorrect.
[bug introduced in coreutils-9.0]
If 'cp -Z A B' checks B's status and some other process then removes B,
cp no longer creates B with a too-generous SELinux security context
before adjusting it to the correct value.
[bug introduced in coreutils-8.17]
'cp --preserve=ownership A B' no longer ignores the umask when creating B.
Also, 'cp --preserve-xattr A B' is less likely to temporarily chmod u+w B.
[bug introduced in coreutils-6.7]
On macOS, 'cp A B' no longer miscopies when A is in an APFS file system
and B is in some other file system.
[bug introduced in coreutils-9.0]
On macOS, fmt no longer corrupts multi-byte characters
by misdetecting their component bytes as spaces.
[This bug was present in "the beginning".]
'id xyz' now uses the name 'xyz' to determine groups, instead of xyz's uid.
[bug introduced in coreutils-8.22]
'ls -v' and 'sort -V' no longer mishandle corner cases like "a..a" vs "a.+"
or lines containing NULs. Their behavior now matches the documentation
for file names like ".m4" that consist entirely of an extension,
and the documentation has been clarified for unusual cases.
[bug introduced in coreutils-7.0]
On macOS, 'mv A B' no longer fails with "Operation not supported"
when A and B are in the same tmpfs file system.
[bug introduced in coreutils-9.0]
'mv -T --backup=numbered A B/' no longer miscalculates the backup number
for B when A is a directory, possibly inflooping.
[bug introduced in coreutils-6.3]
** Changes in behavior
cat now uses the copy_file_range syscall if available, when doing
simple copies between regular files. This may be more efficient, by avoiding
user space copies, and possibly employing copy offloading or reflinking.
chown and chroot now warn about usages like "chown root.root f",
which have the nonstandard and long-obsolete "." separator that
causes problems on platforms where user names contain ".".
Applications should use ":" instead of ".".
cksum no longer allows abbreviated algorithm names,
so that forward compatibility and robustness is improved.
date +'%-N' now suppresses excess trailing digits, instead of always
padding them with zeros to 9 digits. It uses clock_getres and
clock_gettime to infer the clock resolution.
dd conv=fsync now synchronizes output even after a write error,
and similarly for dd conv=fdatasync.
dd now counts bytes instead of blocks if a block count ends in "B".
For example, 'dd count=100KiB' now copies 100 KiB of data, not
102,400 blocks of data. The flags count_bytes, skip_bytes and
seek_bytes are therefore obsolescent and are no longer documented,
though they still work.
ls no longer colors files with capabilities by default, as file-based
capabilties are very rarely used, and lookup increases processing per file by
about 30%. It's best to use getcap [-r] to identify files with capabilities.
ls no longer tries to automount files, reverting to the behavior
before the statx() call was introduced in coreutils-8.32.
stat no longer tries to automount files by default, reverting to the
behavior before the statx() call was introduced in coreutils-8.32.
Only `stat --cached=never` will continue to automount files.
timeout --foreground --kill-after=... will now exit with status 137
if the kill signal was sent, which is consistent with the behavior
when the --foreground option is not specified. This allows users to
distinguish if the command was more forcefully terminated.
** New Features
dd now supports the aliases iseek=N for skip=N, and oseek=N for seek=N,
like FreeBSD and other operating systems.
dircolors takes a new --print-ls-colors option to display LS_COLORS
entries, on separate lines, colored according to the entry color code.
dircolors will now also match COLORTERM in addition to TERM environment
variables. The default config will apply colors with any COLORTERM set.
** Improvements
cp, mv, and install now use openat-like syscalls when copying to a directory.
This avoids some race conditions and should be more efficient.
On macOS, cp creates a copy-on-write clone if source and destination
are regular files on the same APFS file system, the destination does
not already exist, and cp is preserving mode and timestamps (e.g.,
'cp -p', 'cp -a').
The new 'date' option --resolution outputs the timestamp resolution.
With conv=fdatasync or conv=fsync, dd status=progress now reports
any extra final progress just before synchronizing output data,
since synchronizing can take a long time.
printf now supports printing the numeric value of multi-byte characters.
sort --debug now diagnoses issues with --field-separator characters
that conflict with characters possibly used in numbers.
'tail -f file | filter' now exits on Solaris when filter exits.
root invoked coreutils, that are built and run in single binary mode,
now adjust /proc/$pid/cmdline to be more specific to the utility
being run, rather than using the general "coreutils" binary name.
** Build-related
AIX builds no longer fail because some library functions are not found.
[bug introduced in coreutils-8.32]
* Noteworthy changes in release 9.0 (2021-09-24) [stable]
** Bug fixes
chmod -v no longer misreports modes of dangling symlinks.
[bug introduced in coreutils-5.3.0]
cp -a --attributes-only now never removes destination files,
even if the destination files are hardlinked, or the source
is a non regular file.
[bug introduced in coreutils-8.6]
csplit --suppress-matched now elides the last matched line
when a specific number of pattern matches are performed.
[bug introduced with the --suppress-matched feature in coreutils-8.22]
df no longer outputs duplicate remote mounts in the presence of bind mounts.
[bug introduced in coreutils-8.26]
df no longer mishandles command-line args that it pre-mounts
[bug introduced in coreutils-8.29]
du no longer crashes on XFS file systems when the directory hierarchy is
heavily changed during the run.
[bug introduced in coreutils-8.25]
env -S no longer crashes when given unusual whitespace characters
[bug introduced in coreutils-8.30]
expr no longer mishandles unmatched \(...\) in regular expressions.
[bug introduced in coreutils-6.0]
ls no longer crashes when printing the SELinux context for unstatable files.
[bug introduced in coreutils-6.9.91]
mkdir -m no longer mishandles modes more generous than the umask.
[bug introduced in coreutils-8.22]
nl now handles single character --section-delimiter arguments,
by assuming a second ':' character has been specified, as specified by POSIX.
[This bug was present in "the beginning".]
pr again adjusts tabs in input, to maintain alignment in multi column output.
[bug introduced in coreutils-6.9]
rm no longer skips an extra file when the removal of an empty directory fails.
[bug introduced by the rewrite to use fts in coreutils-8.0]
split --number=K/N will again correctly split chunk K of N to stdout.
Previously a chunk starting after 128KiB, output the wrong part of the file.
[bug introduced in coreutils-8.26]
tail -f no longer overruns a stack buffer when given too many files
to follow and ulimit -n exceeds 1024.
[bug introduced in coreutils-7.5]
tr no longer crashes when using --complement with certain
invalid combinations of case character classes.
[bug introduced in coreutils-8.6]
basenc --base64 --decode no longer silently discards decoded characters
on (1024*5) buffer boundaries
[bug introduced in coreutils-8.31]
** Changes in behavior
cp and install now default to copy-on-write (COW) if available.
I.e., cp now uses --reflink=auto mode by default.
cp, install and mv now use the copy_file_range syscall if available.
Also, they use lseek+SEEK_HOLE rather than ioctl+FS_IOC_FIEMAP on sparse
files, as lseek is simpler and more portable.
On GNU/Linux systems, ls no longer issues an error message on a
directory merely because it was removed. This reverts a change
that was made in release 8.32.
ptx -T no longer attempts to substitute old-fashioned TeX escapes
for 8-bit non-ASCII alphabetic characters. TeX indexes should
instead use '\usepackage[latin1]{inputenc}' or equivalent.
stat will use decomposed (major,minor) device numbers in its default format.
This is less ambiguous, and more consistent with ls.
sum [-r] will output a file name, even if only a single name is passed.
This is consistent with sum -s, cksum, and other sum(1) implementations.
** New Features
cksum now supports the -a (--algorithm) option to select any
of the existing sum, md5sum, b2sum, sha*sum implementations etc.
cksum now subsumes all of these programs, and coreutils
will introduce no future standalone checksum utility.
cksum -a now supports the 'sm3' argument, to use the SM3 digest algorithm.
cksum --check now supports auto detecting the digest type to use,
when verifying tagged format checksums.
expr and factor now support bignums on all platforms.
ls --classify now supports the "always", "auto", or "never" flags,
to support only outputting classifier characters if connected to a tty.
ls now accepts the --sort=width option, to sort by file name width.
This is useful to more compactly organize the default vertical column output.
ls now accepts the --zero option, to terminate each output line with
NUL instead of newline.
nl --line-increment can now take a negative number to decrement the count.
stat supports more formats for representing decomposed device numbers.
%Hd,%Ld and %Hr,%Lr will output major,minor device numbers and device types
respectively. %d corresponds to st_dev and %r to std_rdev.
** Improvements
cat --show-ends will now show \r\n as ^M$. Previously the \r was taken
literally, thus overwriting the first character in the line with '$'.
cksum [-a crc] is now up to 4 times faster by using a slice by 8 algorithm,
and at least 8 times faster where pclmul instructions are supported.
A new --debug option will indicate if pclmul is being used.
md5sum --check now supports checksum files with CRLF line endings.
This also applies to cksum, sha*sum, and b2sum.
df now recognizes these file systems as remote:
acfs, coda, fhgfs, gpfs, ibrix, ocfs2, and vxfs.
rmdir now clarifies the error if a symlink_to_dir/ has not been traversed.
This is the case on GNU/Linux systems, where the trailing slash is ignored.
stat and tail now know about the "devmem", "exfat", "secretmem", "vboxsf",
and "zonefs" file system types. stat -f -c%T now reports the file system
type, and tail -f uses polling for "vboxsf" and inotify for the others.
timeout now supports sub-second timeouts on macOS.
wc is up to 5 times faster when counting only new line characters,
where avx2 instructions are supported.
A new --debug option will indicate if avx2 is being used.
* Noteworthy changes in release 8.32 (2020-03-05) [stable]
** Bug fixes
cp now copies /dev/fd/N correctly on platforms like Solaris where
it is a character-special file whose minor device number is N.
[bug introduced in fileutils-4.1.6]
dd conv=fdatasync no longer reports a "Bad file descriptor" error
when fdatasync is interrupted, and dd now retries interrupted calls
to close, fdatasync, fstat and fsync instead of incorrectly
reporting an "Interrupted system call" error.
[bugs introduced in coreutils-6.0]
df now correctly parses the /proc/self/mountinfo file for unusual entries
like ones with '\r' in a field value ("mount -t tmpfs tmpfs /foo$'\r'bar"),
when the source field is empty ('mount -t tmpfs "" /mnt'), and when the
filesystem type contains characters like a blank which need escaping.
[bugs introduced in coreutils-8.24 with the introduction of reading
the /proc/self/mountinfo file]
factor again outputs immediately when stdout is a tty but stdin is not.
[bug introduced in coreutils-8.24]
ln works again on old systems without O_DIRECTORY support (like Solaris 10),
and on systems where symlink ("x", ".") fails with errno == EINVAL
(like Solaris 10 and Solaris 11).
[bug introduced in coreutils-8.31]
rmdir --ignore-fail-on-non-empty now works correctly for directories
that fail to be removed due to permission issues. Previously the exit status
was reversed, failing for non empty and succeeding for empty directories.
[bug introduced in coreutils-6.11]
'shuf -r -n 0 file' no longer mistakenly reads from standard input.
[bug introduced with the --repeat feature in coreutils-8.22]
split no longer reports a "output file suffixes exhausted" error
when the specified number of files is evenly divisible by 10, 16, 26,
for --numeric, --hex, or default alphabetic suffixes respectively.
[bug introduced in coreutils-8.24]
seq no longer prints an extra line under certain circumstances (such as
'seq -f "%g " 1000000 1000000').
[bug introduced in coreutils-6.10]
** Changes in behavior
Several programs now check that numbers end properly. For example,
'du -d 1x' now reports an error instead of silently ignoring the 'x'.
Affected programs and options include du -d, expr's numeric operands
on non-GMP builds, install -g and -o, ls's TABSIZE environment
variable, mknod b and c, ptx -g and -w, shuf -n, and sort --batch-size
and --parallel.
date now parses military time zones in accordance with common usage:
"A" to "M" are equivalent to UTC+1 to UTC+12
"N" to "Y" are equivalent to UTC-1 to UTC-12
"Z" is "zulu" time (UTC).
For example, 'date -d "09:00B" is now equivalent to 9am in UTC+2 time zone.
Previously, military time zones were parsed according to the obsolete
rfc822, with their value negated (e.g., "B" was equivalent to UTC-2).
[The old behavior was introduced in sh-utils 2.0.15 ca. 1999, predating
coreutils package.]
date now pads nanoseconds on the right, not the left. For example,
if the time is currently 1590020079.003388470 seconds after the
Epoch, then "date '+%s.%-N'" formerly output "1590020079.3388470",
and it now outputs "1590020079.00338847".
ls issues an error message on a removed directory, on GNU/Linux systems.
Previously no error and no entries were output, and so indistinguishable
from an empty directory, with default ls options.
uniq no longer uses strcoll() to determine string equivalence,
and so will operate more efficiently and consistently.
** New Features
ls now supports the --time=birth option to display and sort by
file creation time, where available.
od --skip-bytes now can use lseek even if the input is not a regular
file, greatly improving performance in some cases.
stat(1) supports a new --cached= option, used on systems with statx(2)
to control cache coherency of file system attributes,
useful on network file systems.
** Improvements
stat and ls now use the statx() system call where available, which can
operate more efficiently by only retrieving requested attributes.
stat and tail now know about the "binderfs", "dma-buf-fs", "erofs",
"ppc-cmm-fs", and "z3fold" file systems.
stat -f -c%T now reports the file system type, and tail -f uses inotify.
** Build-related
gzip-compressed tarballs are distributed once again
* Noteworthy changes in release 8.31 (2019-03-10) [stable]
** Bug fixes
'base64 a b' now correctly diagnoses 'b' as the extra operand, not 'a'.
[bug introduced in coreutils-5.3.0]
When B already exists, 'cp -il A B' no longer immediately fails
after asking the user whether to proceed.
[This bug was present in "the beginning".]
df no longer corrupts displayed multibyte characters on macOS.
[bug introduced with coreutils-8.18]
seq no longer outputs inconsistent decimal point characters
for the last number, when locales are misconfigured.
[bug introduced in coreutils-7.0]
shred, sort, and split no longer falsely report ftruncate errors
when outputting to less-common file types. For example, the shell
command 'sort /dev/null -o /dev/stdout | cat' no longer fails with
an "error truncating" diagnostic.
[bug was introduced with coreutils-8.18 for sort and split, and
(for shared memory objects only) with fileutils-4.1 for shred]
sync no longer fails for write-only file arguments.
[bug introduced with argument support to sync in coreutils-8.24]
'tail -f file | filter' no longer exits immediately on AIX.
[bug introduced in coreutils-8.28]
'tail -f file | filter' no longer goes into an infinite loop
if filter exits and SIGPIPE is ignored.
[bug introduced in coreutils-8.28]
** Changes in behavior
cksum, dd, hostid, hostname, link, logname, sleep, tsort, unlink,
uptime, users, whoami, yes: now always process --help and --version options,
regardless of any other arguments present before any optional '--'
end-of-options marker.
nohup now processes --help and --version as first options even if other
parameters follow.
'yes a -- b' now outputs 'a b' instead of including the end-of-options
marker as before: 'a -- b'.
echo now always processes backslash escapes when the POSIXLY_CORRECT
environment variable is set.
When possible 'ln A B' now merely links A to B and reports an error
if this fails, instead of statting A and B before linking. This
uses fewer system calls and avoids some races. The old statting
approach is still used in situations where hard links to directories
are allowed (e.g., NetBSD when superuser).
ls --group-directories-first will also group symlinks to directories.
'test -a FILE' is not supported anymore. Long ago, there were concerns about
the high probability of humans confusing the -a primary with the -a binary
operator, so POSIX changed this to 'test -e FILE'. Scripts using it were
already broken and non-portable; the -a unary operator was never documented.
wc now treats non breaking space characters as word delimiters
unless the POSIXLY_CORRECT environment variable is set.
** New features
id now supports specifying multiple users.
'date' now supports the '+' conversion specification flag,
introduced in POSIX.1-2017.
printf, seq, sleep, tail, and timeout now accept floating point
numbers in either the current or the C locale. For example, if the
current locale's decimal point is ',', 'sleep 0,1' and 'sleep 0.1'
now mean the same thing. Previously, these commands accepted only
C-locale syntax with '.' as the decimal point. The new behavior is
more compatible with other implementations in non-C locales.
test now supports the '-N FILE' unary operator (like e.g. bash) to check
whether FILE exists and has been modified since it was last read.
env now supports '--default-signal[=SIG]', '--ignore-signal[=SIG]', and
'--block-signal[=SIG], to setup signal handling before executing a program.
env now supports '--list-signal-handling' to indicate non-default
signal handling before executing a program.
** New commands
basenc is added to complement existing base64,base32 commands,
and encodes and decodes printable text using various common encodings:
base64,base64url,base32,base32hex,base16,base2,z85.
** Improvements
ls -l now better aligns abbreviated months containing digits,
which is common in Asian locales.
stat and tail now know about the "sdcardfs" file system on Android.
stat -f -c%T now reports the file system type, and tail -f uses inotify.
stat now prints file creation time when supported by the file system,
on GNU Linux systems with glibc >= 2.28 and kernel >= 4.11.
* Noteworthy changes in release 8.30 (2018-07-01) [stable]
** Bug fixes
@@ -37,7 +753,7 @@ GNU coreutils NEWS -*- outline -*-
'mv -n A B' no longer suffers from a race condition that can
overwrite a simultaneously-created B. This bug fix requires
platform support for the renameat2 or renameatx_np syscalls, found
in recent Linux and macOS kernels. As a side effect, mv -n A A
in recent Linux and macOS kernels. As a side effect, 'mv -n A A'
now silently does nothing if A exists.
[bug introduced with coreutils-7.1]
@@ -2062,7 +2778,7 @@ GNU coreutils NEWS -*- outline -*-
rm -r --one-file-system works once again.
The rewrite to make rm use fts introduced a regression whereby
a commmand of the above form would fail for all subdirectories.
a command of the above form would fail for all subdirectories.
[bug introduced in coreutils-8.0]
stat -f recognizes more file system types: k-afs, fuseblk, gfs/gfs2, ocfs2,
@@ -2661,7 +3377,7 @@ GNU coreutils NEWS -*- outline -*-
install accepts a new option --strip-program to specify the program used to
strip binaries.
ls now colorizes files with capabilities if libcap is available
ls now colors names of files with capabilities if libcap is available.
ls -v now uses filevercmp function as sort predicate (instead of strverscmp)
@@ -4934,7 +5650,7 @@ packages, see ./old/*/NEWS.
========================================================================
Copyright (C) 2001-2018 Free Software Foundation, Inc.
Copyright (C) 2001-2023 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

158
README
View File

@@ -7,21 +7,22 @@ arbitrary limits.
The programs that can be built with this package are:
[ arch b2sum base32 base64 basename cat chcon chgrp chmod chown chroot cksum
comm coreutils cp csplit cut date dd df dir dircolors dirname du echo env
expand expr factor false fmt fold groups head hostid hostname id install
join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl
nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx pwd
readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum sha384sum
sha512sum shred shuf sleep sort split stat stdbuf stty sum sync tac tail
tee test timeout touch tr true truncate tsort tty uname unexpand uniq
unlink uptime users vdir wc who whoami yes
[ arch b2sum base32 base64 basename basenc cat chcon chgrp chmod chown
chroot cksum comm coreutils cp csplit cut date dd df dir dircolors dirname
du echo env expand expr factor false fmt fold groups head hostid hostname
id install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp
mv nice nl nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx
pwd readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum
sha384sum sha512sum shred shuf sleep sort split stat stdbuf stty sum sync
tac tail tee test timeout touch tr true truncate tsort tty uname unexpand
uniq unlink uptime users vdir wc who whoami yes
See the file NEWS for a list of major changes in the current release.
If you obtained this file as part of a "git clone", then see the
README-hacking file. If this file came to you as part of a tar archive,
then see the file INSTALL for compilation and installation instructions.
then see the file INSTALL for general compilation and installation
instructions, or README-install for system and coreutils specific instructions.
Like the rest of the GNU system, these programs mostly conform to
POSIX, with BSD and other extensions. For closer conformance, or
@@ -57,97 +58,17 @@ files (man/*.x) are welcome. However, the authoritative documentation
is in texinfo form in the doc directory.
*********************
Pre-C99 build failure
---------------------
***************
Feature requests:
---------------
In 2009 we added this requirement:
To build the coreutils from source, you must have a C99-conforming
compiler, due to the use of declarations after non-declaration statements
in several files in src/. There is code in configure to find and, if
possible, enable an appropriate compiler. However, if configure doesn't
find a C99 compiler, it continues nonetheless, and your build will fail.
There used to be a "c99-to-c89.diff" patch you could apply to convert
to code that even an old pre-c99 compiler can handle, but it was too
tedious to maintain, so has been removed.
***********************
HPUX 11.x build failure
-----------------------
A known problem exists when compiling on HPUX on both hppa and ia64
in 64-bit mode (i.e., +DD64) on HP-UX 11.0, 11.11, and 11.23. This
is not due to a bug in the package but instead due to a bug in the
system header file which breaks things in 64-bit mode. The default
compilation mode is 32-bit and the software compiles fine using the
default mode. To build this software in 64-bit mode you will need
to fix the system /usr/include/inttypes.h header file. After
correcting that file the software also compiles fine in 64-bit mode.
Here is one possible patch to correct the problem:
--- /usr/include/inttypes.h.orig Thu May 30 01:00:00 1996
+++ /usr/include/inttypes.h Sun Mar 23 00:20:36 2003
@@ -489 +489 @@
-#ifndef __STDC_32_MODE__
+#ifndef __LP64__
************************
OSF/1 4.0d and AIX build failures
------------------------
If you use /usr/bin/make on these systems, the build will fail due
to the presence of the "[" target. OSF/1 make(1) appears to
treat "[" as some syntax relating to locks, while AIX make(1)
appears to skip the "[" target. To work around these issues
the best solution is to use GNU make. Otherwise, simply remove
all mention of "[$(EXEEXT)" from src/Makefile.
************************
32 bit time_t build failures
------------------------
On systems where it's determined that 64 bit time_t is supported
(indicated by touch -t <some time after 2038>), but that coreutils
would be built with a narrower time_t, the build will fail.
This can be allowed by passing TIME_T_32_BIT_OK=yes to configure,
or avoided by enabling 64 bit builds. For example GCC on AIX defaults
to 32 bit, and to enable the 64 bit ABI one can use:
./configure CFLAGS=-maix64 LDFLAGs=-maix64 AR='ar -X64'
*************************************************
"make check" failure on IRIX 6.5 and Solaris <= 9
-------------------------------------------------
Using the vendor make program to run "make check" fails on these two systems.
If you want to run all of the tests there, use GNU make.
**********************
Running tests as root:
----------------------
If you run the tests as root, note that a few of them create files
and/or run programs as a non-root user, 'nobody' by default.
If you want to use some other non-root username, specify it via
the NON_ROOT_USERNAME environment variable. Depending on the
permissions with which the working directories have been created,
using 'nobody' may fail, because that user won't have the required
read and write access to the build and test directories.
I find that it is best to unpack and build as a non-privileged
user, and then to run the following command as that user in order
to run the privilege-requiring tests:
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
If you can run the tests as root, please do so and report any
problems. We get much less test coverage in that mode, and it's
arguably more important that these tools work well when run by
root than when run by less privileged users.
If you would like to add a new feature, please try to get some sort of
consensus that it is a worthwhile change. One way to do that is to send
mail to coreutils@gnu.org including as much description and justification
as you can. Based on the feedback that generates, you may be able to
convince us that it's worth adding. Please also consult the list of
previously discussed but ultimately rejected feature requests at:
https://www.gnu.org/software/coreutils/rejected_requests.html
***************
@@ -157,8 +78,12 @@ Reporting bugs:
Send bug reports, questions, comments, etc. to bug-coreutils@gnu.org.
To suggest a patch, see the files README-hacking and HACKING for tips.
All of these programs except 'test' recognize the '--version' option.
When reporting bugs, please include in the subject line both the package
name/version and the name of the program for which you found a problem.
If you have a problem with 'sort', try running 'sort --debug', as it
can can often help find and fix problems without having to wait for an
can often help find and fix problems without having to wait for an
answer to a bug report. If the debug output does not suffice to fix
the problem on your own, please compress and attach it to the rest of
your bug report.
@@ -181,7 +106,7 @@ There are many tests, but nowhere near as many as we need.
Additions and corrections are very welcome.
If you see a problem that you've already reported, feel free to re-report
it -- it won't bother me to get a reminder. Besides, the more messages I
it -- it won't bother us to get a reminder. Besides, the more messages we
get regarding a particular problem the sooner it'll be fixed -- usually.
If you sent a complete patch and, after a couple weeks you haven't
received any acknowledgement, please ping us. A complete patch includes
@@ -195,30 +120,6 @@ Here are instructions for checking out the latest development sources:
https://savannah.gnu.org/git/?group=coreutils
If your patch adds a new feature, please try to get some sort of consensus
that it is a worthwhile change. One way to do that is to send mail to
coreutils@gnu.org including as much description and justification
as you can. Based on the feedback that generates, you may be able to
convince us that it's worth adding. Please also consult the list of
previously discussed but ultimately rejected feature requests at:
https://www.gnu.org/software/coreutils/rejected_requests.html
WARNING: Now that we use the ./bootstrap script, you should not run
autoreconf manually. Doing that will overwrite essential source files
with older versions, which may make the package unbuildable or introduce
subtle bugs.
WARNING: If you modify files like configure.in, m4/*.m4, aclocal.m4,
or any Makefile.am, then don't be surprised if what gets regenerated no
longer works. To make things work, you'll have to be using appropriate
versions of the tools listed in bootstrap.conf's buildreq string.
All of these programs except 'test' recognize the '--version' option.
When reporting bugs, please include in the subject line both the package
name/version and the name of the program for which you found a problem.
For general documentation on the coding and usage standards
this distribution follows, see the GNU Coding Standards at:
https://www.gnu.org/prep/standards/
@@ -226,13 +127,10 @@ https://www.gnu.org/prep/standards/
For any copyright year range specified as YYYY-ZZZZ in this package
note that the range specifies every single year in that closed interval.
Mail suggestions and bug reports for these programs to
the address on the last line of --help output.
========================================================================
Copyright (C) 1998-2018 Free Software Foundation, Inc.
Copyright (C) 1998-2023 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -1,36 +1,47 @@
-*- outline -*-
Building from a Git repository -*- outline -*-
These notes intend to help people working on the checked-out sources.
These requirements do not apply when building from a distribution tarball.
See also HACKING for more detailed contribution guidelines.
If this package has a file HACKING, please also read that file for
more detailed contribution guidelines.
* Requirements
We've opted to keep only the highest-level sources in the GIT repository.
This eases our maintenance burden, (fewer merges etc.), but imposes more
We've opted to keep only the highest-level sources in the Git repository.
This eases our maintenance burden (fewer merges etc.), but imposes more
requirements on anyone wishing to build from the just-checked-out sources.
Note the requirements to build the released archive are much less and
are just the requirements of the standard ./configure && make procedure.
(The requirements to build from a release are much less and are just
the requirements of the standard './configure && make' procedure.)
Specific development tools and versions will be checked for and listed by
the bootstrap script. See README-prereq for specific notes on obtaining
these prerequisite tools.
Valgrind <http://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture. See also README-valgrind.
Valgrind <https://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture. See also README-valgrind
(if present).
While building from a just-cloned source tree may require installing a
few prerequisites, later, a plain 'git pull && make' should be sufficient.
few prerequisites, later, a plain 'git pull && make' typically suffices.
* First GIT checkout
* First Git checkout
You can get a copy of the source repository like this:
$ git clone git://git.sv.gnu.org/coreutils
$ cd coreutils
$ git clone https://git.savannah.gnu.org/git/<packagename>
$ cd <packagename>
As an optional step, if you already have a copy of the gnulib git
where '<packagename>' stands for 'coreutils' or whatever other package
you are building.
To use the most-recent Gnulib (as opposed to the Gnulib version that
the package last synchronized to), do this next:
$ git submodule foreach git pull origin master
$ git commit -m 'build: update gnulib submodule to latest' gnulib
As an optional step, if you already have a copy of the Gnulib Git
repository, then you can use it as a reference to reduce download
time and disk space requirements:
time and file system space requirements:
$ export GNULIB_SRCDIR=/path/to/gnulib
@@ -39,20 +50,14 @@ which are extracted from other source packages:
$ ./bootstrap
To use the most-recent gnulib (as opposed to the gnulib version that
the package last synchronized to), do this next:
$ git submodule foreach git pull origin master
$ git commit -m 'build: update gnulib submodule to latest' gnulib
And there you are! Just
$ ./configure --quiet #[--enable-gcc-warnings] [*]
$ ./configure --quiet #[--disable-gcc-warnings] [*]
$ make
$ make check
At this point, there should be no difference between your local copy,
and the GIT master copy:
and the Git master copy:
$ git diff
@@ -60,12 +65,15 @@ should output no difference.
Enjoy!
[*] The --enable-gcc-warnings option is useful only with glibc
and with a very recent version of gcc. You'll probably also have
to use recent system headers. If you configure with this option,
and spot a problem, please be sure to send the report to the bug
reporting address of this package, and not to that of gnulib, even
if the problem seems to originate in a gnulib-provided file.
[*] By default GCC warnings are enabled when building from Git.
If you get warnings with recent GCC and Glibc with default
configure-time options, please report the warnings to the bug
reporting address of this package instead of to bug-gnulib,
even if the problem seems to originate in a Gnulib-provided file.
If you get warnings with other configurations, you can run
'./configure --disable-gcc-warnings' or 'make WERROR_CFLAGS='
to build quietly or verbosely, respectively.
-----
* Submitting patches
@@ -93,7 +101,7 @@ each program. One way to do this is to use vc-dwim
-----
Copyright (C) 2002-2018 Free Software Foundation, Inc.
Copyright (C) 2002-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

111
README-install Normal file
View File

@@ -0,0 +1,111 @@
Please see the file INSTALL for generic build and installation instructions.
This file details coreutils and system specific build instructions.
*********************
Pre-C99 build failure
---------------------
In 2009 we added this requirement:
To build the coreutils from source, you must have a C99-conforming
compiler, due to the use of declarations after non-declaration statements
in several files in src/. There is code in configure to find and, if
possible, enable an appropriate compiler. However, if configure doesn't
find a C99 compiler, it continues nonetheless, and your build will fail.
There used to be a "c99-to-c89.diff" patch you could apply to convert
to code that even an old pre-c99 compiler can handle, but it was too
tedious to maintain, so has been removed.
***********************
HPUX 11.x build failure
-----------------------
A known problem exists when compiling on HPUX on both hppa and ia64
in 64-bit mode (i.e., +DD64) on HP-UX 11.0, 11.11, and 11.23. This
is not due to a bug in the package but instead due to a bug in the
system header file which breaks things in 64-bit mode. The default
compilation mode is 32-bit and the software compiles fine using the
default mode. To build this software in 64-bit mode you will need
to fix the system /usr/include/inttypes.h header file. After
correcting that file the software also compiles fine in 64-bit mode.
Here is one possible patch to correct the problem:
--- /usr/include/inttypes.h.orig Thu May 30 01:00:00 1996
+++ /usr/include/inttypes.h Sun Mar 23 00:20:36 2003
@@ -489 +489 @@
-#ifndef __STDC_32_MODE__
+#ifndef __LP64__
************************
OSF/1 4.0d and AIX build failures
------------------------
If you use /usr/bin/make on these systems, the build will fail due
to the presence of the "[" target. OSF/1 make(1) appears to
treat "[" as some syntax relating to locks, while AIX make(1)
appears to skip the "[" target. To work around these issues
the best solution is to use GNU make. Otherwise, simply remove
all mention of "[$(EXEEXT)" from src/Makefile.
************************
32 bit time_t build failures
------------------------
Although 32-bit builds fail if that forces time_t to be 32 bits, this
can be fixed by using 64-bit builds. For example, on AIX where GCC
defaults to 32 bits, one can use "./configure CC='gcc -maix64' AR='ar
-X64'"; similarly, on Solaris one can configure with CC='gcc -m64'.
If all else fails one can configure with ac_year2038_required=no;
however, this will mishandle timestamps after 2038, and please file
bug reports for any such situations.
*************************************************
"make check" failure on IRIX 6.5 and Solaris <= 9
-------------------------------------------------
Using the vendor make program to run "make check" fails on these two systems.
If you want to run all of the tests there, use GNU make.
**********************
Running tests as root:
----------------------
If you run the tests as root, note that a few of them create files
and/or run programs as a non-root user, 'nobody' by default.
If you want to use some other non-root username, specify it via
the NON_ROOT_USERNAME environment variable. Depending on the
permissions with which the working directories have been created,
using 'nobody' may fail, because that user won't have the required
read and write access to the build and test directories.
I find that it is best to unpack and build as a non-privileged
user, and then to run the following command as that user in order
to run the privilege-requiring tests:
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
If you can run the tests as root, please do so and report any
problems. We get much less test coverage in that mode, and it's
arguably more important that these tools work well when run by
root than when run by less privileged users.
**********************
autotools considerations:
----------------------
WARNING: Now that we use the ./bootstrap script, you should not run
autoreconf manually. Doing that will overwrite essential source files
with older versions, which may make the package unbuildable or introduce
subtle bugs.
WARNING: If you modify files like configure.in, m4/*.m4, aclocal.m4,
or any Makefile.am, then don't be surprised if what gets regenerated no
longer works. To make things work, you'll have to be using appropriate
versions of the tools listed in bootstrap.conf's buildreq string.

View File

@@ -1,64 +1,41 @@
This gives some notes on obtaining the tools required for development.
I.e., the tools checked for by the bootstrap script and include:
These tools can be used by the 'bootstrap' and 'configure' scripts,
as well as by 'make'. They include:
- Autoconf <https://www.gnu.org/software/autoconf/>
- Automake <https://www.gnu.org/software/automake/>
- Bison <https://www.gnu.org/software/bison/>
- Gettext <https://www.gnu.org/software/gettext/>
- Git <https://git-scm.com/>
- Gperf <https://www.gnu.org/software/gperf/>
- Gzip <https://www.gnu.org/software/gzip/>
- Perl <https://www.cpan.org/>
- Rsync <https://rsync.samba.org/>
- Tar <https://www.gnu.org/software/tar/>
- Texinfo <https://www.gnu.org/software/texinfo/>
- Autoconf <https://www.gnu.org/software/autoconf/>
- Automake <https://www.gnu.org/software/automake/>
- Bison <https://www.gnu.org/software/bison/>
- Gettext <https://www.gnu.org/software/gettext/>
- Git <https://git-scm.com/>
- Gperf <https://www.gnu.org/software/gperf/>
- Gzip <https://www.gnu.org/software/gzip/>
- Help2man <https://www.gnu.org/software/help2man/>
- M4 <https://www.gnu.org/software/m4/>
- Make <https://www.gnu.org/software/make/>
- Perl <https://www.cpan.org/>
- Tar <https://www.gnu.org/software/tar/>
- Texinfo <https://www.gnu.org/software/texinfo/>
- Wget <https://www.gnu.org/software/wget/>
- XZ Utils <https://tukaani.org/xz/>
Note please try to install/build official packages for your system.
If these programs are not available use the following instructions
to build them and install the results into a directory that you will
then use when building this package.
It is generally better to use official packages for your system.
If a package is not officially available you can build it from source
and install it into a directory that you can then use to build this
package. If some packages are available but are too old, install the
too-old versions first as they may be needed to build newer versions.
Even if the official version of a package for your system is too old,
please install it, as it may be required to build the newer versions.
The examples below install into $HOME/coreutils/deps/, so if you are
going to follow these instructions, first ensure that your $PATH is
set correctly by running this command:
Here is an example of how to build a program from source. This
example is for Autoconf; a similar approach should work for the other
developer prerequisites. This example assumes Autoconf 2.71; it
should be OK to use a later version of Autoconf, if available.
prefix=$HOME/coreutils/deps
prefix=$HOME/prefix # (or wherever else you choose)
export PATH=$prefix/bin:$PATH
* autoconf *
# Note Autoconf 2.62 or newer is needed to build automake-1.11.2
# but we specify 2.64 here as that's what coreutils requires.
# Please use the latest stable release version as indicated by git tags.
git clone --depth=1 git://git.sv.gnu.org/autoconf.git
cd autoconf
git checkout v2.64
autoreconf -vi
wget https://ftp.gnu.org/pub/gnu/autoconf/autoconf-2.71.tar.gz
gzip -d <autoconf-2.71.tar.gz | tar xf -
cd autoconf-2.71
./configure --prefix=$prefix
make install
* automake *
# Note help2man is required to build automake fully
git clone git://git.sv.gnu.org/automake.git
cd automake
git checkout v1.11.2
./bootstrap
./configure --prefix=$prefix
make install
This package uses XZ utils (successor to LZMA) to create
a compressed distribution tarball. Using this feature of Automake
requires version 1.10a or newer, as well as the xz program itself.
* xz *
git clone git://ctrl.tukaani.org/xz.git
cd xz
./autogen.sh
./configure --prefix=$prefix
make install
Now you can build this package as described in README-hacking.
Once the prerequisites are installed, you can build this package as
described in README-hacking.

View File

@@ -1,7 +1,7 @@
#! /bin/bash
# Convert this package for use with valgrind.
# Copyright (C) 2002-2018 Free Software Foundation, Inc.
# Copyright (C) 2002-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -25,7 +25,6 @@ Adam Klein aklein@debian.org
Adam Sampson ats@offog.org
Adrian Bunk bunk@stusta.de
AIDA Shinra shinra@j10n.org
Akim Demaille demaille@inf.enst.fr
Alain Magloire alain@qnx.com
Alan Iwi iwi@atm.ox.ac.uk
Alan Jenkins alan-jenkins@tuffmail.co.uk
@@ -133,7 +132,7 @@ Clark Morgan cmorgan@aracnet.com
Clement Wang clem.wang@overture.com
Colin Plumb colin@nyx.net
Collin Rogowski collin@rogowski.de
Cray-Cyber Project http://www.cray-cyber.org
Cray-Cyber Project https://www.cray-cyber.org
Cristian Cadar cristic@stanford.edu
Cyril Bouthors cyril@bouthors.org
Dale Scheetz dwarf@polaris.net
@@ -161,6 +160,7 @@ David Luyer david_luyer@pacific.net.au
David Madore david.madore@ens.fr
David Malone dwmalone@cnri.dit.ie
David Matei matei@cs.toronto.edu
David Pinto carandraug+dev@gmail.com
Davide Canova kc.canova@gmail.com
Dawson Engler engler@stanford.edu
Dean Gaudet dean-savannah@arctic.org
@@ -189,6 +189,7 @@ Eivind eivindt@multinet.no
Elbert Pol elbert.pol@gmail.com
Eldon Stegall eldon@eldondev.com
Eli Zaretskii eliz@is.elta.co.il
Emanuel Landeholm emanuel.landeholm@gmail.com
Emile LeBlanc leblanc@math.toronto.edu
Emmanuel Lacour elacour@home-dn.net
Eric Backus ericb@lsid.hp.com
@@ -229,6 +230,7 @@ Gerald Pfeifer gerald@pfeifer.com
Gerhard Poul gpoul@gnu.org
Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp
Glen Lenker glen.lenker@gmail.com
Glenn Golden gdg@zplane.com
GOTO Masanori gotom@debian.or.jp
Greg Louis glouis@dynamicro.on.ca
Greg McGary gkm@gnu.org
@@ -280,7 +282,6 @@ Jamie McClelland jm@mayfirst.org
Jan Engelhardt jengelh@medozas.de
Jan Fedak J.Fedak@sh.cvut.cz
Jan Moringen jan.moringen@uni-bielefeld.de
Jan Nieuwenhuizen janneke@gnu.org
Janos Farkas chexum@shadow.banki.hu
Jan-Pawel Wrozstinski jpwroz@gmail.com
Jari Aalto jari.aalto@cante.net
@@ -311,6 +312,7 @@ Joerg Sonnenberger joerg@britannica.bec.de
Joey Hess joeyh@debian.org
Johan Boule bohan@bohan.dyndns.org
Johan Danielsson joda@pdc.kth.se
Johannes Altmanninger aclopte@gmail.com
John Bley jbb6@acpub.duke.edu
John Gatewood Ham zappaman@alphabox.compsci.buu.ac.th
John Gotts jgotts@umich.edu
@@ -421,6 +423,7 @@ Matthew Arnison maffew@cat.org.au
Matthew Braun matthew@ans.net
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
Matthew M. Boedicker matthewm@boedicker.org
Matthew Pfeiffer spferical@gmail.com
Matthew S. Levine mslevine@theory.lcs.mit.edu
Matthew Smith matts@bluesguitar.org
Matthew Swift swift@alum.mit.edu
@@ -641,7 +644,6 @@ Ulrich Hermisson ulrich_hermisson@hotmail.com
Urs Thuermann urs@isnogud.escape.de
Uwe H. Steinfeld usteinfeld@gmx.net
Vesselin Atanasov vesselin@bgnet.bg
Ville Skyttä ville.skytta@iki.fi
Vin Shelton acs@alumni.princeton.edu
Vineet Chadha chadha@acis.ufl.edu
Vitali Lovich vlovich@gmail.com

4
TODO
View File

@@ -49,7 +49,7 @@ no longer incurs the overhead of saving src. dev/ino and dest. filename
in the hash table.
Write an autoconf test to work around build failure in HPUX's 64-bit mode.
See notes in README -- and remove them once there's a work-around.
See notes in README-install -- and remove them once there's a work-around.
Integrate use of sendfile, suggested here:
https://lists.gnu.org/r/bug-fileutils/2003-03/msg00030.html
@@ -143,7 +143,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
-----
Copyright (C) 2002-2018 Free Software Foundation, Inc.
Copyright (C) 2002-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

591
bootstrap
View File

@@ -1,10 +1,10 @@
#! /bin/sh
# Print a version string.
scriptversion=2017-09-19.08; # UTC
scriptversion=2022-06-04.00; # UTC
# Bootstrap this package from checked-out sources.
# Copyright (C) 2003-2018 Free Software Foundation, Inc.
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -47,6 +47,8 @@ PERL="${PERL-perl}"
me=$0
default_gnulib_url=https://git.savannah.gnu.org/git/gnulib.git
usage() {
cat <<EOF
Usage: $me [OPTION]...
@@ -69,17 +71,56 @@ Options:
--no-git do not use git to update gnulib. Requires that
--gnulib-srcdir point to a correct gnulib snapshot
--skip-po do not download po files
EOF
bootstrap_print_option_usage_hook
cat <<EOF
If the file $me.conf exists in the same directory as this script, its
contents are read as shell variables to configure the bootstrap.
For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
are honored.
Gnulib sources can be fetched in various ways:
* If this package is in a git repository with a 'gnulib' submodule
configured, then that submodule is initialized and updated and sources
are fetched from there. If \$GNULIB_SRCDIR is set (directly or via
--gnulib-srcdir) and is a git repository, then it is used as a reference.
* Otherwise, if \$GNULIB_SRCDIR is set (directly or via --gnulib-srcdir),
then sources are fetched from that local directory. If it is a git
repository and \$GNULIB_REVISION is set, then that revision is checked
out.
* Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated and
sources are fetched from there.
* Otherwise, if the 'gnulib' directory does not exist, Gnulib sources are
cloned into that directory using git from \$GNULIB_URL, defaulting to
$default_gnulib_url.
If \$GNULIB_REVISION is set, then that revision is checked out.
* Otherwise, the existing Gnulib sources in the 'gnulib' directory are
used. If it is a git repository and \$GNULIB_REVISION is set, then that
revision is checked out.
If you maintain a package and want to pin a particular revision of the
Gnulib sources that has been tested with your package, then there are two
possible approaches: either configure a 'gnulib' submodule with the
appropriate revision, or set \$GNULIB_REVISION (and if necessary
\$GNULIB_URL) in $me.conf.
Running without arguments will suffice in most cases.
EOF
}
copyright_year=`echo "$scriptversion" | sed -e 's/[^0-9].*//'`
copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."
# warnf_ FORMAT-STRING ARG1...
warnf_ ()
{
@@ -121,6 +162,18 @@ gnulib_files=
: ${AUTOPOINT=autopoint}
: ${AUTORECONF=autoreconf}
# A function to be called for each unrecognized option. Returns 0 if
# the option in $1 has been processed by the function. Returns 1 if
# the option has not been processed by the function. Override it via
# your own definition in bootstrap.conf
bootstrap_option_hook() { return 1; }
# A function to be called in order to print the --help information
# corresponding to user-defined command-line options.
bootstrap_print_option_usage_hook() { :; }
# A function to be called right after gnulib-tool is run.
# Override it via your own definition in bootstrap.conf.
bootstrap_post_import_hook() { :; }
@@ -129,22 +182,15 @@ bootstrap_post_import_hook() { :; }
# Override it via your own definition in bootstrap.conf.
bootstrap_epilogue() { :; }
# The command to download all .po files for a specified domain into
# a specified directory. Fill in the first %s is the domain name, and
# the second with the destination directory. Use rsync's -L and -r
# options because the latest/%s directory and the .po files within are
# all symlinks.
# The command to download all .po files for a specified domain into a
# specified directory. Fill in the first %s with the destination
# directory and the second with the domain name.
po_download_command_format=\
"rsync --delete --exclude '*.s1' -Lrtvz \
'translationproject.org::tp/latest/%s/' '%s'"
# Fallback for downloading .po files (if rsync fails).
po_download_command_format2=\
"wget --mirror -nd -q -np -A.po -P '%s' \
"wget --mirror --level=1 -nd -nv -A.po -P '%s' \
https://translationproject.org/latest/%s/"
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
# fall back to the package name (1st argument with munging)
# fall back to the package name (1st argument with munging).
extract_package_name='
/^AC_INIT(\[*/{
s///
@@ -161,8 +207,11 @@ extract_package_name='
p
}
'
package=$(sed -n "$extract_package_name" configure.ac) \
|| die 'cannot find package name in configure.ac'
package=$(${AUTOCONF:-autoconf} --trace AC_INIT:\$4 configure.ac 2>/dev/null)
if test -z "$package"; then
package=$(sed -n "$extract_package_name" configure.ac) \
|| die 'cannot find package name in configure.ac'
fi
gnulib_name=lib$package
build_aux=build-aux
@@ -170,7 +219,15 @@ source_base=lib
m4_base=m4
doc_base=doc
tests_base=tests
gnulib_extra_files=''
gnulib_extra_files="
build-aux/install-sh
build-aux/mdate-sh
build-aux/texinfo.tex
build-aux/depcomp
build-aux/config.guess
build-aux/config.sub
doc/INSTALL
"
# Additional gnulib-tool options to use. Use "\newline" to break lines.
gnulib_tool_option_extras=
@@ -256,68 +313,6 @@ find_tool ()
eval "export $find_tool_envvar"
}
# Override the default configuration, if necessary.
# Make sure that bootstrap.conf is sourced from the current directory
# if we were invoked as "sh bootstrap".
case "$0" in
*/*) test -r "$0.conf" && . "$0.conf" ;;
*) test -r "$0.conf" && . ./"$0.conf" ;;
esac
# Extra files from gnulib, which override files from other sources.
test -z "${gnulib_extra_files}" && \
gnulib_extra_files="
build-aux/install-sh
build-aux/mdate-sh
build-aux/texinfo.tex
build-aux/depcomp
build-aux/config.guess
build-aux/config.sub
doc/INSTALL
"
if test "$vc_ignore" = auto; then
vc_ignore=
test -d .git && vc_ignore=.gitignore
test -d CVS && vc_ignore="$vc_ignore .cvsignore"
fi
# Translate configuration into internal form.
# Parse options.
for option
do
case $option in
--help)
usage
exit;;
--gnulib-srcdir=*)
GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
--skip-po)
SKIP_PO=t;;
--force)
checkout_only_file=;;
--copy)
copy=true;;
--bootstrap-sync)
bootstrap_sync=true;;
--no-bootstrap-sync)
bootstrap_sync=false;;
--no-git)
use_git=false;;
*)
die "$option: unknown option";;
esac
done
$use_git || test -d "$GNULIB_SRCDIR" \
|| die "Error: --no-git requires --gnulib-srcdir"
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
die "Bootstrapping from a non-checked-out distribution is risky."
fi
# Strip blank and comment lines to leave significant entries.
gitignore_entries() {
sed '/^#/d; /^$/d' "$@"
@@ -359,9 +354,140 @@ insert_vc_ignore() {
insert_if_absent "$vc_ignore_file" "$pattern"
}
symlink_to_dir()
{
src=$1/$2
dst=${3-$2}
test -f "$src" && {
# If the destination directory doesn't exist, create it.
# This is required at least for "lib/uniwidth/cjk.h".
dst_dir=$(dirname "$dst")
if ! test -d "$dst_dir"; then
mkdir -p "$dst_dir"
# If we've just created a directory like lib/uniwidth,
# tell version control system(s) it's ignorable.
# FIXME: for now, this does only one level
parent=$(dirname "$dst_dir")
for dot_ig in x $vc_ignore; do
test $dot_ig = x && continue
ig=$parent/$dot_ig
insert_vc_ignore $ig "${dst_dir##*/}"
done
fi
if $copy; then
{
test ! -h "$dst" || {
echo "$me: rm -f $dst" &&
rm -f "$dst"
}
} &&
test -f "$dst" &&
cmp -s "$src" "$dst" || {
echo "$me: cp -fp $src $dst" &&
cp -fp "$src" "$dst"
}
else
# Leave any existing symlink alone, if it already points to the source,
# so that broken build tools that care about symlink times
# aren't confused into doing unnecessary builds. Conversely, if the
# existing symlink's timestamp is older than the source, make it afresh,
# so that broken tools aren't confused into skipping needed builds. See
# <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>.
test -h "$dst" &&
src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
test "$src_i" = "$dst_i" &&
both_ls=$(ls -dt "$src" "$dst") &&
test "X$both_ls" = "X$dst$nl$src" || {
dot_dots=
case $src in
/*) ;;
*)
case /$dst/ in
*//* | */../* | */./* | /*/*/*/*/*/)
die "invalid symlink calculation: $src -> $dst";;
/*/*/*/*/) dot_dots=../../../;;
/*/*/*/) dot_dots=../../;;
/*/*/) dot_dots=../;;
esac;;
esac
echo "$me: ln -fs $dot_dots$src $dst" &&
ln -fs "$dot_dots$src" "$dst"
}
fi
}
}
# Override the default configuration, if necessary.
# Make sure that bootstrap.conf is sourced from the current directory
# if we were invoked as "sh bootstrap".
case "$0" in
*/*) test -r "$0.conf" && . "$0.conf" ;;
*) test -r "$0.conf" && . ./"$0.conf" ;;
esac
if test "$vc_ignore" = auto; then
vc_ignore=
test -d .git && vc_ignore=.gitignore
test -d CVS && vc_ignore="$vc_ignore .cvsignore"
fi
if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
use_gnulib=false
else
use_gnulib=true
fi
# Translate configuration into internal form.
# Parse options.
for option
do
case $option in
--help)
usage
exit;;
--version)
set -e
echo "bootstrap $scriptversion"
echo "$copyright"
exit 0
;;
--gnulib-srcdir=*)
GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
--skip-po)
SKIP_PO=t;;
--force)
checkout_only_file=;;
--copy)
copy=true;;
--bootstrap-sync)
bootstrap_sync=true;;
--no-bootstrap-sync)
bootstrap_sync=false;;
--no-git)
use_git=false;;
*)
bootstrap_option_hook $option || die "$option: unknown option";;
esac
done
$use_git || test -d "$GNULIB_SRCDIR" \
|| die "Error: --no-git requires --gnulib-srcdir"
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
die "Bootstrapping from a non-checked-out distribution is risky."
fi
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
found_aux_dir=no
grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'])' configure.ac \
>/dev/null && found_aux_dir=yes
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
>/dev/null && found_aux_dir=yes
@@ -612,95 +738,118 @@ git_modules_config () {
test -f .gitmodules && git config --file .gitmodules "$@"
}
if $use_git; then
gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
fi
# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
# submodule, for use in the rest of the script.
case ${GNULIB_SRCDIR--} in
-)
# Note that $use_git is necessarily true in this case.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib 1 2 13 15
shallow=
git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
cleanup_gnulib
trap - 1 2 13 15
if $use_gnulib; then
if $use_git; then
gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
fi
GNULIB_SRCDIR=$gnulib_path
;;
*)
# Use GNULIB_SRCDIR directly or as a reference.
if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
git submodule update -- "$gnulib_path" || exit $?
# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
# submodule, for use in the rest of the script.
case ${GNULIB_SRCDIR--} in
-)
# Note that $use_git is necessarily true in this case.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib 1 2 13 15
shallow=
if test -z "$GNULIB_REVISION"; then
git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \
|| cleanup_gnulib
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_SRCDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init -- "$gnulib_path" \
&& git submodule update -- "$gnulib_path" \
|| exit $?
git fetch -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
mkdir -p "$gnulib_path"
# Only want a shallow checkout of $GNULIB_REVISION, but git does not
# support cloning by commit hash. So attempt a shallow fetch by commit
# hash to minimize the amount of data downloaded and changes needed to
# be processed, which can drastically reduce download and processing
# time for checkout. If the fetch by commit fails, a shallow fetch can
# not be performed because we do not know what the depth of the commit
# is without fetching all commits. So fallback to fetching all commits.
git -C "$gnulib_path" init
git -C "$gnulib_path" remote add origin \
${GNULIB_URL:-$default_gnulib_url}
git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
|| git -C "$gnulib_path" fetch origin \
|| cleanup_gnulib
git -C "$gnulib_path" reset --hard FETCH_HEAD
fi
trap - 1 2 13 15
fi
GNULIB_SRCDIR=$gnulib_path
;;
*)
# Use GNULIB_SRCDIR directly or as a reference.
if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
git submodule update -- "$gnulib_path" || exit $?
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_SRCDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init -- "$gnulib_path" \
&& git submodule update -- "$gnulib_path" \
|| exit $?
fi
fi
GNULIB_SRCDIR=$gnulib_path
fi
;;
esac
if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \
&& ! git_modules_config submodule.gnulib.url >/dev/null; then
(cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib
fi
;;
esac
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..."
case $(sh -c 'echo "$1"' -- a) in
a) ignored=--;;
*) ignored=ignored;;
esac
exec sh -c \
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
$ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
"$0" "$@" --no-bootstrap-sync
}
if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..."
case $(sh -c 'echo "$1"' -- a) in
a) ignored=--;;
*) ignored=ignored;;
esac
exec sh -c \
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
$ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
"$0" "$@" --no-bootstrap-sync
}
fi
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit $?
fi
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit $?
# Get translations.
download_po_files() {
subdir=$1
domain=$2
echo "$me: getting translations into $subdir for $domain..."
cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
eval "$cmd" && return
# Fallback to HTTPS.
cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
eval "$cmd"
}
@@ -750,75 +899,6 @@ case $SKIP_PO in
fi;;
esac
symlink_to_dir()
{
src=$1/$2
dst=${3-$2}
test -f "$src" && {
# If the destination directory doesn't exist, create it.
# This is required at least for "lib/uniwidth/cjk.h".
dst_dir=$(dirname "$dst")
if ! test -d "$dst_dir"; then
mkdir -p "$dst_dir"
# If we've just created a directory like lib/uniwidth,
# tell version control system(s) it's ignorable.
# FIXME: for now, this does only one level
parent=$(dirname "$dst_dir")
for dot_ig in x $vc_ignore; do
test $dot_ig = x && continue
ig=$parent/$dot_ig
insert_vc_ignore $ig "${dst_dir##*/}"
done
fi
if $copy; then
{
test ! -h "$dst" || {
echo "$me: rm -f $dst" &&
rm -f "$dst"
}
} &&
test -f "$dst" &&
cmp -s "$src" "$dst" || {
echo "$me: cp -fp $src $dst" &&
cp -fp "$src" "$dst"
}
else
# Leave any existing symlink alone, if it already points to the source,
# so that broken build tools that care about symlink times
# aren't confused into doing unnecessary builds. Conversely, if the
# existing symlink's timestamp is older than the source, make it afresh,
# so that broken tools aren't confused into skipping needed builds. See
# <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>.
test -h "$dst" &&
src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
test "$src_i" = "$dst_i" &&
both_ls=$(ls -dt "$src" "$dst") &&
test "X$both_ls" = "X$dst$nl$src" || {
dot_dots=
case $src in
/*) ;;
*)
case /$dst/ in
*//* | */../* | */./* | /*/*/*/*/*/)
die "invalid symlink calculation: $src -> $dst";;
/*/*/*/*/) dot_dots=../../../;;
/*/*/*/) dot_dots=../../;;
/*/*/) dot_dots=../;;
esac;;
esac
echo "$me: ln -fs $dot_dots$src $dst" &&
ln -fs "$dot_dots$src" "$dst"
}
fi
}
}
version_controlled_file() {
parent=$1
file=$2
@@ -898,36 +978,47 @@ fi
# Import from gnulib.
gnulib_tool_options="\
--import\
--no-changelog\
--aux-dir $build_aux\
--doc-base $doc_base\
--lib $gnulib_name\
--m4-base $m4_base/\
--source-base $source_base/\
--tests-base $tests_base\
--local-dir $local_gl_dir\
$gnulib_tool_option_extras\
"
if test $use_libtool = 1; then
case "$gnulib_tool_options " in
*' --libtool '*) ;;
*) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
esac
fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
if $use_gnulib; then
gnulib_tool_options="\
--no-changelog\
--aux-dir=$build_aux\
--doc-base=$doc_base\
--lib=$gnulib_name\
--m4-base=$m4_base/\
--source-base=$source_base/\
--tests-base=$tests_base\
--local-dir=$local_gl_dir\
$gnulib_tool_option_extras\
"
if test $use_libtool = 1; then
case "$gnulib_tool_options " in
*' --libtool '*) ;;
*) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
esac
fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
done
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
done
fi
bootstrap_post_import_hook \
|| die "bootstrap_post_import_hook failed"
# Don't proceed if there are uninitialized submodules. In particular,
# the next step will remove dangling links, which might be links into
# uninitialized submodules.
#
# Uninitialized submodules are listed with an initial dash.
if $use_git && git submodule | grep '^-' >/dev/null; then
die "some git submodules are not initialized. " \
"Run 'git submodule update --init' and bootstrap again."
fi
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
# The following requires GNU find 4.2.3 or newer. Considering the usual
@@ -1019,8 +1110,8 @@ bootstrap_epilogue
echo "$0: done. Now you can run './configure'."
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# Local Variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Copyright (C) 2006-2018 Free Software Foundation, Inc.
# Copyright (C) 2006-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,40 +26,50 @@ avoided_gnulib_modules='
gnulib_modules="
$avoided_gnulib_modules
acl
alignof
alignalloc
alignasof
alloca
announce-gen
areadlink-with-size
areadlinkat-with-size
argmatch
argv-iter
assert
assert-h
attribute
autobuild
backupfile
backup-rename
base32
base64
btowc
buffer-lcm
byteswap
c-strcase
c-strtod
c-strtold
cl-strtod
cl-strtold
calloc-gnu
canon-host
canonicalize
chmodat
chown
chownat
cloexec
closein
closeout
config-h
configmake
copy-file-range
count-leading-zeros
crypto/md5
crypto/sha1
crypto/sha256
crypto/sha512
crypto/sm3
cycle-check
d-ino
d-type
di-set
diacrit
dirfd
dirname
do-release-commit-and-tag
@@ -81,7 +91,6 @@ gnulib_modules="
fcntl-safer
fd-reopen
fdatasync
fdl
fdopen
fdutimensat
file-has-acl
@@ -94,6 +103,7 @@ gnulib_modules="
fnmatch-gnu
fopen-safer
fprintftime
free-posix
freopen
freopen-safer
fseeko
@@ -116,7 +126,7 @@ gnulib_modules="
getpass-gnu
gettext-h
gettime
gettimeofday
gettime-res
getugroups
getusershell
git-version-gen
@@ -128,11 +138,12 @@ gnulib_modules="
group-member
hard-locale
hash
hash-pjw
hash-triple
heap
host-os
human
idcache
idx
ignore-value
inttostr
inttypes
@@ -144,6 +155,7 @@ gnulib_modules="
lchown
ldtoastr
lib-ignore
libgmp
linebuffer
link
link-follow
@@ -164,11 +176,14 @@ gnulib_modules="
memcmp2
mempcpy
memrchr
minmax
mgetgroups
mkancesdirs
mkdir
mkdir-p
mkdirat
mkfifo
mkfifoat
mknod
mkostemp
mkstemp
@@ -177,12 +192,13 @@ gnulib_modules="
mountlist
mpsort
netinet_in
non-recursive-gnulib-prefix-hack
nproc
nstrftime
obstack
open
openat-safer
parse-datetime
parse-datetime2
pathmax
perl
physmem
@@ -194,12 +210,16 @@ gnulib_modules="
priv-set
progname
propername
pthread
pthread-cond
pthread-mutex
pthread-thread
pthread_sigmask
putenv
quote
quotearg
randint
randperm
rawmemchr
read-file
readlink
readtokens
@@ -210,7 +230,7 @@ gnulib_modules="
remove
rename
renameat
renameat2
renameatu
rmdir
root-dev-ino
rpmatch
@@ -219,6 +239,7 @@ gnulib_modules="
save-cwd
savedir
savewd
select
selinux-at
setenv
settime
@@ -229,7 +250,6 @@ gnulib_modules="
stat-macros
stat-size
stat-time
statat
stdbool
stdlib-safer
stpcpy
@@ -238,7 +258,6 @@ gnulib_modules="
strncat
strnumcmp
strsignal
strtod
strtoimax
strtoumax
symlinkat
@@ -246,17 +265,20 @@ gnulib_modules="
sys_resource
sys_stat
sys_wait
targetdir
tempname
termios
time_rz
timer-time
timespec
tmpfile
tzset
uname
unicodeio
unistd-safer
unlink-busy
unlinkat
unlinkdir
unlocked-io
unsetenv
update-copyright
@@ -265,6 +287,7 @@ gnulib_modules="
userspec
utimecmp
utimens
utimensat
vasprintf-posix
vc-list-files
verify
@@ -276,6 +299,7 @@ gnulib_modules="
winsz-ioctl
winsz-termios
write-any-file
xalignalloc
xalloc
xbinary-io
xdectoint
@@ -291,9 +315,10 @@ gnulib_modules="
xstrtod
xstrtoimax
xstrtol
xstrtol-error
xstrtold
xstrtoumax
year2038
year2038-required
yesno
"
@@ -326,7 +351,7 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
'
gnulib_tool_option_extras="--tests-base=gnulib-tests --with-tests --symlink\
--makefile-name=gnulib.mk
--makefile-name=gnulib.mk --automake-subdir
"
# Build prerequisites
@@ -360,9 +385,6 @@ bootstrap_post_import_hook ()
&& chmod a-w $tmp-1 $tmp-2 \
&& mv -f $tmp-1 $m4f && mv -f $tmp-2 $mkf)
# Massage lib/gnulib.mk before using it later in the bootstrapping process.
build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
# Regenerate src/single-binary.mk
(mkf=src/single-binary.mk tmp=single-binary.tmp \
&& rm -f $mkf $tmp \

View File

@@ -45,6 +45,7 @@ normal_progs='
b2sum
base64
base32
basenc
basename
cat
chcon

View File

@@ -41,7 +41,7 @@ done
# Load actual values from src/local.mk. This will read all the variables from
# the local.mk matching the src_${cmd}_... case.
while read l; do
if echo "$l" | grep -E '^src_\w+ +\+?=' > /dev/null; then
if echo "$l" | grep -E '^src_[_[:alnum:]]+ +\+?=' > /dev/null; then
var=$(echo $l | cut -f 1 -d ' ')
value=$(echo $l | cut -f 2- -d =)
if [ "$value" != " \$(LDADD)" ]; then
@@ -58,19 +58,19 @@ done < $LOCAL_MK
me=`echo "$0" | sed 's,.*/,,'`
echo "## Automatically generated by $me. DO NOT EDIT BY HAND!"
# Override the sources for dir and vdir. We use a smaller version of dir and
# vdir that relies on the ls main.
src_dir_SOURCES="src/coreutils-dir.c"
src_dir_LDADD="$src_dir_LDADD src/libsinglebin_ls.a"
echo src_libsinglebin_dir_a_DEPENDENCIES = src/libsinglebin_ls.a
src_vdir_SOURCES="src/coreutils-vdir.c"
src_vdir_LDADD="$src_vdir_LDADD src/libsinglebin_ls.a"
echo src_libsinglebin_vdir_a_DEPENDENCIES = src/libsinglebin_ls.a
# Override the sources for some tools, to use smaller variants
override_single() {
from="$1"; to="$2";
# Override the sources for arch likewise, using the main from uname.
src_arch_SOURCES="src/coreutils-arch.c"
src_arch_LDADD="$src_arch_LDADD src/libsinglebin_uname.a"
echo src_libsinglebin_arch_a_DEPENDENCIES = src/libsinglebin_uname.a
eval "src_${from}_SOURCES='src/coreutils-${from}.c'"
eval "src_from_LDADD=\$src_${from}_LDADD"
eval "src_${from}_LDADD='$src_from_LDADD src/libsinglebin_${to}.a'"
eval "src_libsinglebin_${from}_a_DEPENDENCIES='src/libsinglebin_${to}.a'"
echo "src_libsinglebin_${from}_a_DEPENDENCIES = src/libsinglebin_${to}.a"
}
override_single dir ls
override_single vdir ls
override_single arch uname
for cmd in $ALL_PROGRAMS; do
echo "# Command $cmd"
@@ -88,6 +88,13 @@ for cmd in $ALL_PROGRAMS; do
echo "${base}_ldadd = $value"
fi
# DEPENDENCIES
var=src_libsinglebin_${cmd}_a_DEPENDENCIES
eval "value=\$$var"
if [ "x$value" = "x" ]; then
echo "$var = \$(src_${cmd}_DEPENDENCIES)"
fi
# CFLAGS
# Hack any other program defining a main() replacing its main by
# single_binary_main_$PROGRAM_NAME.

140
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2003-2018 Free Software Foundation, Inc.
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,7 +26,8 @@ VC_LIST_ALWAYS_EXCLUDE_REGEX = src/blake2/.*$$
# Tests not to run as part of "make distcheck".
local-checks-to-skip = \
sc_proper_name_utf8_requires_ICONV
sc_proper_name_utf8_requires_ICONV \
sc_indent
# Tools used to bootstrap this package, used for "announcement".
bootstrap-tools = autoconf,automake,gnulib,bison
@@ -48,7 +49,7 @@ export VERBOSE = yes
# 4914152 9e
export XZ_OPT = -8e
old_NEWS_hash = 48668bce5e01bf434b1d1ff10d141884
old_NEWS_hash = 72a8f8283d3c9daef72e06be5bb52734
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = ' && !/^cu_install_prog/ && !/dynamic-dep/'
@@ -75,8 +76,8 @@ sc_dd_O_FLAGS:
dd_c = $(srcdir)/src/dd.c
sc_dd_max_sym_length:
ifneq ($(wildcard $(dd_c)),)
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
@len=$$( (sed -n '/conversions\[] =$$/,/^};/p' $(dd_c);\
sed -n '/flags\[] =$$/,/^};/p' $(dd_c) ) \
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'| wc -L);\
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
|tr -d '"' | wc -L); \
@@ -115,12 +116,13 @@ sc_tests_list_consistency:
cd $(top_srcdir); \
$(SHELL) build-aux/vc-list-files tests \
| grep -Ev '^tests/(factor/(run|create-test)|init)\.sh$$' \
| $(EGREP) "$$test_extensions_rx\$$"; \
| grep -E "$$test_extensions_rx\$$"; \
} | sort | uniq -u | grep . && exit 1; :
# Ensure that all version-controlled test scripts are executable.
sc_tests_executable:
@set -o noglob 2>/dev/null || set -f; \
cd $(srcdir); \
find_ext="-name '' "`printf -- "-o -name *%s " $(TEST_EXTENSIONS)`;\
find $(srcdir)/tests/ \( $$find_ext \) \! -perm -u+x -print \
| { sed "s|^$(srcdir)/||"; git ls-files $(srcdir)/tests/; } \
@@ -138,8 +140,8 @@ sc_ensure_gl_diffs_apply_cleanly:
# Avoid :>file which doesn't propagate errors
sc_prohibit_colon_redirection:
@cd $(srcdir)/tests && GIT_PAGER= git grep -n ': *>.*||' \
&& { echo '$(ME): '"The leading colon in :> will hide errors" 1>&2; \
@cd $(srcdir)/tests && GIT_PAGER= git grep -En ': *>.*\|\|' \
&& { echo '$(ME): '"The leading colon in :> will hide errors" >&2; \
exit 1; } \
|| :
@@ -174,7 +176,7 @@ sc_system_h_headers: .re-list
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0; \
$(gl_trap_); \
grep -nE -f .re-list \
$$($(VC_LIST_EXCEPT) | grep '^\($(srcdir)/\)\?src/') \
$$($(VC_LIST_EXCEPT) | grep -E '^($(srcdir)/)?src/') \
&& { echo '$(ME): the above are already included via system.h'\
1>&2; exit 1; } || :; \
fi
@@ -190,7 +192,7 @@ sc_prohibit_quotes_notation:
# Files in src/ should quote all strings in error() output, so that
# unexpected input chars like \r etc. don't corrupt the error.
# In edge cases this can be avoided by putting the format string
# on a separate line to the following arguments.
# on a separate line to the arguments, or the arguments in parenthesis.
sc_error_quotes:
@cd $(srcdir)/src && GIT_PAGER= git grep -n 'error *(.*%s.*, [^(]*);$$'\
*.c | grep -v ', q' \
@@ -234,7 +236,7 @@ sc_error_shell_always_quotes:
# to the compiler that it doesn't return.
sc_die_EXIT_FAILURE:
@cd $(srcdir)/src && GIT_PAGER= git grep -E \
'error \(.*_(FAILURE|INVALID)' \
'error \([^?]*EXIT_' \
&& { echo '$(ME): '"Use die() instead of error" 1>&2; \
exit 1; } \
|| :
@@ -250,6 +252,11 @@ sc_prohibit-quotearg:
halt='Unstyled diagnostic quoting detected' \
$(_sc_search_regexp)
sc_prohibit-skip:
@prohibit='\|\| skip ' \
halt='Use skip_ not skip' \
$(_sc_search_regexp)
sc_sun_os_names:
@grep -nEi \
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
@@ -319,13 +326,22 @@ sc_prohibit-gl-attributes:
halt='Use _GL... attribute macros' \
$(_sc_search_regexp)
# Prefer the const declaration form, with const following the type
sc_prohibit-const-char:
@prohibit='const char \*' \
in_vc_files='\.[ch]$$' \
halt='Use char const *, not const char *' \
$(_sc_search_regexp)
# Look for lines longer than 80 characters, except omit:
# - urls
# - the fdl.texi file copied from gnulib,
# - the help2man script copied from upstream,
# - tests involving long checksum lines, and
# - the 'pr' test cases.
FILTER_LONG_LINES = \
\|^[^:]*NEWS:.*https\{,1\}://| d; \
\|^[^:]*doc/fdl.texi:| d; \
\|^[^:]*man/help2man:| d; \
\|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d; \
\|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
@@ -350,6 +366,11 @@ sc_option_desc_uppercase: $(ALL_MANS)
@grep '^\\fB\\-' -A1 man/*.1 | LC_ALL=C grep '\.1.[A-Z][a-z]' \
&& { echo 1>&2 '$@: found initial capitals in --help'; exit 1; } || :
# '--' should not be treated as '' (U+2013 EN DASH) in long option names.
sc_texi_long_option_escaped: doc/coreutils.info
@grep ' [^ ]' '$<' \
&& { echo 1>&2 '$@: found unquoted --long-option'; exit 1; } || :
# Ensure all man/*.[1x] files are present.
sc_man_file_correlation: check-x-vs-1 check-programs-vs-x
@@ -402,7 +423,7 @@ check-programs-vs-x:
# Ensure we can check out on case insensitive file systems
sc_case_insensitive_file_names: src/uniq
@git ls-files | sort -f | src/uniq -Di | grep . && \
@git -C $(srcdir) ls-files | sort -f | src/uniq -Di | grep . && \
{ echo "$(ME): the above file(s) conflict on case insensitive" \
" file systems" 1>&2; exit 1; } || :
@@ -425,35 +446,35 @@ sc_prohibit_operator_at_end_of_line:
halt='found operator at end of line' \
$(_sc_search_regexp)
# Don't use "readlink" or "readlinkat" directly
sc_prohibit_readlink:
@prohibit='\<readlink(at)? \(' \
halt='do not use readlink(at); use via xreadlink or areadlink*' \
$(_sc_search_regexp)
# Partial substitutes for GNU extensions \< and \> in regexps.
begword = (^|[^_[:alnum:]])
endword = ($$|[^_[:alnum:]])
# Don't use address of "stat" or "lstat" functions
sc_prohibit_stat_macro_address:
@prohibit='\<l?stat '':|&l?stat\>' \
@prohibit='$(begword)l?stat '':|&l?stat$(endword)' \
halt='stat() and lstat() may be function-like macros' \
$(_sc_search_regexp)
# Ensure that date's --help output stays in sync with the info
# documentation for GNU strftime. The only exception is %N and %q,
# which date accepts but GNU strftime does not.
#
# "info foo" fails with error, but not "info foo >/dev/null".
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
sc_strftime_check:
@if test -f $(srcdir)/src/date.c; then \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
{ echo N; echo q; \
info libc date calendar format 2>/dev/null \
| grep "^ *['\`]%.'$$"| $(extract_char); }| sort >$@-info;\
if test $$(stat --format %s $@-info) != 2; then \
if info libc date calendar format 2>/dev/null | \
grep "^ *['\`]%.'$$" >$@-tmp; then \
{ echo N; echo q; $(extract_char) $@-tmp; }| sort \
>$@-info; \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
diff -u $@-src $@-info || exit 1; \
else \
echo '$(ME): skipping $@: libc info not installed' 1>&2; \
fi; \
rm -f $@-src $@-info; \
rm -f $@-info $@-src $@-tmp; \
fi
# Indent only with spaces.
@@ -484,7 +505,7 @@ sc_ensure_comma_after_id_est:
# a period. Check the first line after each "SEE ALSO" line in man/*.x:
sc_prohibit_man_see_also_period:
@grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$') \
| grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' && \
| grep -A1 -e '-\[SEE ALSO]' | grep '\.$$' && \
{ echo '$(ME): do not end "SEE ALSO" section with a period' \
1>&2; exit 1; } || :
@@ -496,7 +517,7 @@ sc_prohibit_emacs__indent_tabs_mode__setting:
# Ensure that tests don't include a redundant fail=0.
sc_prohibit_fail_0:
@prohibit='\<fail=0\>' \
@prohibit='$(begword)fail=0$(endword)' \
halt='fail=0 initialization' \
$(_sc_search_regexp)
@@ -511,6 +532,14 @@ sc_prohibit_and_fail_1:
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Ensure that tests don't use `cmd ... || fail` as that's a noop.
sc_prohibit_or_fail:
@prohibit='\|\| fail$$' \
exclude=':#' \
halt='|| fail detected. Please use: || fail=1' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Ensure that env vars are not passed through returns_ as
# that was seen to fail on FreeBSD /bin/sh at least
sc_prohibit_env_returns:
@@ -525,14 +554,14 @@ sc_prohibit_env_returns:
# setfacl reject it with: "Unrecognized character found in mode field".
# Use hyphens to give it a length of 3: "...:rw-" or "...:r--".
sc_prohibit_short_facl_mode_spec:
@prohibit='\<setfacl .*-m.*:.*:[rwx-]{1,2} ' \
@prohibit='$(begword)setfacl .*-m.*:.*:[rwx-]{1,2} ' \
halt='setfacl mode string length < 3; extend with hyphen(s)' \
$(_sc_search_regexp)
# Ensure that "stdio--.h" is used where appropriate.
sc_require_stdio_safer:
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \
files=$$(grep -l '$(begword)freopen \?(' $$($(VC_LIST_EXCEPT) \
| grep '\.[ch]$$')); \
test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
| grep . && \
@@ -548,7 +577,7 @@ sc_prohibit_perl_hash_quotes:
# Prefer xnanosleep over other less-precise sleep methods
sc_prohibit_sleep:
@prohibit='\<(nano|u)?sleep \(' \
@prohibit='$(begword)(nano|u)?sleep \(' \
halt='prefer xnanosleep over other sleep interfaces' \
$(_sc_search_regexp)
@@ -567,14 +596,14 @@ sc_env_test_dependencies:
grep -vF '[' |paste -d'|' -s))" tests | \
sed "s/\([^:]\):.*env \([^)' ]*\).*/\1 \2/" | uniq | \
while read test prog; do \
printf '%s' $$test | grep -q '\.pl$$' && continue; \
grep -q "print_ver_.* $$prog" $$test \
printf '%s' $$test | grep '\.pl$$' >/dev/null && continue; \
grep "print_ver_.* $$prog" $$test >/dev/null \
|| echo $$test should call: print_ver_ $$prog; \
done | grep . && exit 1 || :
# Use framework_failure_, not the old name without the trailing underscore.
sc_prohibit_framework_failure:
@prohibit='\<framework_''failure\>' \
@prohibit='$(begword)framework_''failure$(endword)' \
halt='use framework_failure_ instead' \
$(_sc_search_regexp)
@@ -591,19 +620,12 @@ sc_prohibit_test_empty:
halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \
$(_sc_search_regexp)
# Ensure that expr doesn't work directly on various unsigned int types,
# as that's not generally supported without GMP.
sc_prohibit_expr_unsigned:
@prohibit='expr .*(UINT|ULONG|[^S]SIZE|[UGP]ID|UINTMAX)' \
halt='avoid passing unsigned limits to `expr` (without GMP)' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Programs like sort, ls, expr use PROG_FAILURE in place of EXIT_FAILURE.
# Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
# In those programs, ensure that EXIT_FAILURE is not used by mistake.
sc_some_programs_must_avoid_exit_failure:
@grep -nw EXIT_FAILURE \
@cd $(srcdir) \
&& grep -nw EXIT_FAILURE \
$$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' $(srcdir)/src) \
| grep -vE '= EXIT_FAILURE|return .* \?' | grep . \
&& { echo '$(ME): do not use EXIT_FAILURE in the above' \
@@ -611,28 +633,28 @@ sc_some_programs_must_avoid_exit_failure:
# Ensure that tests call the get_min_ulimit_v_ function if using ulimit -v
sc_prohibit_test_ulimit_without_require_:
@(git grep -l get_min_ulimit_v_ $(srcdir)/tests; \
git grep -l 'ulimit -v' $(srcdir)/tests) \
@(git -C $(srcdir) grep -l get_min_ulimit_v_ tests; \
git -C $(srcdir) grep -l 'ulimit -v' tests) \
| sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
" should match get_min_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
# Ensure that tests call the cleanup_ function if using background processes
sc_prohibit_test_background_without_cleanup_:
@(git grep -El '( &$$|&[^&]*=\$$!)' $(srcdir)/tests; \
git grep -l 'cleanup_()' $(srcdir)/tests | sed p) \
@(git -C $(srcdir) grep -El '( &$$|&[^&]*=\$$!)' tests; \
git -C $(srcdir) grep -l 'cleanup_()' tests | sed p) \
| sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
" should use cleanup_ for background processes" 1>&2; exit 1; } || :
# Ensure that tests call the print_ver_ function for programs which are
# actually used in that test.
sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
@git grep -w print_ver_ $(srcdir)/tests \
@git -C $(srcdir) grep -w print_ver_ tests \
| sed 's#:print_ver_##' \
| { fail=0; \
while read file name; do \
for i in $$name; do \
case "$$i" in install) i=ginstall;; esac; \
grep -w "$$i" $$file|grep -vw print_ver_|grep -q . \
grep -w "$$i" $$file|grep -vw print_ver_|grep . >/dev/null \
|| { fail=1; \
echo "*** Test: $$file, offending: $$i." 1>&2; };\
done; \
@@ -738,7 +760,7 @@ sc_preprocessor_indentation:
# someone who was initially listed only in THANKS.in later authors a commit,
# this rule detects that their pair may now be removed from THANKS.in.
sc_THANKS_in_duplicates:
@{ git log --pretty=format:%aN | sort -u; \
@{ git -C $(srcdir) log --pretty=format:%aN | sort -u; \
cut -b-36 $(srcdir)/THANKS.in \
| sed '/^$$/,/^$$/!d;/^$$/d;s/ *$$//'; } \
| sort | uniq -d | grep . \
@@ -765,7 +787,7 @@ sc_THANKS_in_sorted:
# Look for developer diagnostics that are marked for translation.
# This won't find any for which devmsg's format string is on a separate line.
sc_marked_devdiagnostics:
@prohibit='\<devmsg *\(.*_\(' \
@prohibit='$(begword)devmsg *\(.*_\(' \
halt='found marked developer diagnostic(s)' \
$(_sc_search_regexp)
@@ -816,15 +838,16 @@ update-copyright-env = \
exclude_file_name_regexp--sc_space_tab = \
^(tests/pr/|tests/misc/nl\.sh$$|gl/.*\.diff$$|man/help2man$$)
exclude_file_name_regexp--sc_bindtextdomain = \
^(gl/.*|lib/euidaccess-stat|src/make-prime-list)\.c$$
^(gl/.*|lib/euidaccess-stat|src/make-prime-list|src/cksum)\.c$$
exclude_file_name_regexp--sc_trailing_blank = \
^(tests/pr/|gl/.*\.diff$$|man/help2man)
exclude_file_name_regexp--sc_system_h_headers = \
^src/((die|system|copy)\.h|make-prime-list\.c)$$
^src/((die|system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
_src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
_gl_src = (xdecto.max|cl-strtold)
exclude_file_name_regexp--sc_require_config_h_first = \
(^lib/buffer-lcm\.c|gl/lib/xdecto.max\.c|src/$(_src)\.c)$$
(^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
exclude_file_name_regexp--sc_require_config_h = \
$(exclude_file_name_regexp--sc_require_config_h_first)
@@ -840,7 +863,7 @@ exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
^m4/stat-prog\.m4$$
exclude_file_name_regexp--sc_prohibit_fail_0 = \
(^.*/git-hooks/commit-msg|^tests/init\.sh|Makefile\.am|\.mk|.*\.texi)$$
exclude_file_name_regexp--sc_prohibit_test_minus_ao = *\.texi$$
exclude_file_name_regexp--sc_prohibit_test_minus_ao = doc/.*\.texi$$
exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
# longlong.h is maintained elsewhere.
@@ -862,8 +885,9 @@ exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
^src/(system\.h|od\.c|printf\.c|getlimits\.c)$$
_cksum = ^tests/misc/cksum-base64\.pl$$
exclude_file_name_regexp--sc_prohibit_test_backticks = \
^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$
^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$|$(_cksum)
# Exempt test.c, since it's nominally shared, and relatively static.
exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
@@ -878,7 +902,11 @@ exclude_file_name_regexp--sc_prohibit-gl-attributes = ^src/libstdbuf\.c$$
exclude_file_name_regexp--sc_prohibit_uppercase_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_comma_after_id_est = \.diff|$(_ll)$$
exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)
exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)|$(_cksum)
# `grep . -q` is not exactly equivalent to `grep . >/dev/null`
# and this difference is significant in the NEWS description
exclude_file_name_regexp--sc_unportable_grep_q = NEWS
# Augment AM_CFLAGS to include our per-directory options:
AM_CFLAGS += $($(@D)_CFLAGS)

View File

@@ -1,7 +1,7 @@
# -*- autoconf -*-
# Process this file with autoconf to produce a configure script.
# Copyright (C) 1991-2018 Free Software Foundation, Inc.
# Copyright (C) 1991-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -35,8 +35,7 @@ AC_CONFIG_SRCDIR([src/ls.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
AM_INIT_AUTOMAKE([1.11.2 no-dist-gzip dist-xz color-tests parallel-tests
subdir-objects])
AM_INIT_AUTOMAKE([1.11.2 dist-xz color-tests parallel-tests subdir-objects])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds
@@ -53,22 +52,20 @@ m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set])
m4_if(m4_sysval, [0], [], [dnl
gl_ASSERT_NO_GNULIB_POSIXCHECK])
AC_PROG_CC_STDC
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AC_PROG_RANLIB
AC_PROG_EGREP
AC_PROG_LN_S
gl_EARLY
gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat])
gl_INIT
coreutils_MACROS
# The test suite needs to know if we have a working perl.
# FIXME: this is suboptimal. Ideally, we would be able to call gl_PERL
# with an ACTION-IF-NOT-FOUND argument ...
cu_have_perl=yes
case $PERL in *"/missing "*) cu_have_perl=no;; esac
AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes])
AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
# ------------------------------------------------
@@ -88,11 +85,59 @@ AC_DEFUN([gl_GCC_VERSION_IFELSE],
]
)
AC_ARG_ENABLE([single-binary],
[AS_HELP_STRING([--enable-single-binary=[shebangs|symlinks]],
[Compile all the tools in a single binary, reducing the overall size.
When compiled this way, shebangs (default when enabled) or symlinks are
installed for each tool that points to the single binary.])],
[gl_single_binary=no ;
case $enableval in
yes) gl_single_binary=shebangs ;;
no|shebangs|symlinks) gl_single_binary=$enableval ;;
*) AC_MSG_ERROR([bad value $enableval for single-binary option.
Options are: symlinks, shebangs, no.]) ;;
esac],
[gl_single_binary=no]
)
AC_ARG_ENABLE([single-binary-exceptions],
[AS_HELP_STRING([--enable-single-binary-exceptions=PROG_LIST],
[When used with --enable-single-binary, exclude the PROG_LIST from
it, so these programs are compiled as separated files
(comma-separated, default none))])],
[gl_single_binary_exceptions=$enableval],
[gl_single_binary_exceptions=]
)
if test "$gl_single_binary" = 'symlinks'; then
if ! test "`echo ls | sed \"$program_transform_name\"`" = 'ls'; then
AC_MSG_ERROR([program name transformations are not currently supported
with --enable-single-binary=symlinks.])
fi
fi
AM_CONDITIONAL([SINGLE_BINARY], [test "$gl_single_binary" != no])
AC_ARG_ENABLE([bold-man-page-references],
[AS_HELP_STRING([--disable-bold-man-page-references],
[When generating man pages, do not apply bold style around any
references like name(1) etc.])],
[gl_bold_manpages=yes ;
case $enableval in
no|yes) gl_bold_manpages=$enableval ;;
*) AC_MSG_ERROR([bad value $enableval for bold-man-page-references.
Options are: yes, no.]) ;;
esac],
[gl_bold_manpages=yes]
)
AM_CONDITIONAL([BOLD_MAN_REFS], [test "$gl_bold_manpages" != no])
AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
[turn on many GCC warnings (for developers; best with GNU make)])],
[AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
[control generation of GCC warnings. The TYPE 'no' disables
warnings (default for non-developer builds); 'yes' generates
cheap warnings if available (default for developer builds);
'expensive' in addition generates expensive-to-compute warnings
if available.])],
[case $enableval in
yes|no) ;;
no|yes|expensive) ;;
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
esac
gl_gcc_warnings=$enableval],
@@ -108,12 +153,18 @@ AC_ARG_ENABLE([gcc-warnings],
&& gl_gcc_warnings=yes])]
)
if test "$gl_gcc_warnings" = yes; then
if test $gl_gcc_warnings != no; then
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
AC_SUBST([WERROR_CFLAGS])
nw=
ew=
AS_IF([test $gl_gcc_warnings != expensive],
[# -fanalyzer and related options slow GCC considerably.
ew="$ew -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
ew="$ew -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"])
# This, $nw, is the list of warnings we disable.
nw=$ew
nw="$nw -Wdeclaration-after-statement" # too useful to forbid
nw="$nw -Waggregate-return" # anachronistic
nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
@@ -128,14 +179,11 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wunreachable-code" # Too many warnings for now
nw="$nw -Wpadded" # Our structs are not padded
nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
nw="$nw -Wlogical-op" # Too many warnings until GCC 4.8.0
nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
nw="$nw -Wvla" # warnings in gettext.h
nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
nw="$nw -Wswitch-enum" # Too many warnings for now
nw="$nw -Wswitch-default" # Too many warnings for now
nw="$nw -Wstack-protector" # not worth working around
nw="$nw -Wtype-limits" # False alarms for portable code
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776
nw="$nw -Wformat-truncation=2" # False alarm in ls.c, probably related
# things I might fix soon:
@@ -143,7 +191,14 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wmissing-format-attribute" # copy.c
nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
nw="$nw -Wsuggest-attribute=format" # warns about copy.c and factor.c
nw="$nw -Wvector-operation-performance" # warns about randperm.c
# Suppress noreturn warnings with single binaries; otherwise
# GCC complains about the renamed 'main' not being declared noreturn
# because 'main_exit' calls 'exit' when linting.
if test "$gl_single_binary" != no; then
nw="$nw -Wsuggest-attribute=noreturn"
fi
# Using -Wstrict-overflow is a pain, but the alternative is worse.
# For an example, see the code that provoked this report:
@@ -156,15 +211,9 @@ if test "$gl_gcc_warnings" = yes; then
gl_WARN_ADD([$w])
done
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-type-limits]) # False alarms for portable code
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wno-format-nonliteral])
# Enable this warning only with gcc-4.8 and newer. Before that
# bounds checking as done in truncate.c was incorrectly flagged.
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772
gl_GCC_VERSION_IFELSE([4], [8], [gl_WARN_ADD([-Wlogical-op])])
# clang is unduly picky about some things.
AC_CACHE_CHECK([whether the compiler is clang], [utils_cv_clang],
[AC_COMPILE_IFELSE(
@@ -197,7 +246,7 @@ if test "$gl_gcc_warnings" = yes; then
# We use a slightly smaller set of warning options for lib/.
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
nw=
nw=$ew
nw="$nw -Wduplicated-branches" # Too many false alarms
nw="$nw -Wformat-truncation=2"
nw="$nw -Wstrict-overflow"
@@ -208,6 +257,11 @@ if test "$gl_gcc_warnings" = yes; then
# FIXME: it may be easy to remove this, since it affects only one file:
# the snprintf call at ftoastr.c:132.
nw="$nw -Wdouble-promotion"
# FIXME: remove this line when gcc improves
# FP in careadlinkat.c w/gcc 10.0.1 20200205
gl_WARN_ADD([-Wno-return-local-addr])
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
@@ -216,42 +270,13 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wstrict-prototypes"
# It's not worth being this picky about test programs.
nw="$nw -Wsuggest-attribute=const"
nw="$nw -Wsuggest-attribute=format"
nw="$nw -Wsuggest-attribute=pure"
gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
[$GNULIB_WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
fi
AC_ARG_ENABLE([single-binary],
[AS_HELP_STRING([--enable-single-binary=[shebangs|symlinks]],
[Compile all the tools in a single binary, reducing the overall size.
When compiled this way, shebangs (default when enabled) or symlinks are
installed for each tool that points to the single binary.])],
[gl_single_binary=no ;
case $enableval in
yes) gl_single_binary=shebangs ;;
no|shebangs|symlinks) gl_single_binary=$enableval ;;
*) AC_MSG_ERROR([bad value $enableval for single-binary option.
Options are: symlinks, shebangs, no.]) ;;
esac],
[gl_single_binary=no]
)
AC_ARG_ENABLE([single-binary-exceptions],
[AS_HELP_STRING([--enable-single-binary-exceptions=PROG_LIST],
[When used with --enable-single-binary, exclude the PROG_LIST from
it, so these programs are compiled as separated files
(comma-separated, default none))])],
[gl_single_binary_exceptions=$enableval],
[gl_single_binary_exceptions=]
)
if test "$gl_single_binary" = 'symlinks'; then
if ! test "`echo ls | sed \"$program_transform_name\"`" = 'ls'; then
AC_MSG_ERROR([program name transformations are not currently supported
with --enable-single-binary=symlinks.])
fi
fi
AM_CONDITIONAL([SINGLE_BINARY], [test "$gl_single_binary" != no])
AC_FUNC_FORK
optional_bin_progs=
@@ -279,7 +304,8 @@ void unset_TZ (void)
if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
to++;
}
int main()
int
main ()
{
time_t now = time ((time_t *) 0);
int hour_GMT0, hour_unset;
@@ -311,6 +337,9 @@ if test $utils_cv_localtime_cache = yes; then
AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
fi
# macOS >= 10.12
AC_CHECK_FUNCS([fclonefileat])
# Assume that if getattrat exists, it's compatible with Solaris 11.
AC_CHECK_FUNCS([getattrat])
if test $ac_cv_func_getattrat = yes; then
@@ -318,6 +347,9 @@ if test $ac_cv_func_getattrat = yes; then
AC_SUBST([LIB_NVPAIR])
fi
# glibc >= 2.28 and linux kernel >= 4.11
AC_CHECK_FUNCS([statx])
# SCO-ODT-3.0 is reported to need -los to link programs using initgroups
AC_CHECK_FUNCS([initgroups])
if test $ac_cv_func_initgroups = no; then
@@ -351,6 +383,15 @@ case $utils_cv_func_setpriority,$ac_cv_func_nice in
gl_ADD_PROG([optional_bin_progs], [nice])
esac
if test "$cross_compiling" = yes || test -c /dev/stdin <.; then
AC_DEFINE([DEV_FD_MIGHT_BE_CHR], [1],
[Define to 1 if /dev/std{in,out,err} and /dev/fd/N, if they exist, might be
character-special devices whose minor device number is the file
descriptor number, such as on Solaris. Leave undefined if they are
definitely the actual files. This determination should be done after any
symbolic links are followed.])
fi
AC_DEFUN([coreutils_DUMMY_1],
[
AC_REQUIRE([gl_READUTMP])
@@ -464,8 +505,6 @@ AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
[AC_INCLUDES_DEFAULT
#include <signal.h>])
cu_GMP
# Build df only if there's a point to it.
if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
gl_ADD_PROG([optional_bin_progs], [df])
@@ -474,6 +513,8 @@ fi
# Build stdbuf only if supported
ac_save_CFLAGS=$CFLAGS
ac_save_LDFLAGS=$LDFLAGS
cu_save_c_werror_flag=$ac_c_werror_flag
AC_LANG_WERROR
# Detect warnings about ignored "constructor" attributes.
gl_WARN_ADD([-Werror], [CFLAGS])
gl_WARN_ADD([-errwarn], [CFLAGS])
@@ -502,18 +543,111 @@ if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
fi
CFLAGS=$ac_save_CFLAGS
LDFLAGS=$ac_save_LDFLAGS
ac_c_werror_flag=$cu_save_c_werror_flag
# Detect when using xlc to determine whether to use -qinclude=
AC_CACHE_CHECK([whether the system supports xlc include], [utils_cv_xlc],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
#ifndef __xlc__
#error "not xlc"
#endif
]])],
[utils_cv_xlc=yes],
[utils_cv_xlc=no])])
AM_CONDITIONAL([USE_XLC_INCLUDE], [test "$utils_cv_xlc" = yes])
AC_MSG_CHECKING([if __get_cpuid available])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <cpuid.h>
int
main (void)
{
unsigned int eax, ebx, ecx, edx;
__get_cpuid (1, &eax, &ebx, &ecx, &edx);
return 1;
}
]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_CPUID], [1], [__get_cpuid available])
cpuid_exists=yes
],[
AC_MSG_RESULT([no])
])
ac_save_CFLAGS=$CFLAGS
CFLAGS="-mavx -mpclmul $CFLAGS"
AC_MSG_CHECKING([if pclmul intrinsic exists])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m128i a, b;
a = _mm_clmulepi64_si128 (a, b, 0x00);
return 1;
}
]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_PCLMUL_INTRINSIC], [1], [pclmul intrinsic exists])
pclmul_intrinsic_exists=yes
],[
AC_MSG_RESULT([no])
])
if test "x$cpuid_exists" = "xyes" &&
test "x$pclmul_intrinsic_exists" = "xyes"; then
AC_DEFINE([USE_PCLMUL_CRC32], [1],
[CRC32 calculation by pclmul hardware instruction enabled])
fi
AM_CONDITIONAL([USE_PCLMUL_CRC32],
[test "x$cpuid_exists" = "xyes" &&
test "x$pclmul_intrinsic_exists" = "xyes"])
CFLAGS=$ac_save_CFLAGS
AC_MSG_CHECKING([if __get_cpuid_count exists])
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <cpuid.h>
int
main (void)
{
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx);
return 1;
}
]])
],[
AC_MSG_RESULT([yes])
get_cpuid_count_exists=yes
],[
AC_MSG_RESULT([no])
])
CFLAGS="-mavx2 $CFLAGS"
AC_MSG_CHECKING([if avx2 intrinstics exists])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m256i a, b;
a = _mm256_sad_epu8 (a, b);
return 1;
}
]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_AVX2_INTRINSIC], [1], [avx2 intrinsics exists])
avx2_intrinsic_exists=yes
],[
AC_MSG_RESULT([no])
])
if test "x$get_cpuid_count_exists" = "xyes" &&
test "x$avx2_intrinsic_exists" = "xyes"; then
AC_DEFINE([USE_AVX2_WC_LINECOUNT], [1], [Counting lines with AVX2 enabled])
fi
AM_CONDITIONAL([USE_AVX2_WC_LINECOUNT],
[test "x$get_cpuid_count_exists" = "xyes" &&
test "x$avx2_intrinsic_exists" = "xyes"])
CFLAGS=$ac_save_CFLAGS
############################################################################

6
doc/.gitignore vendored
View File

@@ -1,3 +1,4 @@
/.dirstamp
/constants.texi
/coreutils.aux
/coreutils.cp
@@ -12,13 +13,12 @@
/coreutils.op
/coreutils.pdf
/coreutils.pg
/coreutils.t2p/
/coreutils.toc
/coreutils.tp
/coreutils.vr
/fdl.texi
/gendocs_template
/gendocs_template_min
/parse-datetime.texi
/stamp-vti
/version.texi
/.dirstamp
/gendocs_template_min

File diff suppressed because it is too large Load Diff

505
doc/fdl.texi Normal file
View File

@@ -0,0 +1,505 @@
@c The GNU Free Documentation License.
@center Version 1.3, 3 November 2008
@c This file is intended to be included within another document,
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
@uref{https://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
@enumerate 0
@item
PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
@item
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The ``Document'', below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as ``you''. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, La@TeX{} input
format, SGML or XML using a publicly available
DTD, and standard-conforming simple HTML,
PostScript or PDF designed for human modification. Examples
of transparent image formats include PNG, XCF and
JPG@. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are
not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for
output purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
The ``publisher'' means any person or entity that distributes copies
of the Document to the public.
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
@item
VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@item
COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@item
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.
@item
Preserve all the copyright notices of the Document.
@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
@item
Include an unaltered copy of this License.
@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
@item
Delete any section Entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.
@item
Preserve any Warranty Disclaimers.
@end enumerate
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@item
COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''. You must delete all
sections Entitled ``Endorsements.''
@item
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@item
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
@item
TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
@item
TERMINATION
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
@item
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
@uref{https://www.gnu.org/licenses/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation. If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
@item
RELICENSING
``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
site means any set of copyrightable works thus published on the MMC
site.
``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
``Incorporate'' means to publish or republish a Document, in whole or
in part, as part of another Document.
An MMC is ``eligible for relicensing'' if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
@end enumerate
@page
@heading ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
@smallexample
@group
Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with@dots{}Texts.''@: line with this:
@smallexample
@group
with the Invariant Sections being @var{list their titles}, with
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
being @var{list}.
@end group
@end smallexample
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:

View File

@@ -1,7 +1,7 @@
# Make coreutils documentation. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 1995-2018 Free Software Foundation, Inc.
# Copyright (C) 1995-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,7 +22,8 @@ doc_coreutils_TEXINFOS = \
doc/perm.texi \
doc/parse-datetime.texi \
doc/constants.texi \
doc/fdl.texi
doc/fdl.texi \
doc/sort-version.texi
# The following is necessary if the package name is 8 characters or longer.
# If the info documentation would be split into 10 or more separate files,

View File

@@ -1,6 +1,6 @@
@c File mode bits
@c Copyright (C) 1994-2018 Free Software Foundation, Inc.
@c Copyright (C) 1994--2023 Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -70,38 +70,36 @@ In addition to the three sets of three permissions listed above, the
file mode bits have three special components, which affect only
executable files (programs) and, on most systems, directories:
@enumerate
@item
@table @asis
@item The @dfn{set-user-ID bit} (@dfn{setuid bit}).
@cindex set-user-ID
@cindex setuid
Set the process's effective user ID to that of the file upon execution
(called the @dfn{set-user-ID bit}, or sometimes the @dfn{setuid bit}).
On execution, set the process's effective user ID to that of the file.
For directories on a few systems, give files created in the directory
the same owner as the directory, no matter who creates them, and set
the set-user-ID bit of newly-created subdirectories.
@item
@item The @dfn{set-group-ID bit} (@dfn{setgid bit}).
@cindex set-group-ID
@cindex setgid
Set the process's effective group ID to that of the file upon execution
(called the @dfn{set-group-ID bit}, or sometimes the @dfn{setgid bit}).
On execution, set the process's effective group ID to that of the file.
For directories on most systems, give files created in the directory
the same group as the directory, no matter what group the user who
creates them is in, and set the set-group-ID bit of newly-created
subdirectories.
@item
@item The @dfn{restricted deletion flag} or @dfn{sticky bit}.
@cindex sticky
@cindex swap space, saving text image in
@cindex text image, saving in swap space
@cindex restricted deletion flag
Prevent unprivileged users from removing or renaming a file in a directory
unless they own the file or the directory; this is called the
@dfn{restricted deletion flag} for the directory, and is commonly
unless they own the file or the directory; this is commonly
found on world-writable directories like @file{/tmp}.
For regular files on some older systems, save the program's text image on the
swap device so it will load more quickly when run; this is called the
@dfn{sticky bit}.
@end enumerate
swap device so it will load more quickly when run, so that the image
is ``sticky''.
@end table
In addition to the file mode bits listed above, there may be file attributes
specific to the file system, e.g., access control lists (ACLs), whether a
@@ -511,8 +509,8 @@ Value in Corresponding
Mode Mode Bit
Special mode bits:
4000 Set user ID on execution
2000 Set group ID on execution
4000 Set user ID
2000 Set group ID
1000 Restricted deletion flag or sticky bit
The file's owner:

909
doc/sort-version.texi Normal file
View File

@@ -0,0 +1,909 @@
@c GNU Version-sort ordering documentation
@c Copyright (C) 2019--2023 Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, no Front-Cover Texts, and no Back-Cover
@c Texts. A copy of the license is included in the ``GNU Free
@c Documentation License'' file as part of this distribution.
@c Written by Assaf Gordon
@node Version sort ordering
@chapter Version sort ordering
@node Version sort overview
@section Version sort overview
@dfn{Version sort} puts items such as file names and lines of
text in an order that feels natural to people, when the text
contains a mixture of letters and digits.
Lexicographic sorting usually does not produce the order that one expects
because comparisons are made on a character-by-character basis.
Compare the sorting of the following items:
@example
Lexicographic sort: Version Sort:
a1 a1
a120 a2
a13 a13
a2 a120
@end example
Version sort functionality in GNU Coreutils is available in the @samp{ls -v},
@samp{ls --sort=version}, @samp{sort -V}, and
@samp{sort --version-sort} commands.
@node Using version sort in GNU Coreutils
@subsection Using version sort in GNU Coreutils
Two GNU Coreutils programs use version sort: @command{ls} and @command{sort}.
To list files in version sort order, use @command{ls}
with the @option{-v} or @option{--sort=version} option:
@example
default sort: version sort:
$ ls -1 $ ls -1 -v
a1 a1
a100 a1.4
a1.13 a1.13
a1.4 a1.40
a1.40 a2
a2 a100
@end example
To sort text files in version sort order, use @command{sort} with
the @option{-V} or @option{--version-sort} option:
@example
$ cat input
b3
b11
b1
b20
lexicographic order: version sort order:
$ sort input $ sort -V input
b1 b1
b11 b3
b20 b11
b3 b20
@end example
To sort a specific field in a file, use @option{-k/--key} with
@samp{V} type sorting, which is often combined with @samp{b} to
ignore leading blanks in the field:
@example
$ cat input2
100 b3 apples
2000 b11 oranges
3000 b1 potatoes
4000 b20 bananas
$ sort -k 2bV,2 input2
3000 b1 potatoes
100 b3 apples
2000 b11 oranges
4000 b20 bananas
@end example
@node Version sort and natural sort
@subsection Version sort and natural sort
In GNU Coreutils, the name @dfn{version sort} was chosen because it is based
on Debian GNU/Linux's algorithm of sorting packages' versions.
Its goal is to answer questions like
``Which package is newer, @file{firefox-60.7.2} or @file{firefox-60.12.3}?''
In Coreutils this algorithm was slightly modified to work on more
general input such as textual strings and file names
(see @ref{Differences from Debian version sort}).
In other contexts, such as other programs and other programming
languages, a similar sorting functionality is called
@uref{https://en.wikipedia.org/wiki/Natural_sort_order,natural sort}.
@node Variations in version sort order
@subsection Variations in version sort order
Currently there is no standard for version sort.
That is: there is no one correct way or universally agreed-upon way to
order items. Each program and each programming language can decide its
own ordering algorithm and call it ``version sort'', ``natural sort'',
or other names.
See @ref{Other version/natural sort implementations} for many examples of
differing sorting possibilities, each with its own rules and variations.
If you find a bug in the Coreutils implementation of version-sort, please
report it. @xref{Reporting version sort bugs}.
@node Version sort implementation
@section Version sort implementation
GNU Coreutils version sort is based on the ``upstream version''
part of
@uref{https://www.debian.org/doc/debian-policy/ch-controlfields.html#version,
Debian's versioning scheme}.
This section describes the GNU Coreutils sort ordering rules.
The next section (@ref{Differences from Debian version
sort}) describes some differences between GNU Coreutils
and Debian version sort.
@node Version-sort ordering rules
@subsection Version-sort ordering rules
The version sort ordering rules are:
@enumerate
@item
The strings are compared from left to right.
@item
First the initial part of each string consisting entirely of non-digit
bytes is determined.
@enumerate A
@item
These two parts (either of which may be empty) are compared lexically.
If a difference is found it is returned.
@item
The lexical comparison is a lexicographic comparison of byte strings,
except that:
@enumerate a
@item
ASCII letters sort before other bytes.
@item
A tilde sorts before anything, even an empty string.
@end enumerate
@end enumerate
@item
Then the initial part of the remainder of each string that contains
all the leading digits is determined. The numerical values represented by
these two parts are compared, and any difference found is returned as
the result of the comparison.
@enumerate A
@item
For these purposes an empty string (which can only occur at the end of
one or both version strings being compared) counts as zero.
@item
Because the numerical value is used, non-identical strings can compare
equal. For example, @samp{123} compares equal to @samp{00123}, and
the empty string compares equal to @samp{0}.
@end enumerate
@item
These two steps (comparing and removing initial non-digit strings and
initial digit strings) are repeated until a difference is found or
both strings are exhausted.
@end enumerate
Consider the version-sort comparison of two file names:
@file{foo07.7z} and @file{foo7a.7z}. The two strings will be broken
down to the following parts, and the parts compared respectively from
each string:
@example
foo @r{vs} foo @r{(rule 2, non-digits)}
07 @r{vs} 7 @r{(rule 3, digits)}
. @r{vs} a. @r{(rule 2)}
7 @r{vs} 7 @r{(rule 3)}
z @r{vs} z @r{(rule 2)}
@end example
Comparison flow based on above algorithm:
@enumerate
@item
The first parts (@samp{foo}) are identical.
@item
The second parts (@samp{07} and @samp{7}) are compared numerically,
and compare equal.
@item
The third parts (@samp{.} vs @samp{a.}) are compared
lexically by ASCII value (rule 2.B).
@item
The first byte of the first string (@samp{.}) is compared
to the first byte of the second string (@samp{a}).
@item
Rule 2.B.a says letters sorts before non-letters.
Hence, @samp{a} comes before @samp{.}.
@item
The returned result is that @file{foo7a.7z} comes before @file{foo07.7z}.
@end enumerate
Result when using sort:
@example
$ cat input3
foo07.7z
foo7a.7z
$ sort -V input3
foo7a.7z
foo07.7z
@end example
See @ref{Differences from Debian version sort} for
additional rules that extend the Debian algorithm in Coreutils.
@node Version sort is not the same as numeric sort
@subsection Version sort is not the same as numeric sort
Consider the following text file:
@example
$ cat input4
8.10
8.5
8.1
8.01
8.010
8.100
8.49
Numerical Sort: Version Sort:
$ sort -n input4 $ sort -V input4
8.01 8.01
8.010 8.1
8.1 8.5
8.10 8.010
8.100 8.10
8.49 8.49
8.5 8.100
@end example
Numeric sort (@samp{sort -n}) treats the entire string as a single numeric
value, and compares it to other values. For example, @samp{8.1}, @samp{8.10} and
@samp{8.100} are numerically equivalent, and are ordered together. Similarly,
@samp{8.49} is numerically less than @samp{8.5}, and appears before first.
Version sort (@samp{sort -V}) first breaks down the string into digit and
non-digit parts, and only then compares each part (see annotated
example in @ref{Version-sort ordering rules}).
Comparing the string @samp{8.1} to @samp{8.01}, first the
@samp{8}s are compared (and are identical), then the
dots (@samp{.}) are compared and are identical, and lastly the
remaining digits are compared numerically (@samp{1} and @samp{01}) --
which are numerically equal. Hence, @samp{8.01} and @samp{8.1}
are grouped together.
Similarly, comparing @samp{8.5} to @samp{8.49} -- the @samp{8}
and @samp{.} parts are identical, then the numeric values @samp{5} and
@samp{49} are compared. The resulting @samp{5} appears before @samp{49}.
This sorting order (where @samp{8.5} comes before @samp{8.49}) is common when
assigning versions to computer programs (while perhaps not intuitive
or ``natural'' for people).
@node Version sort punctuation
@subsection Version sort punctuation
Punctuation is sorted by ASCII order (rule 2.B).
@example
$ touch 1.0.5_src.tar.gz 1.0_src.tar.gz
$ ls -v -1
1.0.5_src.tar.gz
1.0_src.tar.gz
@end example
Why is @file{1.0.5_src.tar.gz} listed before @file{1.0_src.tar.gz}?
Based on the version-sort ordering rules, the strings are broken down
into the following parts:
@example
1 @r{vs} 1 @r{(rule 3, all digits)}
. @r{vs} . @r{(rule 2, all non-digits)}
0 @r{vs} 0 @r{(rule 3)}
. @r{vs} _src.tar.gz @r{(rule 2)}
5 @r{vs} empty string @r{(no more bytes in the file name)}
_src.tar.gz @r{vs} empty string
@end example
The fourth parts (@samp{.} and @samp{_src.tar.gz}) are compared
lexically by ASCII order. The @samp{.} (ASCII value 46) is
less than @samp{_} (ASCII value 95) -- and should be listed before it.
Hence, @file{1.0.5_src.tar.gz} is listed first.
If a different byte appears instead of the underscore (for
example, percent sign @samp{%} ASCII value 37, which is less
than dot's ASCII value of 46), that file will be listed first:
@example
$ touch 1.0.5_src.tar.gz 1.0%zzzzz.gz
1.0%zzzzz.gz
1.0.5_src.tar.gz
@end example
The same reasoning applies to the following example, as @samp{.} with
ASCII value 46 is less than @samp{/} with ASCII value 47:
@example
$ cat input5
3.0/
3.0.5
$ sort -V input5
3.0.5
3.0/
@end example
@node Punctuation vs letters
@subsection Punctuation vs letters
Rule 2.B.a says letters sort before non-letters
(after breaking down a string to digit and non-digit parts).
@example
$ cat input6
a%
az
$ sort -V input6
az
a%
@end example
The input strings consist entirely of non-digits, and based on the
above algorithm have only one part, all non-digits
(@samp{a%} vs @samp{az}).
Each part is then compared lexically,
byte-by-byte; @samp{a} compares identically in both
strings.
Rule 2.B.a says a letter like @samp{z} sorts before
a non-letter like @samp{%} -- hence @samp{az} appears first (despite
@samp{z} having ASCII value of 122, much larger than @samp{%}
with ASCII value 37).
@node The tilde @samp{~}
@subsection The tilde @samp{~}
Rule 2.B.b says the tilde @samp{~} (ASCII 126) sorts
before other bytes, and before an empty string.
@example
$ cat input7
1
1%
1.2
1~
~
$ sort -V input7
~
1~
1
1%
1.2
@end example
The sorting algorithm starts by breaking down the string into
non-digit (rule 2) and digit parts (rule 3).
In the above input file, only the last line in the input file starts
with a non-digit (@samp{~}). This is the first part. All other lines
in the input file start with a digit -- their first non-digit part is
empty.
Based on rule 2.B.b, tilde @samp{~} sorts before other bytes
and before the empty string -- hence it comes before all other strings,
and is listed first in the sorted output.
The remaining lines (@samp{1}, @samp{1%}, @samp{1.2}, @samp{1~})
follow similar logic: The digit part is extracted (1 for all strings)
and compares equal. The following extracted parts for the remaining
input lines are: empty part, @samp{%}, @samp{.}, @samp{~}.
Tilde sorts before all others, hence the line @samp{1~} appears next.
The remaining lines (@samp{1}, @samp{1%}, @samp{1.2}) are sorted based
on previously explained rules.
@node Version sort ignores locale
@subsection Version sort ignores locale
In version sort, Unicode characters are compared byte-by-byte according
to their binary representation, ignoring their Unicode value or the
current locale.
Most commonly, Unicode characters are encoded as UTF-8 bytes; for
example, GREEK SMALL LETTER ALPHA (U+03B1, @samp{α}) is encoded as the
UTF-8 sequence @samp{0xCE 0xB1}). The encoding is compared
byte-by-byte, e.g., first @samp{0xCE} (decimal value 206) then
@samp{0xB1} (decimal value 177).
@example
$ touch aa az "a%" "aα"
$ ls -1 -v
aa
az
a%
aα
@end example
Ignoring the first letter (@samp{a}) which is identical in all
strings, the compared values are:
@samp{a} and @samp{z} are letters, and sort before
all other non-digits.
Then, percent sign @samp{%} (ASCII value 37) is compared to the
first byte of the UTF-8 sequence of @samp{α}, which is 0xCE or 206). The
value 37 is smaller, hence @samp{a%} is listed before @samp{aα}.
@node Differences from Debian version sort
@section Differences from Debian version sort
GNU Coreutils version sort differs slightly from the
official Debian algorithm, in order to accommodate more general usage
and file name listing.
@node Hyphen-minus and colon
@subsection Hyphen-minus @samp{-} and colon @samp{:}
In Debian's version string syntax the version consists of three parts:
@example
[epoch:]upstream_version[-debian_revision]
@end example
The @samp{epoch} and @samp{debian_revision} parts are optional.
Example of such version strings:
@example
60.7.2esr-1~deb9u1
52.9.0esr-1~deb9u1
1:2.3.4-1+b2
327-2
1:1.0.13-3
2:1.19.2-1+deb9u5
@end example
If the @samp{debian_revision part} is not present,
hyphens @samp{-} are not allowed.
If epoch is not present, colons @samp{:} are not allowed.
If these parts are present, hyphen and/or colons can appear only once
in valid Debian version strings.
In GNU Coreutils, such restrictions are not reasonable (a file name can
have many hyphens, a line of text can have many colons).
As a result, in GNU Coreutils hyphens and colons are treated exactly
like all other punctuation, i.e., they are sorted after
letters. @xref{Version sort punctuation}.
In Debian, these characters are treated differently than in Coreutils:
a version string with hyphen will sort before similar strings without
hyphens.
Compare:
@example
$ touch 1ab-cd 1abb
$ ls -v -1
1abb
1ab-cd
$ if dpkg --compare-versions 1abb lt 1ab-cd
> then echo sorted
> else echo out of order
> fi
out of order
@end example
For further details, see @ref{Comparing two strings using Debian's
algorithm} and @uref{https://bugs.gnu.org/35939,GNU Bug 35939}.
@node Special priority in GNU Coreutils version sort
@subsection Special priority in GNU Coreutils version sort
In GNU Coreutils version sort, the following items have
special priority and sort before all other strings (listed in order):
@enumerate
@item The empty string
@item The string @samp{.} (a single dot, ASCII 46)
@item The string @samp{..} (two dots)
@item Strings starting with dot (@samp{.}) sort before
strings starting with any other byte.
@end enumerate
Example:
@example
$ printf '%s\n' a "" b "." c ".." ".d20" ".d3" | sort -V
.
..
.d3
.d20
a
b
c
@end example
These priorities make perfect sense for @samp{ls -v}: The special
files dot @samp{.} and dot-dot @samp{..} will be listed
first, followed by any hidden files (files starting with a dot),
followed by non-hidden files.
For @samp{sort -V} these priorities might seem arbitrary. However,
because the sorting code is shared between the @command{ls} and @command{sort}
program, the ordering rules are the same.
@node Special handling of file extensions
@subsection Special handling of file extensions
GNU Coreutils version sort implements specialized handling
of strings that look like file names with extensions.
This enables slightly more natural ordering of file
names.
The following additional rules apply when comparing two strings where
both begin with non-@samp{.}. They also apply when comparing two
strings where both begin with @samp{.} but neither is @samp{.} or @samp{..}.
@enumerate
@item
A suffix (i.e., a file extension) is defined as: a dot, followed by an
ASCII letter or tilde, followed by zero or more ASCII letters, digits,
or tildes; all repeated zero or more times, and ending at string end.
This is equivalent to matching the extended regular expression
@code{(\.[A-Za-z~][A-Za-z0-9~]*)*$} in the C locale.
The longest such match is used, except that a suffix is not
allowed to match an entire nonempty string.
@item
The suffixes are temporarily removed, and the strings are compared
without them, using version sort (see @ref{Version-sort ordering
rules}) without special priority (see @ref{Special priority in GNU
Coreutils version sort}).
@item
If the suffix-less strings do not compare equal, this comparison
result is used and the suffixes are effectively ignored.
@item
If the suffix-less strings compare equal, the suffixes are restored
and the entire strings are compared using version sort.
@end enumerate
Examples for rule 1:
@itemize
@item
@samp{hello-8.txt}: the suffix is @samp{.txt}
@item
@samp{hello-8.2.txt}: the suffix is @samp{.txt}
(@samp{.2} is not included because the dot is not followed by a letter)
@item
@samp{hello-8.0.12.tar.gz}: the suffix is @samp{.tar.gz} (@samp{.0.12}
is not included)
@item
@samp{hello-8.2}: no suffix (suffix is an empty string)
@item
@samp{hello.foobar65}: the suffix is @samp{.foobar65}
@item
@samp{gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2}: the suffix is
@samp{.fc9.tar.bz2} (@samp{.7rc2} is not included as it begins with a digit)
@item
@samp{.autom4te.cfg}: the suffix is the entire string.
@end itemize
Examples for rule 2:
@itemize
@item
Comparing @samp{hello-8.txt} to @samp{hello-8.2.12.txt}, the
@samp{.txt} suffix is temporarily removed from both strings.
@item
Comparing @samp{foo-10.3.tar.gz} to @samp{foo-10.tar.xz}, the suffixes
@samp{.tar.gz} and @samp{.tar.xz} are temporarily removed from the
strings.
@end itemize
Example for rule 3:
@itemize
@item
Comparing @samp{hello.foobar65} to @samp{hello.foobar4}, the suffixes
(@samp{.foobar65} and @samp{.foobar4}) are temporarily removed. The
remaining strings are identical (@samp{hello}). The suffixes are then
restored, and the entire strings are compared (@samp{hello.foobar4} comes
first).
@end itemize
Examples for rule 4:
@itemize
@item
When comparing the strings @samp{hello-8.2.txt} and @samp{hello-8.10.txt}, the
suffixes (@samp{.txt}) are temporarily removed. The remaining strings
(@samp{hello-8.2} and @samp{hello-8.10}) are compared as previously described
(@samp{hello-8.2} comes first).
@slanted{(In this case the suffix removal algorithm
does not have a noticeable effect on the resulting order.)}
@end itemize
@b{How does the suffix-removal algorithm effect ordering results?}
Consider the comparison of hello-8.txt and hello-8.2.txt.
Without the suffix-removal algorithm, the strings will be broken down
to the following parts:
@example
hello- @r{vs} hello- @r{(rule 2, all non-digits)}
8 @r{vs} 8 @r{(rule 3, all digits)}
.txt @r{vs} . @r{(rule 2)}
empty @r{vs} 2
empty @r{vs} .txt
@end example
The comparison of the third parts (@samp{.} vs
@samp{.txt}) will determine that the shorter string comes first --
resulting in @file{hello-8.2.txt} appearing first.
Indeed this is the order in which Debian's @command{dpkg} compares the strings.
A more natural result is that @file{hello-8.txt} should come before
@file{hello-8.2.txt}, and this is where the suffix-removal comes into play:
The suffixes (@samp{.txt}) are removed, and the remaining strings are
broken down into the following parts:
@example
hello- @r{vs} hello- @r{(rule 2, all non-digits)}
8 @r{vs} 8 @r{(rule 3, all digits)}
empty @r{vs} . @r{(rule 2)}
empty @r{vs} 2
@end example
As empty strings sort before non-empty strings, the result is @samp{hello-8}
being first.
A real-world example would be listing files such as:
@file{gcc_10.fc9.tar.gz}
and @file{gcc_10.8.12.7rc2.fc9.tar.bz2}: Debian's algorithm would list
@file{gcc_10.8.12.7rc2.fc9.tar.bz2} first, while @samp{ls -v} will list
@file{gcc_10.fc9.tar.gz} first.
These priorities make sense for @samp{ls -v}:
Versioned files will be listed in a more natural order.
For @samp{sort -V} these priorities might seem arbitrary. However,
because the sorting code is shared between the @command{ls} and @command{sort}
program, the ordering rules are the same.
@node Comparing two strings using Debian's algorithm
@subsection Comparing two strings using Debian's algorithm
The Debian program @command{dpkg} (available on all Debian and Ubuntu
installations) can compare two strings using the @option{--compare-versions}
option.
To use it, create a helper shell function (simply copy & paste the
following snippet to your shell command-prompt):
@example
compver() @{
if dpkg --compare-versions "$1" lt "$2"
then printf '%s\n' "$1" "$2"
else printf '%s\n' "$2" "$1"
fi
@}
@end example
Then compare two strings by calling @command{compver}:
@example
$ compver 8.49 8.5
8.5
8.49
@end example
Note that @command{dpkg} will warn if the strings have invalid syntax:
@example
$ compver "foo07.7z" "foo7a.7z"
dpkg: warning: version 'foo07.7z' has bad syntax:
version number does not start with digit
dpkg: warning: version 'foo7a.7z' has bad syntax:
version number does not start with digit
foo7a.7z
foo07.7z
$ compver "3.0/" "3.0.5"
dpkg: warning: version '3.0/' has bad syntax:
invalid character in version number
3.0.5
3.0/
@end example
To illustrate the different handling of hyphens between Debian and
Coreutils algorithms (see
@ref{Hyphen-minus and colon}):
@example
$ compver abb ab-cd 2>/dev/null $ printf 'abb\nab-cd\n' | sort -V
ab-cd abb
abb ab-cd
@end example
To illustrate the different handling of file extension: (see @ref{Special
handling of file extensions}):
@example
$ compver hello-8.txt hello-8.2.txt 2>/dev/null
hello-8.2.txt
hello-8.txt
$ printf '%s\n' hello-8.txt hello-8.2.txt | sort -V
hello-8.txt
hello-8.2.txt
@end example
@node Advanced version sort topics
@section Advanced Topics
@node Reporting version sort bugs
@subsection Reporting version sort bugs
If you suspect a bug in GNU Coreutils version sort (i.e., in the
output of @samp{ls -v} or @samp{sort -V}), please first check the following:
@enumerate
@item
Is the result consistent with Debian's own ordering (using @command{dpkg}, see
@ref{Comparing two strings using Debian's algorithm})? If it is, then this
is not a bug -- please do not report it.
@item
If the result differs from Debian's, is it explained by one of the
sections in @ref{Differences from Debian version sort}? If it is,
then this is not a bug -- please do not report it.
@item
If you have a question about specific ordering which is not explained
here, please write to @email{coreutils@@gnu.org}, and provide a
concise example that will help us diagnose the issue.
@item
If you still suspect a bug which is not explained by the above, please
write to @email{bug-coreutils@@gnu.org} with a concrete example of the
suspected incorrect output, with details on why you think it is
incorrect.
@end enumerate
@node Other version/natural sort implementations
@subsection Other version/natural sort implementations
As previously mentioned, there are multiple variations on
version/natural sort, each with its own rules. Some examples are:
@itemize
@item
Natural Sorting variants in
@uref{https://rosettacode.org/wiki/Natural_sorting,Rosetta Code}.
@item
Python's @uref{https://pypi.org/project/natsort/,natsort package}
(includes detailed description of their sorting rules:
@uref{https://natsort.readthedocs.io/en/master/howitworks.html,
natsort -- how it works}).
@item
Ruby's @uref{https://github.com/github/version_sorter,version_sorter}.
@item
Perl has multiple packages for natual and version sorts
(each likely with its own rules and nuances):
@uref{https://metacpan.org/pod/Sort::Naturally,Sort::Naturally},
@uref{https://metacpan.org/pod/Sort::Versions,Sort::Versions},
@uref{https://metacpan.org/pod/CPAN::Version,CPAN::Version}.
@item
PHP has a built-in function
@uref{https://www.php.net/manual/en/function.natsort.php,natsort}.
@item
NodeJS's @uref{https://www.npmjs.com/package/natural-sort,natural-sort package}.
@item
In zsh, the
@uref{http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers,
glob modifier} @samp{*(n)} will expand to files in natural sort order.
@item
When writing C programs, the GNU libc library (@samp{glibc})
provides the
@uref{https://man7.org/linux/man-pages/man3/strverscmp.3.html,
strvercmp(3)} function to compare two strings, and
@uref{https://man7.org/linux/man-pages/man3/versionsort.3.html,versionsort(3)}
function to compare two directory entries (despite the names, they are
not identical to GNU Coreutils version sort ordering).
@item
Using Debian's sorting algorithm in:
@itemize
@item
python: @uref{https://stackoverflow.com/a/4957741,
Stack Overflow Example #4957741}.
@item
NodeJS: @uref{https://www.npmjs.com/package/deb-version-compare,
deb-version-compare}.
@end itemize
@end itemize
@node Related source code
@subsection Related source code
@itemize
@item
Debian's code which splits a version string into
@code{epoch/upstream_version/debian_revision} parts:
@uref{https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/parsehelp.c#n191,
parsehelp.c:parseversion()}.
@item
Debian's code which performs the @code{upstream_version} comparison:
@uref{https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/version.c#n140,
version.c}.
@item
Gnulib code (used by GNU Coreutils) which performs the version comparison:
@uref{https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/filevercmp.c,
filevercmp.c}.
@end itemize

View File

@@ -1,6 +1,6 @@
/* buffer-lcm.c - compute a good buffer size for dealing with two files
Copyright (C) 2002-2018 Free Software Foundation, Inc.
Copyright (C) 2002-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

76
gl/lib/cl-strtod.c Normal file
View File

@@ -0,0 +1,76 @@
/* Convert string to double in the current locale, falling back on the C locale.
Copyright 2019-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#include <config.h>
#include "cl-strtod.h"
#include <c-strtod.h>
#include <errno.h>
#include <stdlib.h>
#if LONG
# define CL_STRTOD cl_strtold
# define DOUBLE long double
# define C_STRTOD c_strtold
# define STRTOD strtold
#else
# define CL_STRTOD cl_strtod
# define DOUBLE double
# define C_STRTOD c_strtod
# define STRTOD strtod
#endif
/* This function acts like strtod or strtold, except that it falls
back on the C locale if the initial prefix is not parsable in
the current locale. If the prefix is parsable in both locales,
it uses the longer parse, breaking ties in favor of the current locale.
Parse the initial prefix of NPTR as a floating-point number in the
current locale or in the C locale (preferring the locale that
yields the longer parse, or the current locale if there is a tie).
If ENDPTR is not NULL, set *ENDPTR to the first unused byte, or to
NPTR if the prefix cannot be parsed.
If successful, return a number without changing errno.
If the prefix cannot be parsed, return 0 and possibly set errno to EINVAL.
If the number overflows, return an extreme value and set errno to ERANGE.
If the number underflows, return a value close to 0 and set errno to ERANGE.
If there is some other error, return 0 and set errno. */
DOUBLE
CL_STRTOD (char const *nptr, char **restrict endptr)
{
char *end;
DOUBLE d = STRTOD (nptr, &end);
if (*end)
{
int strtod_errno = errno;
char *c_end;
DOUBLE c = C_STRTOD (nptr, &c_end);
if (end < c_end)
d = c, end = c_end;
else
errno = strtod_errno;
}
if (endptr)
*endptr = end;
return d;
}

4
gl/lib/cl-strtod.h Normal file
View File

@@ -0,0 +1,4 @@
double cl_strtod (char const *, char **restrict)
_GL_ATTRIBUTE_NONNULL ((1));
long double cl_strtold (char const *, char **restrict)
_GL_ATTRIBUTE_NONNULL ((1));

2
gl/lib/cl-strtold.c Normal file
View File

@@ -0,0 +1,2 @@
#define LONG 1
#include "cl-strtod.c"

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2018 Free Software Foundation, Inc.
Copyright (C) 2010-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2018 Free Software Foundation, Inc.
Copyright (C) 2010-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2018 Free Software Foundation, Inc.
Copyright (C) 2005-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2018 Free Software Foundation, Inc.
Copyright (C) 2005-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,4 +19,4 @@
#include <sys/types.h>
int fd_reopen (int, char const *, int, mode_t);
int fd_reopen (int, char const *, int, mode_t) _GL_ATTRIBUTE_NONNULL ();

View File

@@ -1,6 +1,6 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010-2018 Free Software Foundation, Inc.
Copyright (C) 2010-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -118,7 +118,7 @@ heapify_down (void **array, size_t count, size_t initial,
{
size_t child = 2 * parent;
if (child < count && compare (array[child], array[child+1]) < 0)
if (child < count && compare (array[child], array[child + 1]) < 0)
child++;
if (compare (array[child], element) <= 0)
@@ -141,9 +141,9 @@ heapify_up (void **array, size_t count,
size_t k = count;
void *new_element = array[k];
while (k != 1 && compare (array[k/2], new_element) <= 0)
while (k != 1 && compare (array[k / 2], new_element) <= 0)
{
array[k] = array[k/2];
array[k] = array[k / 2];
k /= 2;
}

View File

@@ -1,6 +1,6 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010-2018 Free Software Foundation, Inc.
Copyright (C) 2010-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,7 +20,13 @@
#include <stddef.h>
struct heap *heap_alloc (int (*) (void const *, void const *), size_t);
void heap_free (struct heap *);
int heap_insert (struct heap *heap, void *item);
void *heap_remove_top (struct heap *heap);
struct heap;
void heap_free (struct heap *) _GL_ATTRIBUTE_NONNULL ();
struct heap *heap_alloc (int (*) (void const *, void const *), size_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (heap_free, 1)
_GL_ATTRIBUTE_RETURNS_NONNULL;
int heap_insert (struct heap *heap, void *item) _GL_ATTRIBUTE_NONNULL ();
void *heap_remove_top (struct heap *heap) _GL_ATTRIBUTE_NONNULL ();

View File

@@ -1,5 +1,5 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2018 Free Software Foundation, Inc.
Copyright (C) 2009-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,19 +19,16 @@
#include <config.h>
#include "mbsalign.h"
#include "minmax.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <wchar.h>
#include <wctype.h>
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/* Replace non printable chars.
Note \t and \n etc. are non printable.
Return 1 if replacement made, 0 otherwise. */
@@ -84,8 +81,8 @@ wc_truncate (wchar_t *wc, size_t width)
is always added to DEST.
A pointer to the terminating NUL is returned. */
static char*
mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
static char *
mbs_align_pad (char *dest, char const *dest_end, size_t n_spaces)
{
/* FIXME: Should we pad with "figure space" (\u2007)
if non ascii data present? */
@@ -109,14 +106,14 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
Update *WIDTH to indicate how many columns were used before padding. */
size_t
mbsalign (const char *src, char *dest, size_t dest_size,
mbsalign (char const *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags)
{
size_t ret = SIZE_MAX;
size_t src_size = strlen (src) + 1;
char *newstr = NULL;
wchar_t *str_wc = NULL;
const char *str_to_print = src;
char const *str_to_print = src;
size_t n_cols = src_size - 1;
size_t n_used_bytes = n_cols; /* Not including NUL */
size_t n_spaces = 0;
@@ -245,7 +242,7 @@ mbsalign_cleanup:
Return NULL on failure. */
char *
ambsalign (const char *src, size_t *width, mbs_align_t align, int flags)
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
{
size_t orig_width = *width;
size_t size = *width; /* Start with enough for unibyte mode. */

View File

@@ -1,5 +1,5 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2018 Free Software Foundation, Inc.
Copyright (C) 2009-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,6 +15,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <stddef.h>
#include <stdlib.h>
typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
@@ -52,8 +53,11 @@ enum {
};
size_t
mbsalign (const char *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags);
mbsalign (char const *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags)
_GL_ATTRIBUTE_NONNULL ();
char *
ambsalign (const char *src, size_t *width, mbs_align_t align, int flags);
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
_GL_ATTRIBUTE_NONNULL ();

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2018 Free Software Foundation, Inc.
Copyright (C) 1999-2023 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
This program is free software: you can redistribute it and/or modify
@@ -25,7 +25,7 @@
* so I can be a little bit experimental in the choice of RNGs here.
*
* This generator is based somewhat on RC4, but has analysis
* <http://burtleburtle.net/bob/rand/isaacafa.html>
* <https://burtleburtle.net/bob/rand/isaacafa.html>
* pointing to it actually being better. I like it because it's nice
* and fast, and because the author did good work analyzing it.
* --------------------------------------------------------------------

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2018 Free Software Foundation, Inc.
Copyright (C) 1999-2023 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
This program is free software: you can redistribute it and/or modify
@@ -59,7 +59,8 @@ struct isaac_state
isaac_word a, b, c; /* Extra variables */
};
void isaac_seed (struct isaac_state *);
void isaac_refill (struct isaac_state *, isaac_word[ISAAC_WORDS]);
void isaac_seed (struct isaac_state *) _GL_ATTRIBUTE_NONNULL ();
void isaac_refill (struct isaac_state *, isaac_word[ISAAC_WORDS])
_GL_ATTRIBUTE_NONNULL ();
#endif

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2018 Free Software Foundation, Inc.
Copyright (C) 2006-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2018 Free Software Foundation, Inc.
Copyright (C) 2006-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -32,11 +32,17 @@ typedef uintmax_t randint;
struct randint_source;
struct randint_source *randint_new (struct randread_source *);
struct randint_source *randint_all_new (char const *, size_t);
void randint_free (struct randint_source *) _GL_ATTRIBUTE_NONNULL ();
int randint_all_free (struct randint_source *) _GL_ATTRIBUTE_NONNULL ();
struct randint_source *randint_new (struct randread_source *)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (randint_free, 1)
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_RETURNS_NONNULL;
struct randint_source *randint_all_new (char const *, size_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (randint_all_free, 1);
struct randread_source *randint_get_source (struct randint_source const *)
_GL_ATTRIBUTE_PURE;
randint randint_genmax (struct randint_source *, randint genmax);
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_PURE;
randint randint_genmax (struct randint_source *, randint genmax)
_GL_ATTRIBUTE_NONNULL ();
/* Consume random data from *S to generate a random number in the range
0 .. CHOICES-1. CHOICES must be nonzero. */
@@ -46,7 +52,4 @@ randint_choose (struct randint_source *s, randint choices)
return randint_genmax (s, choices - 1);
}
void randint_free (struct randint_source *);
int randint_all_free (struct randint_source *);
#endif

View File

@@ -1,6 +1,6 @@
/* Generate random permutations.
Copyright (C) 2006-2018 Free Software Foundation, Inc.
Copyright (C) 2006-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,24 +19,29 @@
#include <config.h>
#include "hash.h"
#include "randperm.h"
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include "attribute.h"
#include "count-leading-zeros.h"
#include "hash.h"
#include "xalloc.h"
/* Return the ceiling of the log base 2 of N. If N is zero, return
an unspecified value. */
/* Return the floor of the log base 2 of N. If N is zero, return -1. */
static size_t _GL_ATTRIBUTE_CONST
ceil_lg (size_t n)
ATTRIBUTE_CONST static int
floor_lg (size_t n)
{
size_t b = 0;
for (n--; n != 0; n /= 2)
b++;
return b;
static_assert (SIZE_WIDTH <= ULLONG_WIDTH);
return (n == 0 ? -1
: SIZE_WIDTH <= UINT_WIDTH
? UINT_WIDTH - 1 - count_leading_zeros (n)
: SIZE_WIDTH <= ULONG_WIDTH
? ULONG_WIDTH - 1 - count_leading_zeros_l (n)
: ULLONG_WIDTH - 1 - count_leading_zeros_ll (n));
}
/* Return an upper bound on the number of random bytes needed to
@@ -48,10 +53,10 @@ randperm_bound (size_t h, size_t n)
{
/* Upper bound on number of bits needed to generate the first number
of the permutation. */
size_t lg_n = ceil_lg (n);
uintmax_t lg_n = floor_lg (n) + 1;
/* Upper bound on number of bits needed to generated the first H elements. */
size_t ar = lg_n * h;
uintmax_t ar = lg_n * h;
/* Convert the bit count to a byte count. */
size_t bound = (ar + CHAR_BIT - 1) / CHAR_BIT;
@@ -112,10 +117,10 @@ sparse_new (size_t size_hint)
index I in array V. */
static void
sparse_swap (sparse_map *sv, size_t* v, size_t i, size_t j)
sparse_swap (sparse_map *sv, size_t *v, size_t i, size_t j)
{
struct sparse_ent_ *v1 = hash_delete (sv, &(struct sparse_ent_) {i,0});
struct sparse_ent_ *v2 = hash_delete (sv, &(struct sparse_ent_) {j,0});
struct sparse_ent_ *v1 = hash_remove (sv, &(struct sparse_ent_) {i,0});
struct sparse_ent_ *v2 = hash_remove (sv, &(struct sparse_ent_) {j,0});
/* FIXME: reduce the frequency of these mallocs. */
if (!v1)

View File

@@ -1,4 +1,6 @@
#include "randint.h"
#include <stddef.h>
#include <stdlib.h>
size_t randperm_bound (size_t, size_t) _GL_ATTRIBUTE_CONST;
size_t *randperm_new (struct randint_source *, size_t, size_t);
size_t *randperm_new (struct randint_source *, size_t, size_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2018 Free Software Foundation, Inc.
Copyright (C) 2006-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,47 +29,27 @@
#include <exitfail.h>
#include <fcntl.h>
#include <quote.h>
#include <stdalign.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/random.h>
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "minmax.h"
#include "rand-isaac.h"
#include "stdio-safer.h"
#include "unlocked-io.h"
#include "xalloc.h"
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x) /* empty */
# endif
#endif
#ifndef ATTRIBUTE_NORETURN
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
#endif
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#if _STRING_ARCH_unaligned || _STRING_INLINE_unaligned
# define ALIGNED_POINTER(ptr, type) true
#else
# define ALIGNED_POINTER(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
#endif
#ifndef NAME_OF_NONCE_DEVICE
# define NAME_OF_NONCE_DEVICE "/dev/urandom"
#endif
/* The maximum buffer size used for reads of random data. Using the
value 2 * ISAAC_BYTES makes this the largest power of two that
would not otherwise cause struct randread_source to grow. */
@@ -120,7 +100,7 @@ struct randread_source
/* The default error handler. */
static void ATTRIBUTE_NORETURN
static void
randread_error (void const *file_name)
{
if (file_name)
@@ -143,51 +123,34 @@ simple_new (FILE *source, void const *handler_arg)
return s;
}
/* Put a nonce value into BUFFER, with size BUFSIZE, but do not get
more than BYTES_BOUND bytes' worth of random information from any
nonce device. */
/* Put a nonce value into BUFFER, with size BUFSIZE.
Return true on success, false (setting errno) on failure. */
static void
get_nonce (void *buffer, size_t bufsize, size_t bytes_bound)
static bool
get_nonce (void *buffer, size_t bufsize)
{
char *buf = buffer;
ssize_t seeded = 0;
/* Get some data from FD if available. */
int fd = open (NAME_OF_NONCE_DEVICE, O_RDONLY | O_BINARY);
if (0 <= fd)
char *buf = buffer, *buflim = buf + bufsize;
while (buf < buflim)
{
seeded = read (fd, buf, MIN (bufsize, bytes_bound));
if (seeded < 0)
seeded = 0;
close (fd);
ssize_t nbytes = getrandom (buf, buflim - buf, 0);
if (0 <= nbytes)
buf += nbytes;
else if (errno != EINTR)
return false;
}
/* If there's no nonce device, use a poor approximation
by getting the time of day, etc. */
#define ISAAC_SEED(type, initialize_v) \
if (seeded < bufsize) \
{ \
type v; \
size_t nbytes = MIN (sizeof v, bufsize - seeded); \
initialize_v; \
memcpy (buf + seeded, &v, nbytes); \
seeded += nbytes; \
}
ISAAC_SEED (struct timeval, gettimeofday (&v, NULL));
ISAAC_SEED (pid_t, v = getpid ());
ISAAC_SEED (pid_t, v = getppid ());
ISAAC_SEED (uid_t, v = getuid ());
ISAAC_SEED (uid_t, v = getgid ());
#ifdef lint
/* Normally we like having the extra randomness from uninitialized
parts of BUFFER. However, omit this randomness if we want to
avoid false-positives from memory-checking debugging tools. */
memset (buf + seeded, 0, bufsize - seeded);
#endif
return true;
}
/* Body of randread_free, broken out to pacify gcc -Wmismatched-dealloc. */
static int
randread_free_body (struct randread_source *s)
{
FILE *source = s->source;
explicit_bzero (s, sizeof *s);
free (s);
return source ? fclose (source) : 0;
}
/* Create and initialize a random data source from NAME, or use a
reasonable default source if NAME is null. BYTES_BOUND is an upper
@@ -221,8 +184,14 @@ randread_new (char const *name, size_t bytes_bound)
else
{
s->buf.isaac.buffered = 0;
get_nonce (s->buf.isaac.state.m, sizeof s->buf.isaac.state.m,
bytes_bound);
if (! get_nonce (s->buf.isaac.state.m,
MIN (sizeof s->buf.isaac.state.m, bytes_bound)))
{
int e = errno;
randread_free_body (s);
errno = e;
return NULL;
}
isaac_seed (&s->buf.isaac.state);
}
@@ -340,8 +309,5 @@ randread (struct randread_source *s, void *buf, size_t size)
int
randread_free (struct randread_source *s)
{
FILE *source = s->source;
explicit_bzero (s, sizeof *s);
free (s);
return (source ? fclose (source) : 0);
return randread_free_body (s);
}

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2018 Free Software Foundation, Inc.
Copyright (C) 2006-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,10 +24,14 @@
struct randread_source;
struct randread_source *randread_new (char const *, size_t);
void randread (struct randread_source *, void *, size_t);
void randread_set_handler (struct randread_source *, void (*) (void const *));
void randread_set_handler_arg (struct randread_source *, void const *);
int randread_free (struct randread_source *);
int randread_free (struct randread_source *) _GL_ATTRIBUTE_NONNULL ();
struct randread_source *randread_new (char const *, size_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (randread_free, 1);
void randread (struct randread_source *, void *, size_t)
_GL_ATTRIBUTE_NONNULL ();
void randread_set_handler (struct randread_source *, void (*) (void const *))
_GL_ATTRIBUTE_NONNULL ();
void randread_set_handler_arg (struct randread_source *, void const *)
_GL_ATTRIBUTE_NONNULL ((1));
#endif

View File

@@ -1,5 +1,5 @@
/* root-dev-ino.c -- get the device and inode numbers for '/'.
Copyright (C) 2003-2018 Free Software Foundation, Inc.
Copyright (C) 2003-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Root device and inode number checking.
Copyright (C) 2003-2018 Free Software Foundation, Inc.
Copyright (C) 2003-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
# include "same-inode.h"
struct dev_ino *
get_root_dev_ino (struct dev_ino *root_d_i);
get_root_dev_ino (struct dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL ();
/* These macros are common to the programs that support the
--preserve-root and --no-preserve-root options. */

View File

@@ -1,5 +1,5 @@
/* Include and determine availability of smack routines
Copyright (C) 2013-2018 Free Software Foundation, Inc.
Copyright (C) 2013-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,8 +17,6 @@
/* Here we replace or wrap the most common smack functions used by coreutils.
Others will need to be protected by HAVE_SMACK. */
#include <config.h>
#ifdef HAVE_SMACK
# include <sys/smack.h>
#else
@@ -29,7 +27,7 @@ smack_new_label_from_self (char **label)
}
static inline int
smack_set_label_for_self (const char *label)
smack_set_label_for_self (char const *label)
{
return -1;
}

View File

@@ -1,6 +1,6 @@
/* Compare integer strings.
Copyright (C) 2005-2018 Free Software Foundation, Inc.
Copyright (C) 2005-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,6 +21,8 @@
#include "strnumcmp-in.h"
#include <limits.h>
/* Compare strings A and B as integers without explicitly converting
them to machine numbers, to avoid overflow problems and perhaps
improve performance. */
@@ -28,5 +30,5 @@
int
strintcmp (char const *a, char const *b)
{
return numcompare (a, b, -1, -1);
return numcompare (a, b, CHAR_MAX + 1, CHAR_MAX + 1);
}

View File

@@ -1,6 +1,6 @@
/* Compare numeric strings. This is an internal include file.
Copyright (C) 1988-2018 Free Software Foundation, Inc.
Copyright (C) 1988-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -106,8 +106,8 @@ fraccompare (char const *a, char const *b, char decimal_point)
/* Compare strings A and B as numbers without explicitly converting
them to machine numbers, to avoid overflow problems and perhaps
improve performance. DECIMAL_POINT is the decimal point and
THOUSANDS_SEP the thousands separator. A DECIMAL_POINT of -1
causes comparisons to act as if there is no decimal point
THOUSANDS_SEP the thousands separator. A DECIMAL_POINT outside
'char' range causes comparisons to act as if there is no decimal point
character, and likewise for THOUSANDS_SEP. */
static inline int _GL_ATTRIBUTE_PURE

View File

@@ -1,6 +1,6 @@
/* Compare numeric strings.
Copyright (C) 2005-2018 Free Software Foundation, Inc.
Copyright (C) 2005-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
/* Externally-visible name for numcompare. */
int _GL_ATTRIBUTE_PURE
int
strnumcmp (char const *a, char const *b,
int decimal_point, int thousands_sep)
{

View File

@@ -1,2 +1,4 @@
int strintcmp (char const *, char const *) _GL_ATTRIBUTE_PURE;
int strnumcmp (char const *, char const *, int, int);
int strintcmp (char const *, char const *)
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_PURE;
int strnumcmp (char const *, char const *, int, int)
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_PURE;

118
gl/lib/targetdir.c Normal file
View File

@@ -0,0 +1,118 @@
/* Target directory operands for coreutils
Copyright 2004-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#define TARGETDIR_INLINE _GL_EXTERN_INLINE
#include <targetdir.h>
#include <attribute.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef O_PATH
enum { O_PATHSEARCH = O_PATH };
#else
enum { O_PATHSEARCH = O_SEARCH };
#endif
/* Must F designate the working directory? */
ATTRIBUTE_PURE static bool
must_be_working_directory (char const *f)
{
/* Return true for ".", "./.", ".///./", etc. */
while (*f++ == '.')
{
if (*f != '/')
return !*f;
while (*++f == '/')
continue;
if (!*f)
return true;
}
return false;
}
/* Return a file descriptor open to FILE, for use in openat.
As an optimization, return AT_FDCWD if FILE must be the working directory.
As a side effect, possibly set *ST to the file's status.
Fail and set errno if FILE is not a directory.
On failure return -2 if AT_FDCWD is -1, -1 otherwise. */
int
target_directory_operand (char const *file, struct stat *st)
{
if (must_be_working_directory (file))
return AT_FDCWD;
int fd = -1;
int try_to_open = 1;
int stat_result;
/* On old systems without O_DIRECTORY, like Solaris 10, check with
stat first lest we try to open a fifo for example and hang. */
if (!O_DIRECTORY)
{
stat_result = stat (file, st);
if (stat_result == 0)
{
try_to_open = S_ISDIR (st->st_mode);
errno = ENOTDIR;
}
else
{
/* On EOVERFLOW failure, give up on checking, as there is no
easy way to check. This should be rare. */
try_to_open = errno == EOVERFLOW;
}
}
if (try_to_open)
{
fd = open (file, O_PATHSEARCH | O_DIRECTORY);
/* On platforms lacking O_PATH, using O_SEARCH | O_DIRECTORY to
open an overly-protected non-directory can fail with either
EACCES or ENOTDIR. Prefer ENOTDIR as it makes for better
diagnostics. */
if (O_PATHSEARCH == O_SEARCH && fd < 0 && errno == EACCES)
errno = (((O_DIRECTORY ? stat (file, st) : stat_result) == 0
&& !S_ISDIR (st->st_mode))
? ENOTDIR : EACCES);
}
if (!O_DIRECTORY && 0 <= fd)
{
/* On old systems like Solaris 10 double check type,
to ensure we've opened a directory. */
int err;
if (fstat (fd, st) == 0
? !S_ISDIR (st->st_mode) && (err = ENOTDIR, true)
: (err = errno) != EOVERFLOW)
{
close (fd);
errno = err;
fd = -1;
}
}
return fd - (AT_FDCWD == -1 && fd < 0);
}

43
gl/lib/targetdir.h Normal file
View File

@@ -0,0 +1,43 @@
/* Target directory operands for coreutils
Copyright 2022-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <fcntl.h>
#include <sys/stat.h>
#ifndef _GL_INLINE_HEADER_BEGIN
# error "Please include config.h first."
#endif
_GL_INLINE_HEADER_BEGIN
#ifndef TARGETDIR_INLINE
# define TARGETDIR_INLINE _GL_INLINE
#endif
/* Return a file descriptor open to FILE, for use in openat.
As an optimization, return AT_FDCWD if FILE must be the working directory.
As a side effect, possibly set *ST to the file's status.
Fail and set errno if FILE is not a directory.
On failure return -2 if AT_FDCWD is -1, -1 otherwise. */
extern int target_directory_operand (char const *file, struct stat *st);
/* Return true if FD represents success for target_directory_operand. */
TARGETDIR_INLINE _GL_ATTRIBUTE_PURE bool
target_dirfd_valid (int fd)
{
return fd != -1 - (AT_FDCWD == -1);
}
_GL_INLINE_HEADER_END

View File

@@ -1,189 +0,0 @@
diff --git a/lib/tempname.c b/lib/tempname.c
index 69c572f..1920274 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -20,6 +20,7 @@
#if !_LIBC
# include <config.h>
# include "tempname.h"
+# include "randint.h"
#endif
#include <sys/types.h>
@@ -47,6 +48,7 @@
# error report this to bug-gnulib@gnu.org
#endif
+#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -173,28 +175,34 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
}
#endif /* _LIBC */
+static inline bool _GL_ATTRIBUTE_PURE
+check_x_suffix (char const *s, size_t len)
+{
+ return len <= strspn (s, "X");
+}
+
/* These are the characters used in temporary file names. */
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
int
-__try_tempname (char *tmpl, int suffixlen, void *args,
- int (*tryfunc) (char *, void *))
+try_tempname_len (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *), size_t x_suffix_len)
{
- int len;
+ size_t len;
char *XXXXXX;
- static uint64_t value;
- uint64_t random_time_bits;
unsigned int count;
int fd = -1;
int save_errno = errno;
+ struct randint_source *rand_src;
/* A lower bound on the number of temporary files to attempt to
generate. The maximum total number of temporary file names that
can exist for a given template is 62**6. It should never be
necessary to try all of these combinations. Instead if a reasonable
number of names is tried (we define reasonable as 62**3) fail to
- give the system administrator the chance to remove the problems. */
+ give the system administrator the chance to remove the problems.
+ This value requires that X_SUFFIX_LEN be at least 3. */
#define ATTEMPTS_MIN (62 * 62 * 62)
/* The number of times to attempt to generate a temporary file. To
@@ -206,57 +214,55 @@ __try_tempname (char *tmpl, int suffixlen, void *args,
#endif
len = strlen (tmpl);
- if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6))
+ if (len < x_suffix_len + suffixlen
+ || ! check_x_suffix (&tmpl[len - x_suffix_len - suffixlen],
+ x_suffix_len))
{
__set_errno (EINVAL);
return -1;
}
/* This is where the Xs start. */
- XXXXXX = &tmpl[len - 6 - suffixlen];
+ XXXXXX = &tmpl[len - x_suffix_len - suffixlen];
/* Get some more or less random data. */
-#ifdef RANDOM_BITS
- RANDOM_BITS (random_time_bits);
-#else
- {
- struct timeval tv;
- __gettimeofday (&tv, NULL);
- random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
- }
-#endif
- value += random_time_bits ^ __getpid ();
+ rand_src = randint_all_new (NULL, x_suffix_len);
+ if (! rand_src)
+ return -1;
- for (count = 0; count < attempts; value += 7777, ++count)
+ for (count = 0; count < attempts; ++count)
{
- uint64_t v = value;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % 62];
- v /= 62;
- XXXXXX[1] = letters[v % 62];
- v /= 62;
- XXXXXX[2] = letters[v % 62];
- v /= 62;
- XXXXXX[3] = letters[v % 62];
- v /= 62;
- XXXXXX[4] = letters[v % 62];
- v /= 62;
- XXXXXX[5] = letters[v % 62];
+ size_t i;
+
+ for (i = 0; i < x_suffix_len; i++)
+ XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)];
fd = tryfunc (tmpl, args);
if (fd >= 0)
{
__set_errno (save_errno);
- return fd;
+ goto done;
}
else if (errno != EEXIST)
- return -1;
+ {
+ fd = -1;
+ goto done;
+ }
}
+ randint_all_free (rand_src);
+
/* We got out of the loop because we ran out of combinations to try. */
__set_errno (EEXIST);
return -1;
+
+ done:
+ {
+ int saved_errno = errno;
+ randint_all_free (rand_src);
+ __set_errno (saved_errno);
+ }
+ return fd;
}
static int
@@ -285,9 +291,10 @@ try_nocreate (char *tmpl, void *flags _GL_UNUSED)
}
/* Generate a temporary file name based on TMPL. TMPL must match the
- rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
+ rules for mk[s]temp (i.e., end in at least X_SUFFIX_LEN "X"s,
+ possibly with a suffix).
The name constructed does not exist at the time of the call to
- __gen_tempname. TMPL is overwritten with the result.
+ this function. TMPL is overwritten with the result.
KIND may be one of:
__GT_NOCREATE: simply verify that the name does not exist
@@ -298,7 +305,8 @@ try_nocreate (char *tmpl, void *flags _GL_UNUSED)
We use a clever algorithm to get hard-to-predict names. */
int
-__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
+ size_t x_suffix_len)
{
int (*tryfunc) (char *, void *);
@@ -320,5 +328,18 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
assert (! "invalid KIND in __gen_tempname");
abort ();
}
- return __try_tempname (tmpl, suffixlen, &flags, tryfunc);
+ return try_tempname_len (tmpl, suffixlen, &flags, tryfunc, x_suffix_len);
+}
+
+int
+__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+{
+ return gen_tempname_len (tmpl, suffixlen, flags, kind, 6);
+}
+
+int
+__try_tempname (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *))
+{
+ return try_tempname_len (tmpl, suffixlen, args, tryfunc, 6);
}

View File

@@ -1,23 +0,0 @@
diff --git a/lib/tempname.h b/lib/tempname.h
index e609360..6029b9f 100644
--- a/lib/tempname.h
+++ b/lib/tempname.h
@@ -50,6 +50,8 @@ extern "C" {
We use a clever algorithm to get hard-to-predict names. */
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
+extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
+ size_t x_suffix_len);
/* Similar to gen_tempname, but TRYFUNC is called for each temporary
name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
@@ -57,6 +59,9 @@ extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
name is tried, or else TRY_GEN_TEMPNAME returns -1. */
extern int try_tempname (char *tmpl, int suffixlen, void *args,
int (*tryfunc) (char *, void *));
+extern int try_tempname_len (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *),
+ size_t x_suffix_len);
#ifdef __cplusplus
}

View File

@@ -1,6 +1,6 @@
/* Convert decimal strings with bounds checking and exit on error.
Copyright (C) 2014-2018 Free Software Foundation, Inc.
Copyright (C) 2014-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
#include "error.h"
#include "quote.h"
#include "verify.h"
#include "xstrtol.h"
/* Parse numeric string N_STR of base BASE, and return the value.
@@ -33,8 +34,8 @@
ERR is printed along with N_STR on error. */
__xdectoint_t
__xnumtoint (const char *n_str, int base, __xdectoint_t min, __xdectoint_t max,
const char *suffixes, const char *err, int err_exit)
__xnumtoint (char const *n_str, int base, __xdectoint_t min, __xdectoint_t max,
char const *suffixes, char const *err, int err_exit)
{
strtol_error s_err;
@@ -48,10 +49,10 @@ __xnumtoint (const char *n_str, int base, __xdectoint_t min, __xdectoint_t max,
s_err = LONGINT_OVERFLOW;
/* Use have the INT range as a heuristic to distinguish
type overflow rather than other min/max limits. */
if (tnum > INT_MAX/2)
if (tnum > INT_MAX / 2)
errno = EOVERFLOW;
#if __xdectoint_signed
else if (tnum < INT_MIN/2)
else if (tnum < INT_MIN / 2)
errno = EOVERFLOW;
#endif
else
@@ -68,6 +69,7 @@ __xnumtoint (const char *n_str, int base, __xdectoint_t min, __xdectoint_t max,
/* EINVAL error message is redundant in this context. */
error (err_exit ? err_exit : EXIT_FAILURE, errno == EINVAL ? 0 : errno,
"%s: %s", err, quote (n_str));
assume (false);
}
return tnum;
@@ -79,8 +81,8 @@ __xnumtoint (const char *n_str, int base, __xdectoint_t min, __xdectoint_t max,
ERR is printed along with N_STR on error. */
__xdectoint_t
__xdectoint (const char *n_str, __xdectoint_t min, __xdectoint_t max,
const char *suffixes, const char *err, int err_exit)
__xdectoint (char const *n_str, __xdectoint_t min, __xdectoint_t max,
char const *suffixes, char const *err, int err_exit)
{
return __xnumtoint (n_str, 10, min, max, suffixes, err, err_exit);
}

View File

@@ -1,6 +1,6 @@
/* Convert decimal strings with bounds checking and exit on error.
Copyright (C) 2014-2018 Free Software Foundation, Inc.
Copyright (C) 2014-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,11 +21,13 @@
# include <inttypes.h>
# define _DECLARE_XDECTOINT(name, type) \
type name (const char *n_str, type min, type max, \
const char *suffixes, const char *err, int err_exit);
type name (char const *n_str, type min, type max, \
char const *suffixes, char const *err, int err_exit) \
_GL_ATTRIBUTE_NONNULL ((1, 5));
# define _DECLARE_XNUMTOINT(name, type) \
type name (const char *n_str, int base, type min, type max, \
const char *suffixes, const char *err, int err_exit);
type name (char const *n_str, int base, type min, type max, \
char const *suffixes, char const *err, int err_exit) \
_GL_ATTRIBUTE_NONNULL ((1, 6));
_DECLARE_XDECTOINT (xdectoimax, intmax_t)
_DECLARE_XDECTOINT (xdectoumax, uintmax_t)

View File

@@ -1,6 +1,6 @@
/* xfts.c -- a wrapper for fts_open
Copyright (C) 2003-2018 Free Software Foundation, Inc.
Copyright (C) 2003-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
#include <config.h>
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>

View File

@@ -1,10 +1,11 @@
#include <stdbool.h>
#include "fts_.h"
FTS *
xfts_open (char * const *, int options,
int (*) (const FTSENT **, const FTSENT **));
int (*) (const FTSENT **, const FTSENT **))
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (fts_close, 1)
_GL_ATTRIBUTE_NONNULL ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
bool
cycle_warning_required (FTS const *fts, FTSENT const *ent)
_GL_ATTRIBUTE_PURE;
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_PURE;

24
gl/modules/cl-strtod Normal file
View File

@@ -0,0 +1,24 @@
Description:
Convert string to double in current or C locale.
Files:
lib/cl-strtod.c
lib/cl-strtod.h
Depends-on:
c-strtod
configure.ac:
AC_REQUIRE([AC_C_RESTRICT])
Makefile.am:
lib_SOURCES += cl-strtod.c
Include:
"cl-strtod.h"
License:
GPL
Maintainer:
all

25
gl/modules/cl-strtold Normal file
View File

@@ -0,0 +1,25 @@
Description:
Convert string to long double in current or C locale.
Files:
lib/cl-strtod.c
lib/cl-strtod.h
lib/cl-strtold.c
Depends-on:
c-strtold
configure.ac:
AC_REQUIRE([AC_C_RESTRICT])
Makefile.am:
lib_SOURCES += cl-strtold.c
Include:
"cl-strtod.h"
License:
GPL
Maintainer:
all

View File

@@ -6,6 +6,7 @@ lib/mbsalign.c
lib/mbsalign.h
Depends-on:
minmax
wchar
wctype
wcwidth

View File

@@ -6,7 +6,10 @@ lib/randperm.c
lib/randperm.h
Depends-on:
assert-h
count-leading-zeros
randint
stdint
xalloc
hash

View File

@@ -8,13 +8,14 @@ lib/randread.c
lib/randread.h
Depends-on:
alignasof
error
exitfail
inline
fopen-safer
gettimeofday
getrandom
quote
stdalign
minmax
stdbool
stdint
unlocked-io

View File

@@ -10,7 +10,7 @@ configure.ac:
# Check whether libsmack is available
LIB_SMACK=
AC_ARG_ENABLE([libsmack],
AC_HELP_STRING([--disable-libsmack], [disable libsmack support]))
AS_HELP_STRING([--disable-libsmack], [disable libsmack support]))
if test "X$enable_libsmack" != "Xno"; then
AC_CHECK_LIB([smack], [smack_new_label_from_self],
[AC_CHECK_LIB([smack], [smack_new_label_from_path],

25
gl/modules/targetdir Normal file
View File

@@ -0,0 +1,25 @@
Description:
Target directory operands
Files:
lib/targetdir.c
lib/targetdir.h
Depends-on:
attribute
fcntl-h
stdbool
configure.ac:
Makefile.am:
lib_SOURCES += targetdir.c targetdir.h
Include:
"targetdir.h"
License:
GPL
Maintainer:
all

View File

@@ -1,13 +0,0 @@
diff --git a/modules/tempname b/modules/tempname
index 570ea54..f1be8ff 100644
--- a/modules/tempname
+++ b/modules/tempname
@@ -12,6 +12,8 @@
fcntl-h
gettimeofday
lstat
+randint
+stdbool
stdint
sys_stat
sys_time

View File

@@ -11,6 +11,8 @@ Depends-on:
error
errno
quote
stdbool
verify
xstrtoimax
xstrtoumax

View File

@@ -1,5 +1,5 @@
/* Test that fadvise works as advertised.
Copyright (C) 2010-2018 Free Software Foundation, Inc.
Copyright (C) 2010-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Test that mbsalign works as advertised.
Copyright (C) 2010-2018 Free Software Foundation, Inc.
Copyright (C) 2010-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Test the ISAAC or ISAAC64 pseudorandom number generator.
Copyright (C) 2010-2018 Free Software Foundation, Inc.
Copyright (C) 2010-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
#include "macros.h"
/* This expected output was generated by running the programs in
<http://burtleburtle.net/bob/rand/isaacafa.html>, as last modified
<https://burtleburtle.net/bob/rand/isaacafa.html>, as last modified
on 2010-01-22. The 32-bit numbers were output by rand.c, and the
64-bit by isaac64.c, both on x86, as those programs are not
portable to 64-bit platforms. */

2
gnulib

Submodule gnulib updated: 16aa5a2efe...4b60490554

View File

@@ -1,6 +1,6 @@
# This file is sourced by init.sh, *before* its initialization.
# Copyright (C) 2010-2018 Free Software Foundation, Inc.
# Copyright (C) 2010-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -384,6 +384,7 @@ rwx_to_mode_()
# with a space.
stty_reversible_init_()
{
require_perl_
# Pad start with one space for the first option to match in query function.
stty_reversible_=' '$(perl -lne '/^ *{"(.*?)",.*\bREV\b/ and print $1' \
"$abs_top_srcdir"/src/stty.c | tr '\n' ' ')
@@ -487,12 +488,24 @@ require_membership_in_two_groups_()
{
test $# = 0 || framework_failure_
groups=${COREUTILS_GROUPS-$( (id -G || /usr/xpg4/bin/id -G) 2>/dev/null)}
groups=
for group_ in 1 \
${COREUTILS_GROUPS-$( (id -G || /usr/xpg4/bin/id -G) 2>/dev/null)}
do
# Skip group numbers equal to 2**N - 1 for common N,
# as they are possibly reserved groups like 'nogroup'.
case $group_ in
1 | 32767 | 65535 | 2147483647 | 4294967295) ;;
9223372036854775807 | 18446744073709551615) ;;
*) test -z "$groups" || groups="$groups "
groups="$groups$group_";;
esac
done
case "$groups" in
*' '*) ;;
*) skip_ 'requires membership in two groups
this test requires that you be a member of more than one group,
but running 'id -G'\'' either failed or found just one. If you really
but running '\''id -G'\'' either failed or found just one. If you really
are a member of at least two groups, then rerun this test with
COREUTILS_GROUPS set in your environment to the space-separated list
of group names or numbers. E.g.,
@@ -530,15 +543,36 @@ require_kill_group_()
}
# Return nonzero if the specified path is on a file system for
# which FIEMAP support exists. Note some file systems (like ext3 and btrfs)
# only support FIEMAP for files, not directories.
fiemap_capable_()
# which SEEK_DATA support exists.
seek_data_capable_()
{
if ! python < /dev/null; then
warn_ 'fiemap_capable_: python missing: assuming not fiemap capable'
return 1
# Check that SEEK_HOLE support is enabled
# Note APFS was seen to not create sparse files < 16MiB
if ! truncate -s16M file.sparse_; then
warn_ "can't create a sparse file: assuming not SEEK_DATA capable"
return 1
fi
python "$abs_srcdir"/tests/fiemap-capable "$@"
if ! cp --debug --reflink=never file.sparse_ file.sparse_.cp \
| grep SEEK_HOLE; then
return 1
fi
# Check that SEEK_HOLE is supported on the passed file
{ python3 < /dev/null && PYTHON_=python3; } ||
{ python < /dev/null && PYTHON_=python; }
if test x"$PYTHON_" = x; then
warn_ 'seek_data_capable_: python missing: assuming not SEEK_DATA capable'
return 1
fi
# Use timeout if available to skip cases where SEEK_DATA takes a long time.
# We saw FreeBSD 9.1 take 35s to return from SEEK_DATA for a 1TiB empty file.
# Note lseek() is uninterruptible on FreeBSD 9.1, but it does eventually
# return, and the timeout will ensure a failure return from the process.
timeout --version >/dev/null && TIMEOUT_='timeout 10'
$TIMEOUT_ $PYTHON_ "$abs_srcdir"/tests/seek-data-capable "$@"
}
# Skip the current test if "." lacks d_type support.
@@ -576,16 +610,19 @@ require_sparse_support_()
fi
}
# Libraries needed when we compile a shared library.
gcc_shared_libs_=
# Compile a shared lib using the GCC options for doing so.
# Pass input and output file as parameters respectively.
# Any other optional parmeters are passed to $CC.
# Any other optional parameters are passed to $CC.
gcc_shared_()
{
local in=$1
local out=$2
shift 2 || return 1
$CC -Wall -shared --std=gnu99 -fPIC -O2 $* "$in" -o "$out" -ldl
$CC -Wall -shared --std=gnu99 -fPIC -O2 $* "$in" -o "$out" $gcc_shared_libs_
}
# There are a myriad of ways to build shared libs,
@@ -593,8 +630,18 @@ gcc_shared_()
# on platforms that support building them as follows.
require_gcc_shared_()
{
gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1 \
|| skip_ '$CC -shared ... failed to build a shared lib'
# Try two different values for gcc_shared_libs_.
gcc_shared_libs_='-ldl'
if gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1; then
:
else
gcc_shared_libs_=
if gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1; then
:
else
skip_ '$CC -shared ... failed to build a shared lib'
fi
fi
rm -f d.so
}
@@ -604,12 +651,31 @@ mkfifo_or_skip_()
if ! mkfifo "$1"; then
# Make an exception of this case -- usually we interpret framework-creation
# failure as a test failure. However, in this case, when running on a SunOS
# system using a disk NFS mounted from OpenBSD, the above fails like this:
# system using a file system NFS mounted from OpenBSD, the above fails like
# this:
# mkfifo: cannot make fifo 'fifo-10558': Not owner
skip_ 'unable to create a fifo'
fi
}
trap_sigpipe_or_skip_()
{
timeout --version >/dev/null ||
skip_ 'trapping SIGPIPE cannot be safely checked'
(trap '' PIPE && timeout 10 yes |:) 2>&1 | grep 'Broken pipe' >/dev/null ||
skip_ 'trapping SIGPIPE is not supported'
}
require_bash_as_SHELL_()
{
if bash --version >/dev/null 2>&1; then
SHELL='bash'
else
skip_ 'bash is required'
fi
}
# Disable the current test if the working directory seems to have
# the setgid bit set.
skip_if_setgid_()

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise chdir-long's sample main program.
# Copyright (C) 2005-2018 Free Software Foundation, Inc.
# Copyright (C) 2005-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
# boottime.m4 serial 4
# Determine whether this system has infrastructure for obtaining the boot time.
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
# Copyright (C) 1996-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ AC_DEFUN([GNULIB_BOOT_TIME],
[#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif]])
AC_CHECK_HEADERS_ONCE([utmp.h utmpx.h OS.h])
AC_CHECK_HEADERS_ONCE([utmpx.h OS.h])
AC_CACHE_CHECK(
[whether we can get the system boot time],
[gnulib_cv_have_boot_time],
@@ -43,9 +43,8 @@ AC_DEFUN([GNULIB_BOOT_TIME],
#endif
#if HAVE_UTMPX_H
# include <utmpx.h>
#elif HAVE_UTMP_H
# include <utmp.h>
#endif
#include <utmp.h>
#if HAVE_OS_H
# include <OS.h>
#endif

View File

@@ -1,7 +1,7 @@
#serial 26
#serial 27
# Check declarations for this package.
dnl Copyright (C) 1997-2018 Free Software Foundation, Inc.
dnl Copyright (C) 1997-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -13,8 +13,6 @@ dnl Putting it in a separate file like this helps share it between
dnl different packages.
AC_DEFUN([gl_CHECK_DECLS],
[
AC_REQUIRE([AC_HEADER_TIME])
AC_CHECK_HEADERS_ONCE([grp.h pwd.h])
headers='
#include <sys/types.h>

View File

@@ -1,48 +0,0 @@
# Tests for GNU GMP (or any compatible replacement).
dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl Written by James Youngman.
dnl Check for libgmp. We avoid use of AC_CHECK_LIBS because we don't want to
dnl add this to $LIBS for all targets.
AC_DEFUN([cu_GMP],
[
LIB_GMP=
AC_SUBST([LIB_GMP])
AC_ARG_WITH([gmp],
AS_HELP_STRING([--without-gmp],
[do not use the GNU MP library for arbitrary precision
calculation (default: use it if available)]),
[cu_use_gmp=$withval],
[cu_use_gmp=auto])
if test $cu_use_gmp != no; then
dnl It was noticed on one MacOS X 10.5.8 system at least
dnl that the libs were available but the header wasn't
HAVE_GMP=0
AC_CHECK_HEADERS_ONCE([gmp.h])
if test $ac_cv_header_gmp_h = yes; then
cu_saved_libs=$LIBS
AC_SEARCH_LIBS([__gmpz_init], [gmp],
[test "$ac_cv_search___gmpz_init" = "none required" ||
LIB_GMP=$ac_cv_search___gmpz_init
AC_DEFINE([HAVE_GMP], [1],
[Define if you have GNU libgmp (or replacement)])
HAVE_GMP=1
# This only available in GMP >= 5
AC_CHECK_DECLS([mpz_inits], [], [], [[#include <gmp.h>]])
])
LIBS=$cu_saved_libs
fi
if test $HAVE_GMP != 1; then
AC_MSG_WARN([libgmp development library was not found or not usable.])
AC_MSG_WARN([AC_PACKAGE_NAME will be built without GMP support.])
fi
fi
])

View File

@@ -1,5 +1,5 @@
#serial 2
dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

View File

@@ -1,8 +1,8 @@
#serial 111 -*- autoconf -*-
#serial 114 -*- autoconf -*-
dnl Misc type-related macros for coreutils.
# Copyright (C) 1998-2018 Free Software Foundation, Inc.
# Copyright (C) 1998-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,9 +24,6 @@ AC_DEFUN([coreutils_MACROS],
AM_MISSING_PROG(HELP2MAN, help2man)
AC_SUBST([MAN])
dnl This macro actually runs replacement code. See isc-posix.m4.
AC_REQUIRE([AC_ISC_POSIX])dnl
gl_CHECK_ALL_TYPES
AC_REQUIRE([gl_CHECK_DECLS])
@@ -41,6 +38,10 @@ AC_DEFUN([coreutils_MACROS],
AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
[Define to the declaration of the xargmatch failure function.])
# Ensure VLAs are not used.
# Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
# used by shred
AC_CHECK_FUNCS_ONCE([directio])
@@ -48,27 +49,12 @@ AC_DEFUN([coreutils_MACROS],
LIBS="$LIBS $LIB_SELINUX"
# Used by selinux.c.
AC_CHECK_FUNCS([mode_to_security_class], [], [])
# Used by install.c.
AC_CHECK_FUNCS([matchpathcon_init_prefix], [],
[
if test "$with_selinux" != no; then
case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
no:*) # SELinux disabled
;;
*:no) # SELinux disabled
;;
*)
AC_MSG_WARN([SELinux enabled, but matchpathcon_init_prefix not found])
AC_MSG_WARN([The install utility may run slowly])
esac
fi
])
LIBS=$coreutils_saved_libs
# Used by sort.c.
AC_CHECK_FUNCS_ONCE([nl_langinfo])
# Used by timeout.c
AC_CHECK_FUNCS_ONCE([setrlimit prctl])
AC_CHECK_FUNCS_ONCE([setitimer setrlimit prctl])
# Used by tail.c.
AC_CHECK_FUNCS([inotify_init],
@@ -127,7 +113,7 @@ AC_DEFUN([coreutils_MACROS],
# Check whether libcap is usable -- for ls --color support
LIB_CAP=
AC_ARG_ENABLE([libcap],
AC_HELP_STRING([--disable-libcap], [disable libcap support]))
AS_HELP_STRING([--disable-libcap], [disable libcap support]))
if test "X$enable_libcap" != "Xno"; then
AC_CHECK_LIB([cap], [cap_get_file],
[AC_CHECK_HEADER([sys/capability.h],
@@ -153,29 +139,38 @@ AC_DEFUN([coreutils_MACROS],
# and doesn't have a separate math library.
AC_SUBST([SEQ_LIBM])
ac_seq_body='
static double x, y;
x = floor (x);
x = rint (x);
x = modf (x, &y);'
AC_TRY_LINK([#include <math.h>], [$ac_seq_body], ,
[ac_seq_save_LIBS="$LIBS"
LIBS="$LIBS -lm"
AC_TRY_LINK([#include <math.h>], [$ac_seq_body], [SEQ_LIBM=-lm])
LIBS="$ac_seq_save_LIBS"
])
jm_break=:
for jm_seqlibs in '' '-lm'; do
jm_seq_save_LIBS=$LIBS
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <math.h>
]],
[[static double x, y;
x = floor (x);
x = rint (x);
x = modf (x, &y);]])],
[SEQ_LIBM=$jm_seqlibs
jm_break=break])
LIBS=$jm_seq_save_LIBS
$jm_break
done
# See is fpsetprec() required to use extended double precision
# This is needed on 32 bit FreeBSD to give accurate conversion of:
# `numfmt 9223372036854775808`
AC_TRY_LINK([#include <ieeefp.h>],
[#ifdef __i386__
fpsetprec(FP_PE);
#else
# error not required on 64 bit
#endif
], [ac_have_fpsetprec=yes], [ac_have_fpsetprec=no])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <ieeefp.h>
]],
[[#ifdef __i386__
fpsetprec (FP_PE);
#else
# error not required on 64 bit
#endif
]])],
[ac_have_fpsetprec=yes],
[ac_have_fpsetprec=no])
if test "$ac_have_fpsetprec" = "yes" ; then
AC_DEFINE([HAVE_FPSETPREC], 1, [whether fpsetprec is present and required])
fi

View File

@@ -7,7 +7,7 @@ m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
# directory of the coreutils package.
# Copyright (C) 1998-2018 Free Software Foundation, Inc.
# Copyright (C) 1998-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
# stat-prog.m4 serial 7
# Record the prerequisites of src/stat.c from the coreutils package.
# Copyright (C) 2002-2018 Free Software Foundation, Inc.
# Copyright (C) 2002-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,43 +0,0 @@
# xattr.m4 - check for Extended Attributes (Linux)
# serial 3
# Copyright (C) 2003-2018 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# Originally written by Andreas Gruenbacher.
AC_DEFUN([gl_FUNC_XATTR],
[
AC_ARG_ENABLE([xattr],
AC_HELP_STRING([--disable-xattr],
[do not support extended attributes]),
[use_xattr=$enableval], [use_xattr=yes])
LIB_XATTR=
AC_SUBST([LIB_XATTR])
if test "$use_xattr" = "yes"; then
AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h])
use_xattr=no
if test $ac_cv_header_attr_libattr_h = yes \
&& test $ac_cv_header_attr_error_context_h = yes; then
xattr_saved_LIBS=$LIBS
AC_SEARCH_LIBS([attr_copy_file], [attr],
[test "$ac_cv_search_attr_copy_file" = "none required" ||
LIB_XATTR=$ac_cv_search_attr_copy_file])
AC_CHECK_FUNCS([attr_copy_file])
LIBS=$xattr_saved_LIBS
if test $ac_cv_func_attr_copy_file = yes; then
use_xattr=yes
fi
fi
if test $use_xattr = no; then
AC_MSG_WARN([libattr development library was not found or not usable.])
AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
fi
fi
AC_DEFINE_UNQUOTED([USE_XATTR], [`test $use_xattr != yes; echo $?`],
[Define if you want extended attribute support.])
])

1
man/.gitignore vendored
View File

@@ -3,6 +3,7 @@ Makefile.in
b2sum.1
base32.1
base64.1
basenc.1
basename.1
cat.1
chgrp.1

View File

@@ -2,3 +2,5 @@
b2sum \- compute and check BLAKE2 message digest
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
cksum(1)

View File

@@ -2,3 +2,5 @@
base32 \- base32 encode/decode data and print to standard output
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
basenc(1)

View File

@@ -2,3 +2,5 @@
base64 \- base64 encode/decode data and print to standard output
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
basenc(1)

38
man/basenc.x Normal file
View File

@@ -0,0 +1,38 @@
'\" Copyright (C) 2018-2023 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
'\" There is NO WARRANTY, to the extent permitted by law.
[NAME]
basenc \- Encode/decode data and print to standard output
[DESCRIPTION]
.\" Add any additional description here
[ENCODINGS EXAMPLES]
.PP
.nf
.RS
$ printf '\\376\\117\\202' | basenc \-\-base64
/k+C
$ printf '\\376\\117\\202' | basenc \-\-base64url
_k-C
$ printf '\\376\\117\\202' | basenc \-\-base32
7ZHYE===
$ printf '\\376\\117\\202' | basenc \-\-base32hex
VP7O4===
$ printf '\\376\\117\\202' | basenc \-\-base16
FE4F82
$ printf '\\376\\117\\202' | basenc \-\-base2lsbf
011111111111001001000001
$ printf '\\376\\117\\202' | basenc \-\-base2msbf
111111100100111110000010
$ printf '\\376\\117\\202\\000' | basenc \-\-z85
@.FaC
.RE
.fi

View File

@@ -3,4 +3,4 @@ cat \- concatenate files and print on the standard output
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
\fBtac\fP(1)
tac(1)

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2018 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
@@ -96,10 +96,12 @@ symbolic modes like
and
.BR g\-s .
To clear these bits for directories with a numeric mode requires
an additional leading zero, or leading = like
.B 00755
, or
.B =755
an additional leading zero like
.BR 00755 ,
leading minus like
.BR \-6000 ,
or leading equals like
.BR =755 .
.SH "RESTRICTED DELETION FLAG OR STICKY BIT"
The restricted deletion flag or sticky bit is a single bit, whose
interpretation depends on the file type. For directories, it prevents

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2018 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
[NAME]
cksum \- checksum and count the bytes in a file
cksum \- compute and verify file checksums
[DESCRIPTION]
.\" Add any additional description here

View File

@@ -1,23 +1,23 @@
'\" Copyright (C) 1998-2018 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
'\" There is NO WARRANTY, to the extent permitted by law.
[NAME]
df \- report file system disk space usage
df \- report file system space usage
[DESCRIPTION]
This manual page
documents the GNU version of
.BR df .
.B df
displays the amount of disk space available on the file system
displays the amount of space available on the file system
containing each file name argument. If no file name is given, the
space available on all currently mounted file systems is shown. Disk
space is shown in 1K blocks by default, unless the environment
space available on all currently mounted file systems is shown.
Space is shown in 1K blocks by default, unless the environment
variable POSIXLY_CORRECT is set, in which case 512-byte blocks are
used.
.PP
If an argument is the absolute file name of a disk device node containing a
If an argument is the absolute file name of a device node containing a
mounted file system,
.B df
shows the space available on that file system rather than on the

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2018 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2023 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

Some files were not shown because too many files have changed in this diff Show More