Compare commits

..

447 Commits
v9.0 ... 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
863 changed files with 8771 additions and 5502 deletions

View File

@@ -68,7 +68,7 @@ When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
<!--
Copyright (C) 2017-2021 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-2021 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

8
.gitignore vendored
View File

@@ -32,10 +32,12 @@
/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
@@ -48,6 +50,7 @@
/lib/alloca.h
/lib/arg-nonnull.h
/lib/arpa/inet.h
/lib/assert.h
/lib/byteswap.h
/lib/c++defs.h
/lib/charset.alias
@@ -57,12 +60,14 @@
/lib/ctype.h
/lib/dirent.h
/lib/errno.h
/lib/error.h
/lib/fcntl.h
/lib/float.h
/lib/fnmatch.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
@@ -94,9 +99,9 @@
/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
@@ -106,6 +111,7 @@
/lib/sys/
/lib/termios.h
/lib/time.h
/lib/unictype
/lib/unistd.h
/lib/unistr
/lib/unistr.h

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.32
9.2

View File

@@ -1,6 +1,6 @@
# Suppress valgrind diagnostics we don't care about.
# Copyright (C) 2003-2021 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

@@ -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-2021 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-2021 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.25
gen_start_ver = 8.29
.PHONY: gen-ChangeLog
gen-ChangeLog:
$(AM_V_GEN)if test -d .git; then \

367
NEWS
View File

@@ -1,5 +1,365 @@
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
@@ -67,6 +427,7 @@ GNU coreutils NEWS -*- outline -*-
** 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
@@ -2417,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,
@@ -3016,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)
@@ -5289,7 +5650,7 @@ packages, see ./old/*/NEWS.
========================================================================
Copyright (C) 2001-2021 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

138
README
View File

@@ -21,7 +21,8 @@ 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,6 +78,10 @@ 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 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
@@ -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-2021 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,34 +1,45 @@
-*- 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 file system space requirements:
@@ -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-2021 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,65 +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 pull --tags
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 https://git.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-2021 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

@@ -132,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
@@ -160,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
@@ -188,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
@@ -228,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
@@ -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-2021 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

249
bootstrap
View File

@@ -1,10 +1,10 @@
#! /bin/sh
# Print a version string.
scriptversion=2021-04-11.09; # UTC
scriptversion=2022-06-04.00; # UTC
# Bootstrap this package from checked-out sources.
# Copyright (C) 2003-2021 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
@@ -313,6 +313,116 @@ find_tool ()
eval "export $find_tool_envvar"
}
# Strip blank and comment lines to leave significant entries.
gitignore_entries() {
sed '/^#/d; /^$/d' "$@"
}
# If $STR is not already on a line by itself in $FILE, insert it at the start.
# Entries are inserted at the start of the ignore list to ensure existing
# entries starting with ! are not overridden. Such entries support
# whitelisting exceptions after a more generic blacklist pattern.
insert_if_absent() {
file=$1
str=$2
test -f $file || touch $file
test -r $file || die "Error: failed to read ignore file: $file"
duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
if [ "$duplicate_entries" ] ; then
die "Error: Duplicate entries in $file: " $duplicate_entries
fi
linesold=$(gitignore_entries $file | wc -l)
linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
if [ $linesold != $linesnew ] ; then
{ echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
|| die "insert_if_absent $file $str: failed"
fi
}
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
# insert_if_absent.
insert_vc_ignore() {
vc_ignore_file="$1"
pattern="$2"
case $vc_ignore_file in
*.gitignore)
# A .gitignore entry that does not start with '/' applies
# recursively to subdirectories, so prepend '/' to every
# .gitignore entry.
pattern=$(echo "$pattern" | sed s,^,/,);;
esac
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".
@@ -375,50 +485,9 @@ 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' "$@"
}
# If $STR is not already on a line by itself in $FILE, insert it at the start.
# Entries are inserted at the start of the ignore list to ensure existing
# entries starting with ! are not overridden. Such entries support
# whitelisting exceptions after a more generic blacklist pattern.
insert_if_absent() {
file=$1
str=$2
test -f $file || touch $file
test -r $file || die "Error: failed to read ignore file: $file"
duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
if [ "$duplicate_entries" ] ; then
die "Error: Duplicate entries in $file: " $duplicate_entries
fi
linesold=$(gitignore_entries $file | wc -l)
linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
if [ $linesold != $linesnew ] ; then
{ echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
|| die "insert_if_absent $file $str: failed"
fi
}
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
# insert_if_absent.
insert_vc_ignore() {
vc_ignore_file="$1"
pattern="$2"
case $vc_ignore_file in
*.gitignore)
# A .gitignore entry that does not start with '/' applies
# recursively to subdirectories, so prepend '/' to every
# .gitignore entry.
pattern=$(echo "$pattern" | sed s,^,/,);;
esac
insert_if_absent "$vc_ignore_file" "$pattern"
}
# 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
@@ -694,9 +763,26 @@ if $use_gnulib; then
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
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
git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \
|| cleanup_gnulib
trap - 1 2 13 15
fi
@@ -813,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
@@ -1093,7 +1110,7 @@ bootstrap_epilogue
echo "$0: done. Now you can run './configure'."
# Local variables:
# Local Variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Copyright (C) 2006-2021 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,13 +26,17 @@ 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
@@ -56,6 +60,7 @@ gnulib_modules="
config-h
configmake
copy-file-range
count-leading-zeros
crypto/md5
crypto/sha1
crypto/sha256
@@ -79,6 +84,8 @@ gnulib_modules="
faccessat
fadvise
fchdir
fchmodat
fchownat
fclose
fcntl
fcntl-safer
@@ -96,6 +103,7 @@ gnulib_modules="
fnmatch-gnu
fopen-safer
fprintftime
free-posix
freopen
freopen-safer
fseeko
@@ -118,6 +126,7 @@ gnulib_modules="
getpass-gnu
gettext-h
gettime
gettime-res
getugroups
getusershell
git-version-gen
@@ -172,7 +181,9 @@ gnulib_modules="
mkancesdirs
mkdir
mkdir-p
mkdirat
mkfifo
mkfifoat
mknod
mkostemp
mkstemp
@@ -181,7 +192,6 @@ gnulib_modules="
mountlist
mpsort
netinet_in
non-recursive-gnulib-prefix-hack
nproc
nstrftime
obstack
@@ -240,7 +250,6 @@ gnulib_modules="
stat-macros
stat-size
stat-time
statat
stdbool
stdlib-safer
stpcpy
@@ -256,11 +265,13 @@ gnulib_modules="
sys_resource
sys_stat
sys_wait
targetdir
tempname
termios
time_rz
timer-time
timespec
tmpfile
tzset
uname
unicodeio
@@ -276,6 +287,7 @@ gnulib_modules="
userspec
utimecmp
utimens
utimensat
vasprintf-posix
vc-list-files
verify
@@ -287,6 +299,7 @@ gnulib_modules="
winsz-ioctl
winsz-termios
write-any-file
xalignalloc
xalloc
xbinary-io
xdectoint
@@ -305,7 +318,7 @@ gnulib_modules="
xstrtol-error
xstrtold
xstrtoumax
year2038
year2038-required
yesno
"
@@ -338,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
@@ -372,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

@@ -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

64
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2003-2021 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
@@ -49,7 +49,7 @@ export VERBOSE = yes
# 4914152 9e
export XZ_OPT = -8e
old_NEWS_hash = ad874c61dc38785cb432159b725fc3de
old_NEWS_hash = 72a8f8283d3c9daef72e06be5bb52734
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = ' && !/^cu_install_prog/ && !/dynamic-dep/'
@@ -76,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); \
@@ -116,7 +116,7 @@ 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.
@@ -192,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' \
@@ -236,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; } \
|| :
@@ -366,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
@@ -441,15 +446,13 @@ 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)
@@ -502,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; } || :
@@ -514,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)
@@ -551,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 . && \
@@ -574,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)
@@ -593,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)
@@ -651,7 +654,7 @@ sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
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; \
@@ -784,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)
@@ -839,9 +842,9 @@ exclude_file_name_regexp--sc_bindtextdomain = \
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|find-mount-point)\.h|make-prime-list\.c)$$
^src/((die|system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
_src = (crctab|false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
_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/$(_gl_src)\.c|src/$(_src)\.c)$$
@@ -860,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.
@@ -882,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 = \
@@ -898,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-2021 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
@@ -57,6 +57,7 @@ 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])
@@ -64,11 +65,7 @@ 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,6 +85,50 @@ 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@<:@=TYPE@:>@],
[control generation of GCC warnings. The TYPE 'no' disables
@@ -150,9 +191,14 @@ if test $gl_gcc_warnings != no; 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:
@@ -224,42 +270,13 @@ if test $gl_gcc_warnings != no; 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=
@@ -320,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

File diff suppressed because it is too large Load Diff

View File

@@ -414,7 +414,7 @@ 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/copyleft/}.
@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

View File

@@ -1,7 +1,7 @@
# Make coreutils documentation. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 1995-2021 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

View File

@@ -1,6 +1,6 @@
@c File mode bits
@c Copyright (C) 1994--2021 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

View File

@@ -1,6 +1,6 @@
@c GNU Version-sort ordering documentation
@c Copyright (C) 2019--2021 Free Software Foundation, Inc.
@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
@@ -19,18 +19,17 @@
@node Version sort overview
@section Version sort overview
@dfn{version sort} ordering (and similarly, @dfn{natural sort}
ordering) is a method to sort items such as file names and lines of
text in an order that feels more natural to people, when the text
@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.
Standard sorting usually does not produce the order that one expects
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
Alphabetical sort: Version Sort:
Lexicographic sort: Version Sort:
a1 a1
a120 a2
@@ -38,18 +37,19 @@ 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}, @samp{sort --version-sort} commands.
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
@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}.
Two GNU Coreutils programs use version sort: @command{ls} and @command{sort}.
To list files in version sort order, use @command{ls}
with @option{-v} or @option{--sort=version} options:
with the @option{-v} or @option{--sort=version} option:
@example
default sort: version sort:
@@ -64,7 +64,7 @@ a2 a100
@end example
To sort text files in version sort order, use @command{sort} with
the @option{-V} option:
the @option{-V} or @option{--version-sort} option:
@example
$ cat input
@@ -74,7 +74,7 @@ b1
b20
alphabetical order: version sort order:
lexicographic order: version sort order:
$ sort input $ sort -V input
b1 b1
@@ -83,71 +83,71 @@ b20 b11
b3 b20
@end example
To sort a specific column in a file use @option{-k/--key} with @samp{V}
ordering option:
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
1000 b3 apples
100 b3 apples
2000 b11 oranges
3000 b1 potatoes
4000 b20 bananas
$ sort -k2V,2 input2
$ sort -k 2bV,2 input2
3000 b1 potatoes
1000 b3 apples
100 b3 apples
2000 b11 oranges
4000 b20 bananas
@end example
@node Origin of version sort and differences from natural sort
@subsection Origin of version sort and differences from natural sort
@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
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 the question
``which package is newer, @file{firefox-60.7.2} or @file{firefox-60.12.3} ?''
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
In Coreutils this algorithm was slightly modified to work on more
general input such as textual strings and file names
(see @ref{Differences from the official Debian Algorithm}).
(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 Correct/Incorrect ordering and Expected/Unexpected results
@subsection Correct/Incorrect ordering and Expected/Unexpected results
@node Variations in version sort order
@subsection Variations in version sort order
Currently there is no standard for version/natural sort ordering.
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 'natural sort' (or other various
names).
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 do suspect a bug in coreutils' implementation of version-sort,
see @ref{Reporting bugs or incorrect results} on how to report them.
If you find a bug in the Coreutils implementation of version-sort, please
report it. @xref{Reporting version sort bugs}.
@node Implementation Details
@section Implementation Details
@node Version sort implementation
@section Version sort implementation
GNU coreutils' version sort algorithm is based on
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}, specifically on the "upstream version"
part.
Debian's versioning scheme}.
This section describes the ordering rules.
This section describes the GNU Coreutils sort ordering rules.
The next section (@ref{Differences from the official Debian
Algorithm}) describes some differences between GNU coreutils
implementation and Debian's official algorithm.
The next section (@ref{Differences from Debian version
sort}) describes some differences between GNU Coreutils
and Debian version sort.
@node Version-sort ordering rules
@@ -161,33 +161,40 @@ The strings are compared from left to right.
@item
First the initial part of each string consisting entirely of non-digit
characters is determined.
bytes is determined.
@enumerate
@enumerate A
@item
These two parts (one of which may be empty) are compared lexically.
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 comparison of ASCII values modified so that:
The lexical comparison is a lexicographic comparison of byte strings,
except that:
@enumerate
@enumerate a
@item
all the letters sort earlier than all the non-letters and
ASCII letters sort before other bytes.
@item
so that a tilde sorts before anything, even the end of a part.
A tilde sorts before anything, even an empty string.
@end enumerate
@end enumerate
@item
Then the initial part of the remainder of each string which consists
entirely of digit characters is determined. The numerical values of
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
@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
@@ -202,8 +209,8 @@ down to the following parts, and the parts compared respectively from
each string:
@example
foo @r{vs} foo @r{(rule 2, non-digits characters)}
07 @r{vs} 7 @r{(rule 3, digits characters)}
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)}
@@ -213,23 +220,23 @@ Comparison flow based on above algorithm:
@enumerate
@item
The first parts (@code{foo}) are identical in both strings.
The first parts (@samp{foo}) are identical.
@item
The second parts (@code{07} and @code{7}) are compared numerically,
and are identical.
The second parts (@samp{07} and @samp{7}) are compared numerically,
and compare equal.
@item
The third parts (@samp{@code{.}} vs @samp{@code{a.}}) are compared
lexically by ASCII value (rule 2.2).
The third parts (@samp{.} vs @samp{a.}) are compared
lexically by ASCII value (rule 2.B).
@item
The first character of the first string (@samp{@code{.}}) is compared
to the first character of the second string (@samp{@code{a}}).
The first byte of the first string (@samp{.}) is compared
to the first byte of the second string (@samp{a}).
@item
Rule 2.2.1 dictates that "all letters sorts earlier than all non-letters".
Hence, @samp{@code{a}} comes before @samp{@code{.}}.
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}.
@@ -241,14 +248,13 @@ Result when using sort:
$ cat input3
foo07.7z
foo7a.7z
$ sort -V input3
foo7a.7z
foo07.7z
@end example
See @ref{Differences from the official Debian Algorithm} for
additional rules that extend the Debian algorithm in coreutils.
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
@@ -266,8 +272,6 @@ $ cat input4
8.100
8.49
Numerical Sort: Version Sort:
$ sort -n input4 $ sort -V input4
@@ -281,64 +285,63 @@ $ sort -n input4 $ sort -V input4
@end example
Numeric sort (@samp{sort -n}) treats the entire string as a single numeric
value, and compares it to other values. For example, @code{8.1}, @code{8.10} and
@code{8.100} are numerically equivalent, and are ordered together. Similarly,
@code{8.49} is numerically smaller than @code{8.5}, and appears before first.
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 digits and
non-digits parts, and only then compares each part (see annotated
example in Version-sort ordering rules).
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 @code{8.1} to @code{8.01}, first the
@samp{@code{8}} characters are compared (and are identical), then the
dots (@samp{@code{.}}) are compared and are identical, and lastly the
remaining digits are compared numerically (@code{1} and @code{01}) -
which are numerically equivalent. Hence, @code{8.01} and @code{8.1}
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 @code{8.5} to @code{8.49} - the @samp{@code{8}}
and @samp{@code{.}} parts are identical, then the numeric values @code{5} and
@code{49} are compared. The resulting @code{5} appears before @code{49}.
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 @code{8.5} comes before @code{8.49}) is common when
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).
or ``natural'' for people).
@node Punctuation Characters
@subsection Punctuation Characters
@node Version sort punctuation
@subsection Version sort punctuation
Punctuation characters are sorted by ASCII order (rule 2.2).
Punctuation is sorted by ASCII order (rule 2.B).
@example
$ touch 1.0.5_src.tar.gz 1.0_src.tar.gz
$ 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} ?
Why is @file{1.0.5_src.tar.gz} listed before @file{1.0_src.tar.gz}?
Based on the @ref{Version-sort ordering rules,algorithm,algorithm}
above, the strings are broken down into the following parts:
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 digit characters)}
. @r{vs} . @r{(rule 2, all non-digit characters)}
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 character in the file name)}
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{@code{.}} and @code{_src.tar.gz}) are compared
lexically by ASCII order. The character @samp{@code{.}} (ASCII value 46) is
smaller than @samp{@code{_}} (ASCII value 95) - and should be listed before it.
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 character appears instead of the underscore (for
example, percent sign @samp{@code{%}} ASCII value 37, which is smaller
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
@@ -347,55 +350,52 @@ $ touch 1.0.5_src.tar.gz 1.0%zzzzz.gz
1.0.5_src.tar.gz
@end example
The same reasoning applies to the following example: The character
@samp{@code{.}} has ASCII value 46, and is smaller than slash
character @samp{@code{/}} ASCII value 47:
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 Characters vs letters
@subsection Punctuation Characters vs letters
@node Punctuation vs letters
@subsection Punctuation vs letters
Rule 2.2.1 dictates that letters sorts earlier than all non-letters
(after breaking down a string to digits and non-digits parts).
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-digit characters
(@samp{@code{a%}} vs @samp{@code{az}}).
above algorithm have only one part, all non-digits
(@samp{a%} vs @samp{az}).
Each part is then compared lexically,
character-by-character. @samp{@code{a}} compares identically in both
byte-by-byte; @samp{a} compares identically in both
strings.
Rule 2.2.1 dictates that letters (@samp{@code{z}}) sorts earlier than all
non-letters (@samp{@code{%}}) - hence @samp{@code{az}} appears first (despite
@samp{@code{z}} having ASCII value of 122, much bigger than @samp{@code{%}}
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 Tilde @samp{~} character
@subsection Tilde @samp{~} character
@node The tilde @samp{~}
@subsection The tilde @samp{~}
Rule 2.2.2 dictates that tilde character @samp{@code{~}} (ASCII 126) sorts
before all other non-digit characters, including an empty part.
Rule 2.B.b says the tilde @samp{~} (ASCII 126) sorts
before other bytes, and before an empty string.
@example
$ cat input7
@@ -404,7 +404,6 @@ $ cat input7
1.2
1~
~
$ sort -V input7
~
1~
@@ -414,42 +413,42 @@ $ sort -V input7
@end example
The sorting algorithm starts by breaking down the string into
non-digits (rule 2) and digits parts (rule 3).
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{@code{~}}). This is the first part. All other lines
in the input file start with a digit - their first non-digit part is
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.2.2, tilde @samp{@code{~}} sorts before all other non-digits
including the empty part - hence it comes before all other strings,
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 (@code{1}, @code{1%}, @code{1.2}, @code{1~})
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 identical. The following extracted parts for the remaining
input lines are: empty part, @code{%}, @code{.}, @code{~}.
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 @code{1~} appears next.
Tilde sorts before all others, hence the line @samp{1~} appears next.
The remaining lines (@code{1}, @code{1%}, @code{1.2}) are sorted based
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 uses ASCII order, ignores locale, unicode characters
@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
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 (e.g. Greek Small Letter Alpha
U+03B1 @samp{α}) are encoded as UTF-8 bytes (e.g. @samp{α} is encoded as UTF-8
sequence @code{0xCE 0xB1}). The encoding will be compared byte-by-byte,
e.g. first @code{0xCE} (decimal value 206) then @code{0xB1} (decimal value 177).
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α"
$ touch aa az "a%" "aα"
$ ls -1 -v
aa
az
@@ -457,32 +456,32 @@ a%
aα
@end example
Ignoring the first letter (@code{a}) which is identical in all
Ignoring the first letter (@samp{a}) which is identical in all
strings, the compared values are:
@samp{@code{a}} and @samp{@code{z}} are letters, and sort earlier than
all other non-digit characters.
@samp{a} and @samp{z} are letters, and sort before
all other non-digits.
Then, percent sign @samp{@code{%}} (ASCII value 37) is compared to the
first byte of the UTF-8 sequence of @samp{@code{α}}, which is 0xCE or 206). The
value 37 is smaller, hence @samp{@code{a%}} is listed before @samp{@code{aα}}.
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 the official Debian Algorithm
@section Differences from the official Debian Algorithm
@node Differences from Debian version sort
@section Differences from Debian version sort
The GNU coreutils' version sort algorithm differs slightly from the
GNU Coreutils version sort differs slightly from the
official Debian algorithm, in order to accommodate more general usage
and file name listing.
@node Minus/Hyphen and Colon characters
@subsection Minus/Hyphen @samp{-} and Colon @samp{:} characters
@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 @code{epoch} and @code{debian_revision} parts are optional.
The @samp{epoch} and @samp{debian_revision} parts are optional.
Example of such version strings:
@@ -495,62 +494,62 @@ Example of such version strings:
2:1.19.2-1+deb9u5
@end example
If the @code{debian_revision part} is not present,
hyphen characters @samp{-} are not allowed.
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
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 characters (i.e., they are sorted after
letters. See Punctuation Characters above).
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:
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 abb ab-cd
$ touch 1ab-cd 1abb
$ ls -v -1
abb
ab-cd
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
With Debian's @command{dpkg} they will be listed as @code{ab-cd} first and
@code{abb} second.
For further details, see @ref{Comparing two strings using Debian's
algorithm} and @uref{https://bugs.gnu.org/35939,GNU Bug 35939}.
For further technical details see @uref{https://bugs.gnu.org/35939,bug35939}.
@node Special priority in GNU Coreutils version sort
@subsection Special priority in GNU Coreutils version sort
@node Additional hard-coded priorities in GNU coreutils' version sort
@subsection Additional hard-coded priorities in GNU coreutils' version sort
In GNU coreutils' version sort algorithm, the following items have
special priority and sort earlier than all other characters (listed in
order);
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{@code{.}} (a single dot character, ASCII 46)
@item The string @samp{.} (a single dot, ASCII 46)
@item The string @samp{@code{..}} (two dot characters)
@item The string @samp{..} (two dots)
@item Strings start with a dot (@samp{@code{.}}) sort earlier than
strings starting with any other characters.
@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
$ printf '%s\n' a "" b "." c ".." ".d20" ".d3" | sort -V
.
..
.d3
@@ -561,7 +560,7 @@ c
@end example
These priorities make perfect sense for @samp{ls -v}: The special
files dot @samp{@code{.}} and dot-dot @samp{@code{..}} will be listed
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.
@@ -572,71 +571,78 @@ program, the ordering rules are the same.
@node Special handling of file extensions
@subsection Special handling of file extensions
GNU coreutils' version sort algorithm implements specialized handling
of file extensions (or strings that look like file names with
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.
This nuanced implementation enables slightly more natural ordering of files.
The additional rules are:
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 a
letter or tilde, followed by one or more letters, digits, or tildes
(possibly repeated more than once), until the end of the string
(technically, matching the regular expression
@code{(\.[A-Za-z~][A-Za-z0-9~]*)*}).
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
If the strings contains suffixes, the suffixes are temporarily
removed, and the strings are compared without them (using the
@ref{Version-sort ordering rules,algorithm,algorithm} above).
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 are identical, the suffix is restored and
the entire strings are compared.
If the suffix-less strings do not compare equal, this comparison
result is used and the suffixes are effectively ignored.
@item
If the non-suffixed strings differ, the result is returned and the
suffix is effectively ignored.
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
@code{hello-8.txt}: the suffix is @code{.txt}
@samp{hello-8.txt}: the suffix is @samp{.txt}
@item
@code{hello-8.2.txt}: the suffix is @code{.txt}
(@samp{@code{.2}} is not included because the dot is not followed by a letter)
@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
@code{hello-8.0.12.tar.gz}: the suffix is @code{.tar.gz} (@samp{@code{.0.12}}
@samp{hello-8.0.12.tar.gz}: the suffix is @samp{.tar.gz} (@samp{.0.12}
is not included)
@item
@code{hello-8.2}: no suffix (suffix is an empty string)
@samp{hello-8.2}: no suffix (suffix is an empty string)
@item
@code{hello.foobar65}: the suffix is @code{.foobar65}
@samp{hello.foobar65}: the suffix is @samp{.foobar65}
@item
@code{gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2}: the suffix is
@code{.fc9.tar.bz2} (@code{.7rc2} is not included as it begins with a digit)
@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 @code{hello-8.txt} to @code{hello-8.2.12.txt}, the
@code{.txt} suffix is temporarily removed from both strings.
Comparing @samp{hello-8.txt} to @samp{hello-8.2.12.txt}, the
@samp{.txt} suffix is temporarily removed from both strings.
@item
Comparing @code{foo-10.3.tar.gz} to @code{foo-10.tar.xz}, the suffixes
@code{.tar.gz} and @code{.tar.xz} are temporarily removed from the
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
@@ -644,10 +650,10 @@ Example for rule 3:
@itemize
@item
Comparing @code{hello.foobar65} to @code{hello.foobar4}, the suffixes
(@code{.foobar65} and @code{.foobar4}) are temporarily removed. The
remaining strings are identical (@code{hello}). The suffixes are then
restored, and the entire strings are compared (@code{hello.foobar4} comes
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
@@ -655,10 +661,10 @@ Examples for rule 4:
@itemize
@item
When comparing the strings @code{hello-8.2.txt} and @code{hello-8.10.txt}, the
suffixes (@code{.txt}) are temporarily removed. The remaining strings
(@code{hello-8.2} and @code{hello-8.10}) are compared as previously described
(@code{hello-8.2} comes first).
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
@@ -671,15 +677,15 @@ 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-digit characters)}
8 @r{vs} 8 @r{(rule 3, all digit characters)}
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{@code{.}} vs
@samp{@code{.txt}}) will determine that the shorter string comes first -
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.
@@ -687,17 +693,17 @@ 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 (@code{.txt}) are removed, and the remaining strings are
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-digit characters)}
8 @r{vs} 8 @r{(rule 3, all digit characters)}
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 @code{hello-8}
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:
@@ -714,10 +720,6 @@ because the sorting code is shared between the @command{ls} and @command{sort}
program, the ordering rules are the same.
@node Advanced Topics
@section Advanced Topics
@node Comparing two strings using Debian's algorithm
@subsection Comparing two strings using Debian's algorithm
@@ -730,13 +732,14 @@ following snippet to your shell command-prompt):
@example
compver() @{
dpkg --compare-versions "$1" lt "$2" \
&& printf "%s\n" "$1" "$2" \
|| printf "%s\n" "$2" "$1" ; \
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 compver:
Then compare two strings by calling @command{compver}:
@example
$ compver 8.49 8.5
@@ -754,7 +757,6 @@ 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
@@ -763,11 +765,11 @@ dpkg: warning: version '3.0/' has bad syntax:
@end example
To illustrate the different handling of hyphens between Debian and
coreutils' algorithms (see
@ref{Minus/Hyphen and Colon characters}):
Coreutils algorithms (see
@ref{Hyphen-minus and colon}):
@example
$ compver abb ab-cd 2>/dev/null $ printf "abb\nab-cd\n" | sort -V
$ compver abb ab-cd 2>/dev/null $ printf 'abb\nab-cd\n' | sort -V
ab-cd abb
abb ab-cd
@end example
@@ -779,30 +781,32 @@ handling of file extensions}):
$ 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
$ 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 bugs or incorrect results
@subsection Reporting bugs or incorrect results
If you suspect a bug in GNU coreutils' version sort (i.e., in the
@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.
@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 the official Debian Algorithm}? If it is,
then this is not a bug - please do not report it.
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
@@ -833,7 +837,7 @@ Natural Sorting variants in
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}).
natsort -- how it works}).
@item
Ruby's @uref{https://github.com/github/version_sorter,version_sorter}.
@@ -855,16 +859,16 @@ 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} @code{*(n)} will expand to files in natural sort order.
glob modifier} @samp{*(n)} will expand to files in natural sort order.
@item
When writing @code{C} programs, the GNU libc library (@code{glibc})
When writing C programs, the GNU libc library (@samp{glibc})
provides the
@uref{http://man7.org/linux/man-pages/man3/strverscmp.3.html,
@uref{https://man7.org/linux/man-pages/man3/strverscmp.3.html,
strvercmp(3)} function to compare two strings, and
@uref{http://man7.org/linux/man-pages/man3/versionsort.3.html,versionsort(3)}
@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).
not identical to GNU Coreutils version sort ordering).
@item
Using Debian's sorting algorithm in:
@@ -882,8 +886,8 @@ deb-version-compare}.
@end itemize
@node Related Source code
@subsection Related Source code
@node Related source code
@subsection Related source code
@itemize
@@ -899,7 +903,7 @@ Debian's code which performs the @code{upstream_version} comparison:
version.c}.
@item
GNULIB code (used by GNU coreutils) which performs the version comparison:
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-2021 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,6 +1,6 @@
/* Convert string to double in the current locale, falling back on the C locale.
Copyright 2019-2021 Free Software Foundation, Inc.
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

View File

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

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2021 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-2021 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-2021 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-2021 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-2021 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-2021 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-2021 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? */

View File

@@ -1,5 +1,5 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2021 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;
@@ -53,7 +54,10 @@ enum {
size_t
mbsalign (char const *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags);
size_t *width, mbs_align_t align, int flags)
_GL_ATTRIBUTE_NONNULL ();
char *
ambsalign (char const *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-2021 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-2021 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-2021 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-2021 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-2021 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
@@ -25,17 +25,17 @@
#include <stdint.h>
#include <stdlib.h>
#include "attribute.h"
#include "count-leading-zeros.h"
#include "hash.h"
#include "verify.h"
#include "xalloc.h"
/* Return the floor of the log base 2 of N. If N is zero, return -1. */
static int _GL_ATTRIBUTE_CONST
ATTRIBUTE_CONST static int
floor_lg (size_t n)
{
verify (SIZE_WIDTH <= ULLONG_WIDTH);
static_assert (SIZE_WIDTH <= ULLONG_WIDTH);
return (n == 0 ? -1
: SIZE_WIDTH <= UINT_WIDTH
? UINT_WIDTH - 1 - count_leading_zeros (n)
@@ -117,7 +117,7 @@ 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_remove (sv, &(struct sparse_ent_) {i,0});
struct sparse_ent_ *v2 = hash_remove (sv, &(struct sparse_ent_) {j,0});

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-2021 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,8 +29,6 @@
#include <exitfail.h>
#include <fcntl.h>
#include <quote.h>
#include <stdalign.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -40,25 +38,12 @@
#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
@@ -115,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)
@@ -156,6 +141,17 @@ get_nonce (void *buffer, size_t bufsize)
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
bound on the number of bytes that will be needed. If zero, it is a
@@ -192,7 +188,7 @@ randread_new (char const *name, size_t bytes_bound)
MIN (sizeof s->buf.isaac.state.m, bytes_bound)))
{
int e = errno;
randread_free (s);
randread_free_body (s);
errno = e;
return NULL;
}
@@ -313,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-2021 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-2021 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-2021 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-2021 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

View File

@@ -1,6 +1,6 @@
/* Compare integer strings.
Copyright (C) 2005-2021 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-2021 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-2021 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,6 +1,6 @@
/* Convert decimal strings with bounds checking and exit on error.
Copyright (C) 2014-2021 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.
@@ -48,10 +49,10 @@ __xnumtoint (char const *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 (char const *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;

View File

@@ -1,6 +1,6 @@
/* Convert decimal strings with bounds checking and exit on error.
Copyright (C) 2014-2021 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
@@ -22,10 +22,12 @@
# define _DECLARE_XDECTOINT(name, type) \
type name (char const *n_str, type min, type max, \
char const *suffixes, char const *err, int err_exit);
char const *suffixes, char const *err, int err_exit) \
_GL_ATTRIBUTE_NONNULL ((1, 5));
# define _DECLARE_XNUMTOINT(name, type) \
type name (char const *n_str, int base, type min, type max, \
char const *suffixes, char const *err, int err_exit);
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-2021 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;

View File

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

View File

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

View File

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

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

@@ -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-2021 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-2021 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-2021 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: 9aca7b6733...4b60490554

View File

@@ -1,6 +1,6 @@
# This file is sourced by init.sh, *before* its initialization.
# Copyright (C) 2010-2021 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,7 +488,19 @@ 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
@@ -533,6 +546,18 @@ require_kill_group_()
# which SEEK_DATA support exists.
seek_data_capable_()
{
# 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
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; }
@@ -540,7 +565,14 @@ seek_data_capable_()
warn_ 'seek_data_capable_: python missing: assuming not SEEK_DATA capable'
return 1
fi
$PYTHON_ "$abs_srcdir"/tests/seek-data-capable "$@"
# 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.
@@ -583,7 +615,7 @@ 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
@@ -628,7 +660,10 @@ mkfifo_or_skip_()
trap_sigpipe_or_skip_()
{
(trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
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'
}

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise chdir-long's sample main program.
# Copyright (C) 2005-2021 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-2021 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 27
# Check declarations for this package.
dnl Copyright (C) 1997-2021 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,

View File

@@ -1,5 +1,5 @@
#serial 2
dnl Copyright (C) 2007-2021 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

@@ -2,7 +2,7 @@
dnl Misc type-related macros for coreutils.
# Copyright (C) 1998-2021 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

@@ -7,7 +7,7 @@ m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
# directory of the coreutils package.
# Copyright (C) 1998-2021 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-2021 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 4
# Copyright (C) 2003-2021 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],
AS_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.])
])

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)

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 2018-2021 Free Software Foundation, Inc.
'\" 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>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2021 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 @@
'\" Copyright (C) 1998-2021 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 @@
'\" Copyright (C) 1998-2021 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 @@
'\" Copyright (C) 1998-2021 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

@@ -2,3 +2,5 @@
echo \- display a line of text
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
printf(1)

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2021 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>.
@@ -54,7 +54,7 @@ sh \-c 'env \-\-default-signal=PIPE seq inf | head \-n1'
.PP
[NOTES]
POSIX's exec(2) pages says:
POSIX's exec(3p) pages says:
.RS
"many existing applications wrongly assume that they start with certain
signals set to the default action and/or unblocked.... Therefore, it is best

View File

@@ -2,3 +2,5 @@
fold \- wrap each input line to fit in specified width
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
fmt(1)

View File

@@ -78,6 +78,7 @@ Usage: %s [OPTION]... EXECUTABLE
-p, --info-page=TEXT name of Texinfo manual
-N, --no-info suppress pointer to Texinfo manual
-l, --libtool exclude the `lt-' from the program name
-b, --bold-refs apply bold style to references
--help print this help, then exit
--version print version number, then exit
@@ -99,7 +100,7 @@ my $help_option = '--help';
my $version_option = '--version';
my $discard_stderr = 1;
my ($opt_name, @opt_include, $opt_output, $opt_info, $opt_no_info, $opt_libtool,
$version_text);
$opt_bold_refs, $version_text);
my %opt_def = (
'n|name=s' => \$opt_name,
@@ -113,6 +114,7 @@ my %opt_def = (
'p|info-page=s' => \$opt_info,
'N|no-info' => \$opt_no_info,
'l|libtool' => \$opt_libtool,
'b|bold-refs' => \$opt_bold_refs,
'help' => sub { print $help_info; exit },
'version' => sub { print $version_info; exit },
'h|help-option=s' => \$help_option,
@@ -714,6 +716,13 @@ for my $sect (@pre, (grep !$filter{$_}, @sections), @post)
for ($include{$sect})
{
# Add bold style around referenced pages.
if ($opt_bold_refs)
{
# This will ignore entries already marked up (with \)
s/(^|\s|,)([\[\w\x83]+)\(([1-9][[:lower:]]?)\)/$1\\fB$2\\fP($3)/g;
}
# Replace leading dot, apostrophe, backslash and hyphen
# tokens.
s/\x80/\\&./g;

View File

@@ -1,7 +1,7 @@
# Make coreutils man pages. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 2002-2021 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
@@ -24,7 +24,10 @@ run_help2man = $(SHELL) $(srcdir)/man/dummy-man
else
## Graceful degradation for systems lacking perl.
if HAVE_PERL
run_help2man = $(PERL) -- $(srcdir)/man/help2man
if BOLD_MAN_REFS
help2man_OPTS=--bold-refs
endif
run_help2man = $(PERL) -- $(srcdir)/man/help2man $(help2man_OPTS)
else
run_help2man = $(SHELL) $(srcdir)/man/dummy-man
endif

View File

@@ -2,3 +2,5 @@
ls \- list directory contents
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
dircolors(1)

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2021 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 @@
'\" Copyright (C) 2009-2021 Free Software Foundation, Inc.
'\" Copyright (C) 2009-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,3 +1,8 @@
'\" 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]
test \- check file types and compare values
[SYNOPSIS]
@@ -17,3 +22,5 @@ test \- check file types and compare values
.I OPTION
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
access(2)

View File

@@ -2,3 +2,12 @@
tr \- translate or delete characters
[DESCRIPTION]
.\" Add any additional description here
[BUGS]
.PP
Full support is available only for safe single-byte locales,
in which every possible input byte represents a single character.
The C locale is safe in GNU systems, so you can avoid this issue
in the shell by running
.B "LC_ALL=C tr"
instead of plain
.BR tr .

View File

@@ -1,5 +1,5 @@
# List of files which contain translatable strings.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
# Copyright (C) 1996-2023 Free Software Foundation, Inc.
# These are nominally temporary...
lib/argmatch.c

View File

@@ -35,7 +35,7 @@ Details
GLibC version 2.28 removed non-standed headre file (libio.h) and some
internal symbols which were used by gnulib (a core component of GNU coreutils).
These were announced as 'deprecated' in vesion 2.27 [1], and removed in
These were announced as 'deprecated' in version 2.27 [1], and removed in
version 2.28. Gnulib code was adjusted shortly after [2],
but the code changes obviously can't be retroactively made to
previously-released coreutils versions.
@@ -164,7 +164,7 @@ By adding the directory to your $PATH, older versions can be easily used:
========================================================================
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Copyright (C) 2019-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 @@
#!/bin/sh
#
# Copyright (C) 2019-2021 Free Software Foundation, Inc.
# Copyright (C) 2019-2023 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright

View File

@@ -14,7 +14,7 @@ $editor = "vi" if $? != 0 or $editor =~ /^\s*\z/;
# Keywords allowed before the colon on the first line of a commit message:
# program names and a few general category names.
my @valid = qw(
arch b2sum base32 base64 basenc nbasename cat chcon chgrp chmod chown
arch b2sum base32 base64 basenc basename cat chcon chgrp chmod chown
chroot cksum comm 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
@@ -87,7 +87,7 @@ sub check_msg($$)
my ($log_file, $line_ref) = @_;
local *LOG;
open LOG, '<', $log_file
open LOG, '<:utf8', $log_file
or return "failed to open for reading: $!";
@$line_ref = <LOG>;
close LOG;
@@ -117,10 +117,13 @@ sub check_msg($$)
and return 'second line must be empty';
# Limit line length to allow for the ChangeLog's leading TAB.
my $max_len = 72;
foreach my $line (@line)
{
72 < length $line && $line =~ /^[^#]/
and return 'line longer than 72';
last if $line =~ '.*-{24} >8 -{24}$';
my $len = length $line;
$max_len < $len && $line =~ /^[^#]/
and return "line length ($len) greater than than max: $max_len";
}
my $buf = join ("\n", @line) . "\n";
@@ -149,6 +152,7 @@ sub check_msg($$)
$err eq ''
and last;
$err = "$ME: $err\n";
-t STDOUT or die $err;
warn $err;
# Insert the diagnostic as a comment on the first line of $log_file.
rewrite $log_file, $err, \@line;

View File

@@ -1,5 +1,5 @@
/* basename -- strip directory and suffix from file names
Copyright (C) 1990-2021 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

View File

@@ -1,5 +1,5 @@
/* Base64, base32, and similar encoding/decoding strings or files.
Copyright (C) 2004-2021 Free Software Foundation, Inc.
Copyright (C) 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
@@ -175,17 +175,17 @@ from any other non-alphabet bytes in the encoded stream.\n"),
exit (status);
}
#define ENC_BLOCKSIZE (1024*3*10)
#define ENC_BLOCKSIZE (1024 * 3 * 10)
#if BASE_TYPE == 32
# define BASE_LENGTH BASE32_LENGTH
/* Note that increasing this may decrease performance if --ignore-garbage
is used, because of the memmove operation below. */
# define DEC_BLOCKSIZE (1024*5)
# define DEC_BLOCKSIZE (1024 * 5)
/* Ensure that BLOCKSIZE is a multiple of 5 and 8. */
verify (ENC_BLOCKSIZE % 40 == 0); /* So padding chars only on last block. */
verify (DEC_BLOCKSIZE % 40 == 0); /* So complete encoded blocks are used. */
static_assert (ENC_BLOCKSIZE % 40 == 0); /* Padding chars only on last block. */
static_assert (DEC_BLOCKSIZE % 40 == 0); /* Complete encoded blocks are used. */
# define base_encode base32_encode
# define base_decode_context base32_decode_context
@@ -196,11 +196,11 @@ verify (DEC_BLOCKSIZE % 40 == 0); /* So complete encoded blocks are used. */
# define BASE_LENGTH BASE64_LENGTH
/* Note that increasing this may decrease performance if --ignore-garbage
is used, because of the memmove operation below. */
# define DEC_BLOCKSIZE (1024*3)
# define DEC_BLOCKSIZE (1024 * 3)
/* Ensure that BLOCKSIZE is a multiple of 3 and 4. */
verify (ENC_BLOCKSIZE % 12 == 0); /* So padding chars only on last block. */
verify (DEC_BLOCKSIZE % 12 == 0); /* So complete encoded blocks are used. */
static_assert (ENC_BLOCKSIZE % 12 == 0); /* Padding chars only on last block. */
static_assert (DEC_BLOCKSIZE % 12 == 0); /* Complete encoded blocks are used. */
# define base_encode base64_encode
# define base_decode_context base64_decode_context
@@ -215,8 +215,8 @@ verify (DEC_BLOCKSIZE % 12 == 0); /* So complete encoded blocks are used. */
/* Note that increasing this may decrease performance if --ignore-garbage
is used, because of the memmove operation below. */
# define DEC_BLOCKSIZE (4200)
verify (DEC_BLOCKSIZE % 40 == 0); /* complete encoded blocks for base32 */
verify (DEC_BLOCKSIZE % 12 == 0); /* complete encoded blocks for base64 */
static_assert (DEC_BLOCKSIZE % 40 == 0); /* complete encoded blocks for base32*/
static_assert (DEC_BLOCKSIZE % 12 == 0); /* complete encoded blocks for base64*/
static int (*base_length) (int i);
static bool (*isbase) (char ch);
@@ -310,7 +310,7 @@ base64url_encode (char const *restrict in, idx_t inlen,
{
base64_encode (in, inlen, out, outlen);
/* translate 62nd and 63rd characters */
char* p = out;
char *p = out;
while (outlen--)
{
if (*p == '+')
@@ -346,7 +346,7 @@ base64url_decode_ctx_wrapper (struct base_decode_context *ctx,
/* translate 62nd and 63rd characters */
idx_t i = inlen;
char* p = ctx->inbuf;
char *p = ctx->inbuf;
while (i--)
{
if (*p == '+' || *p == '/')
@@ -395,7 +395,7 @@ base32_decode_ctx_wrapper (struct base_decode_context *ctx,
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
to
0123456789ABCDEFGHIJKLMNOPQRSTUV */
static const char base32_norm_to_hex[32+9] = {
static const char base32_norm_to_hex[32 + 9] = {
/*0x32, 0x33, 0x34, 0x35, 0x36, 0x37, */
'Q', 'R', 'S', 'T', 'U', 'V',
@@ -417,7 +417,7 @@ static const char base32_norm_to_hex[32+9] = {
/* 0123456789ABCDEFGHIJKLMNOPQRSTUV
to
ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 */
static const char base32_hex_to_norm[32+9] = {
static const char base32_hex_to_norm[32 + 9] = {
/* from: 0x30 .. 0x39 ('0' to '9') */
/* to:*/ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
@@ -581,7 +581,7 @@ static int
z85_length (int len)
{
/* Z85 does not allow padding, so no need to round to highest integer. */
int outlen = (len*5)/4;
int outlen = (len * 5) / 4;
return outlen;
}
@@ -949,8 +949,22 @@ wrap_write (char const *buffer, idx_t len,
}
}
static void
do_encode (FILE *in, FILE *out, idx_t wrap_column)
static _Noreturn void
finish_and_exit (FILE *in, char const *infile)
{
if (fclose (in) != 0)
{
if (STREQ (infile, "-"))
die (EXIT_FAILURE, errno, _("closing standard input"));
else
die (EXIT_FAILURE, errno, "%s", quotef (infile));
}
exit (EXIT_SUCCESS);
}
static _Noreturn void
do_encode (FILE *in, char const *infile, FILE *out, idx_t wrap_column)
{
idx_t current_column = 0;
char *inbuf, *outbuf;
@@ -990,12 +1004,11 @@ do_encode (FILE *in, FILE *out, idx_t wrap_column)
if (ferror (in))
die (EXIT_FAILURE, errno, _("read error"));
IF_LINT (free (inbuf));
IF_LINT (free (outbuf));
finish_and_exit (in, infile);
}
static void
do_decode (FILE *in, FILE *out, bool ignore_garbage)
static _Noreturn void
do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
{
char *inbuf, *outbuf;
idx_t sum;
@@ -1057,11 +1070,7 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
}
while (!feof (in));
#if BASE_TYPE == 42
IF_LINT (free (ctx.inbuf));
#endif
IF_LINT (free (inbuf));
IF_LINT (free (outbuf));
finish_and_exit (in, infile);
}
int
@@ -1209,7 +1218,7 @@ main (int argc, char **argv)
if (argc - optind > 1)
{
error (0, 0, _("extra operand %s"), quote (argv[optind+1]));
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
usage (EXIT_FAILURE);
}
@@ -1233,17 +1242,7 @@ main (int argc, char **argv)
fadvise (input_fh, FADVISE_SEQUENTIAL);
if (decode)
do_decode (input_fh, stdout, ignore_garbage);
do_decode (input_fh, infile, stdout, ignore_garbage);
else
do_encode (input_fh, stdout, wrap_column);
if (fclose (input_fh) == EOF)
{
if (STREQ (infile, "-"))
die (EXIT_FAILURE, errno, _("closing standard input"));
else
die (EXIT_FAILURE, errno, "%s", quotef (infile));
}
return EXIT_SUCCESS;
do_encode (input_fh, infile, stdout, wrap_column);
}

View File

@@ -26,7 +26,6 @@
#include <ctype.h>
#include <unistd.h>
#include <getopt.h>
#include <stdbool.h>
#include "blake2.h"

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