mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
212 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca22b9eba0 | ||
|
|
0f2cf20af6 | ||
|
|
bcfbcef928 | ||
|
|
87d5f1e17e | ||
|
|
48e15cef45 | ||
|
|
b411f21414 | ||
|
|
f0a9f5e7da | ||
|
|
197a570ff0 | ||
|
|
30c932a309 | ||
|
|
52139fd690 | ||
|
|
6e9bf0765f | ||
|
|
4f920e93ec | ||
|
|
f98dcbfc1c | ||
|
|
028cad9149 | ||
|
|
2122ceba8e | ||
|
|
e43099f6e9 | ||
|
|
021fc4fad2 | ||
|
|
046ab76166 | ||
|
|
cc01b8a8f4 | ||
|
|
54bec51754 | ||
|
|
d28e369960 | ||
|
|
8f1f0dc975 | ||
|
|
73c0c15225 | ||
|
|
224c1fee69 | ||
|
|
8d9321ee0f | ||
|
|
6b5134770d | ||
|
|
52aeae2c3d | ||
|
|
120ce321d5 | ||
|
|
e07c40c3ea | ||
|
|
500c697cc8 | ||
|
|
6367cfe5fc | ||
|
|
28adf9cf58 | ||
|
|
aa53e73974 | ||
|
|
8767d75b9d | ||
|
|
92cb8427c5 | ||
|
|
85c975df2c | ||
|
|
3f61958495 | ||
|
|
4306bb6246 | ||
|
|
8f31074cb4 | ||
|
|
3abaa2ad67 | ||
|
|
6dc702928e | ||
|
|
677fb3e4ab | ||
|
|
97e9778296 | ||
|
|
ef694d3448 | ||
|
|
4439ef3ec4 | ||
|
|
3f7519130a | ||
|
|
7dbe465fd3 | ||
|
|
cee468f9c5 | ||
|
|
63228501e6 | ||
|
|
041dfff5db | ||
|
|
75c9fc6740 | ||
|
|
0b0f1965fb | ||
|
|
8d3dce9861 | ||
|
|
abc4533fe4 | ||
|
|
26db930c81 | ||
|
|
d8047ae86d | ||
|
|
e7ccf4775e | ||
|
|
195e943be7 | ||
|
|
d35b305109 | ||
|
|
a4d8d58429 | ||
|
|
dc689eba57 | ||
|
|
353ba4978f | ||
|
|
cedf627a90 | ||
|
|
b65ff7e4d0 | ||
|
|
8a3dedfef9 | ||
|
|
cf6c849899 | ||
|
|
b52d66452d | ||
|
|
67cd2c3b72 | ||
|
|
413a6cf521 | ||
|
|
abde159693 | ||
|
|
9a29ee2903 | ||
|
|
59da65b7fe | ||
|
|
1b552e73e8 | ||
|
|
222eee9631 | ||
|
|
bcc479b0b5 | ||
|
|
fb7579768d | ||
|
|
253a46d09f | ||
|
|
eb3cd9e97b | ||
|
|
604f8a6c4d | ||
|
|
d0e3b0ae1a | ||
|
|
701fcbc78e | ||
|
|
cb99998abe | ||
|
|
0ea9aacee9 | ||
|
|
10ded12481 | ||
|
|
f8664b6c8e | ||
|
|
5288f5ab5e | ||
|
|
75a87dc038 | ||
|
|
00973ca777 | ||
|
|
aafa9bf069 | ||
|
|
dba02d1996 | ||
|
|
ec8f3ea958 | ||
|
|
ed93b50eea | ||
|
|
04d735ea96 | ||
|
|
c55372d0d8 | ||
|
|
7e7ecf20aa | ||
|
|
423fed3dd8 | ||
|
|
22a0f9c32e | ||
|
|
836617fa12 | ||
|
|
904f9e3bf4 | ||
|
|
e55ffab35b | ||
|
|
e2feea68ac | ||
|
|
a72fc9ba5f | ||
|
|
f3984a6dba | ||
|
|
0106b5a4b8 | ||
|
|
8692f2a6d3 | ||
|
|
6ca7266666 | ||
|
|
d85374258a | ||
|
|
f21ccfb02c | ||
|
|
b50b63e06c | ||
|
|
8fe6dd3b77 | ||
|
|
a7de740baa | ||
|
|
a08853948c | ||
|
|
06b45ef985 | ||
|
|
75b50689f1 | ||
|
|
b29f782a3f | ||
|
|
05e889b7d5 | ||
|
|
1a83573596 | ||
|
|
7a9bda0477 | ||
|
|
9b2a58ba64 | ||
|
|
afa93e8804 | ||
|
|
a42a039132 | ||
|
|
703e0487e4 | ||
|
|
57c812cc3e | ||
|
|
534cfbb448 | ||
|
|
795a16627c | ||
|
|
2fb945ef77 | ||
|
|
50e438972b | ||
|
|
c4f9554ee9 | ||
|
|
816d84f138 | ||
|
|
3b98e21eed | ||
|
|
b973d2d44a | ||
|
|
1a8a566963 | ||
|
|
fbc7958b36 | ||
|
|
f19bc026b3 | ||
|
|
e94d95075d | ||
|
|
e462d928b0 | ||
|
|
4ec55ec0bd | ||
|
|
a36bc1910f | ||
|
|
4a0a8fdbec | ||
|
|
2ba6fb653c | ||
|
|
b197885b2d | ||
|
|
db539b7c34 | ||
|
|
6df8e86208 | ||
|
|
f39a02a744 | ||
|
|
95d6754451 | ||
|
|
43fa191b5a | ||
|
|
e2daa8f797 | ||
|
|
3f488e1d52 | ||
|
|
95ec19ecbd | ||
|
|
73bd6306d1 | ||
|
|
3067a9293a | ||
|
|
76700e775e | ||
|
|
840ae54cf5 | ||
|
|
0cd39a246a | ||
|
|
64b65cf4b8 | ||
|
|
1011b88594 | ||
|
|
6812e6baa7 | ||
|
|
aa670bed50 | ||
|
|
2f60fa465e | ||
|
|
5bc9d92868 | ||
|
|
5475fd6fe0 | ||
|
|
d5ae6d8120 | ||
|
|
1435e8e5c5 | ||
|
|
eb2400fb9f | ||
|
|
1cfbd4548d | ||
|
|
a2b21e9105 | ||
|
|
915a5e3360 | ||
|
|
8621e44cda | ||
|
|
3bf118dad0 | ||
|
|
064b31eb48 | ||
|
|
1827ae8243 | ||
|
|
bbc5e84513 | ||
|
|
bfc7a9b5e0 | ||
|
|
8931d571d0 | ||
|
|
4f497bf3c7 | ||
|
|
e3d1ff0437 | ||
|
|
5e36c0ce07 | ||
|
|
41bec08d7a | ||
|
|
5012223d78 | ||
|
|
3e2d644483 | ||
|
|
d0f035fc64 | ||
|
|
0f84467a34 | ||
|
|
0060ef82ee | ||
|
|
08930f21cb | ||
|
|
eae8df0d94 | ||
|
|
1b988ffa95 | ||
|
|
0f4d9e849b | ||
|
|
2378a53143 | ||
|
|
a0468760ff | ||
|
|
ea02406748 | ||
|
|
9f8a38414b | ||
|
|
25e68323b9 | ||
|
|
d16821975e | ||
|
|
9287ce5bbc | ||
|
|
2a9bacee50 | ||
|
|
389e766367 | ||
|
|
bafff0019c | ||
|
|
aa31b919ca | ||
|
|
1753012b8d | ||
|
|
a9e31457bf | ||
|
|
f60a3981c3 | ||
|
|
13af84d09a | ||
|
|
0750fcdf34 | ||
|
|
d085678bd6 | ||
|
|
6cafb122fa | ||
|
|
5b43b8e9ce | ||
|
|
b31a6a09ad | ||
|
|
4cfd48481d | ||
|
|
0475ce9f84 | ||
|
|
61c81ffaac | ||
|
|
e8b56ebd53 | ||
|
|
6f38c4b279 |
2
.github/ISSUE_TEMPLATE.txt
vendored
2
.github/ISSUE_TEMPLATE.txt
vendored
@@ -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-2022 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
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.txt
vendored
2
.github/PULL_REQUEST_TEMPLATE.txt
vendored
@@ -88,7 +88,7 @@ in this matter.
|
||||
|
||||
|
||||
<!--
|
||||
Copyright (C) 2017-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2017-2022 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
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -106,6 +106,7 @@
|
||||
/lib/sys/
|
||||
/lib/termios.h
|
||||
/lib/time.h
|
||||
/lib/unictype
|
||||
/lib/unistd.h
|
||||
/lib/unistr
|
||||
/lib/unistr.h
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.32
|
||||
9.0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Suppress valgrind diagnostics we don't care about.
|
||||
|
||||
# Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2022 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
|
||||
|
||||
2
HACKING
2
HACKING
@@ -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-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Make coreutils. -*-Makefile-*-
|
||||
|
||||
# Copyright (C) 1990-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1990-2022 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
|
||||
@@ -93,7 +93,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.27
|
||||
.PHONY: gen-ChangeLog
|
||||
gen-ChangeLog:
|
||||
$(AM_V_GEN)if test -d .git; then \
|
||||
|
||||
133
NEWS
133
NEWS
@@ -1,5 +1,134 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* 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
|
||||
@@ -3016,7 +3145,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 +5418,7 @@ packages, see ./old/*/NEWS.
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2022 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
|
||||
|
||||
2
README
2
README
@@ -232,7 +232,7 @@ the address on the last line of --help output.
|
||||
|
||||
========================================================================
|
||||
|
||||
Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998-2022 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
|
||||
|
||||
@@ -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 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 git://git.sv.gnu.org/<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-2022 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
|
||||
|
||||
@@ -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 <http://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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#! /bin/bash
|
||||
# Convert this package for use with valgrind.
|
||||
|
||||
# Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2022 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
|
||||
|
||||
@@ -641,7 +641,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
|
||||
|
||||
2
TODO
2
TODO
@@ -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-2022 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
|
||||
|
||||
247
bootstrap
247
bootstrap
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Print a version string.
|
||||
scriptversion=2021-04-11.09; # UTC
|
||||
scriptversion=2022-03-21.01; # UTC
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
# Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2022 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,47 +485,6 @@ 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 \
|
||||
@@ -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"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bootstrap configuration.
|
||||
|
||||
# Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2022 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,16 @@ avoided_gnulib_modules='
|
||||
gnulib_modules="
|
||||
$avoided_gnulib_modules
|
||||
acl
|
||||
alignalloc
|
||||
alignof
|
||||
alloca
|
||||
announce-gen
|
||||
areadlink-with-size
|
||||
areadlinkat-with-size
|
||||
argmatch
|
||||
argv-iter
|
||||
assert
|
||||
attribute
|
||||
autobuild
|
||||
backupfile
|
||||
backup-rename
|
||||
@@ -79,6 +82,8 @@ gnulib_modules="
|
||||
faccessat
|
||||
fadvise
|
||||
fchdir
|
||||
fchmodat
|
||||
fchownat
|
||||
fclose
|
||||
fcntl
|
||||
fcntl-safer
|
||||
@@ -118,6 +123,7 @@ gnulib_modules="
|
||||
getpass-gnu
|
||||
gettext-h
|
||||
gettime
|
||||
gettime-res
|
||||
getugroups
|
||||
getusershell
|
||||
git-version-gen
|
||||
@@ -172,7 +178,9 @@ gnulib_modules="
|
||||
mkancesdirs
|
||||
mkdir
|
||||
mkdir-p
|
||||
mkdirat
|
||||
mkfifo
|
||||
mkfifoat
|
||||
mknod
|
||||
mkostemp
|
||||
mkstemp
|
||||
@@ -181,7 +189,6 @@ gnulib_modules="
|
||||
mountlist
|
||||
mpsort
|
||||
netinet_in
|
||||
non-recursive-gnulib-prefix-hack
|
||||
nproc
|
||||
nstrftime
|
||||
obstack
|
||||
@@ -240,7 +247,6 @@ gnulib_modules="
|
||||
stat-macros
|
||||
stat-size
|
||||
stat-time
|
||||
statat
|
||||
stdbool
|
||||
stdlib-safer
|
||||
stpcpy
|
||||
@@ -256,6 +262,7 @@ gnulib_modules="
|
||||
sys_resource
|
||||
sys_stat
|
||||
sys_wait
|
||||
targetdir
|
||||
tempname
|
||||
termios
|
||||
time_rz
|
||||
@@ -276,6 +283,7 @@ gnulib_modules="
|
||||
userspec
|
||||
utimecmp
|
||||
utimens
|
||||
utimensat
|
||||
vasprintf-posix
|
||||
vc-list-files
|
||||
verify
|
||||
@@ -287,6 +295,7 @@ gnulib_modules="
|
||||
winsz-ioctl
|
||||
winsz-termios
|
||||
write-any-file
|
||||
xalignalloc
|
||||
xalloc
|
||||
xbinary-io
|
||||
xdectoint
|
||||
@@ -338,7 +347,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 +381,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 \
|
||||
|
||||
16
cfg.mk
16
cfg.mk
@@ -1,5 +1,5 @@
|
||||
# Customize maint.mk -*- makefile -*-
|
||||
# Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2022 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 = 612bad626bf28b1847ad0114cb2cd6fe
|
||||
|
||||
# Add an exemption for sc_makefile_at_at_check.
|
||||
_makefile_at_at_check_exceptions = ' && !/^cu_install_prog/ && !/dynamic-dep/'
|
||||
@@ -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; } \
|
||||
|| :
|
||||
@@ -441,12 +441,6 @@ 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)
|
||||
|
||||
# Don't use address of "stat" or "lstat" functions
|
||||
sc_prohibit_stat_macro_address:
|
||||
@prohibit='\<l?stat '':|&l?stat\>' \
|
||||
@@ -839,7 +833,7 @@ 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))
|
||||
_gl_src = (xdecto.max|cl-strtold)
|
||||
|
||||
93
configure.ac
93
configure.ac
@@ -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-2022 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
|
||||
@@ -64,11 +64,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 +84,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 +190,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 +269,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 +336,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
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
This manual documents version @value{VERSION} of the GNU core
|
||||
utilities, including the standard programs for text and file manipulation.
|
||||
|
||||
Copyright @copyright{} 1994--2021 Free Software Foundation, Inc.
|
||||
Copyright @copyright{} 1994--2022 Free Software Foundation, Inc.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
@@ -300,7 +300,7 @@ Operating on characters
|
||||
|
||||
@command{tr}: Translate, squeeze, and/or delete characters
|
||||
|
||||
* Character sets:: Specifying sets of characters
|
||||
* Character arrays:: Specifying arrays of characters
|
||||
* Translating:: Changing one set of characters to another
|
||||
* Squeezing and deleting:: Removing characters
|
||||
|
||||
@@ -498,9 +498,9 @@ Date input formats
|
||||
Version sorting order
|
||||
|
||||
* Version sort overview::
|
||||
* Implementation Details::
|
||||
* Differences from the official Debian Algorithm::
|
||||
* Advanced Topics::
|
||||
* Version sort implementation::
|
||||
* Differences from Debian version sort::
|
||||
* Advanced version sort topics::
|
||||
|
||||
Opening the software toolbox
|
||||
|
||||
@@ -3554,7 +3554,8 @@ file once for each repeat.
|
||||
@item /@var{regexp}/[@var{offset}]
|
||||
Create an output file containing the current line up to (but not
|
||||
including) the next line of the input file that contains a match for
|
||||
@var{regexp}. The optional @var{offset} is an integer.
|
||||
@var{regexp}. The optional @var{offset} is an integer, that can
|
||||
be preceded by @samp{+} or @samp{-}.
|
||||
If it is given, the input up to (but not including) the
|
||||
matching line plus or minus @var{offset} is put into the output file,
|
||||
and the line after that begins the next section of input.
|
||||
@@ -3990,7 +3991,7 @@ Output extra information to stderr, like the checksum implementation being used.
|
||||
|
||||
@item --untagged
|
||||
@opindex --untagged
|
||||
Output using the original coreutils format used by the other
|
||||
Output using the original Coreutils format used by the other
|
||||
standalone checksum utilities like @command{md5sum} for example.
|
||||
This format has the checksum at the start of the line, and may be
|
||||
more amenable to further processing by other utilities,
|
||||
@@ -6887,7 +6888,7 @@ These commands operate on individual characters.
|
||||
Synopsis:
|
||||
|
||||
@example
|
||||
tr [@var{option}]@dots{} @var{set1} [@var{set2}]
|
||||
tr [@var{option}]@dots{} @var{string1} [@var{string2}]
|
||||
@end example
|
||||
|
||||
@command{tr} copies standard input to standard output, performing
|
||||
@@ -6904,9 +6905,11 @@ delete characters,
|
||||
delete characters, then squeeze repeated characters from the result.
|
||||
@end itemize
|
||||
|
||||
The @var{set1} and (if given) @var{set2} arguments define ordered
|
||||
sets of characters, referred to below as @var{set1} and @var{set2}. These
|
||||
sets are the characters of the input that @command{tr} operates on.
|
||||
The @var{string1} and @var{string2} operands define arrays of
|
||||
characters @var{array1} and @var{array2}. By default @var{array1}
|
||||
lists input characters that @command{tr} operates on, and @var{array2}
|
||||
lists corresponding translations. In some cases the second operand is
|
||||
omitted.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
Options must precede operands.
|
||||
@@ -6919,34 +6922,29 @@ Options must precede operands.
|
||||
@opindex -c
|
||||
@opindex -C
|
||||
@opindex --complement
|
||||
This option replaces @var{set1} with its
|
||||
complement (all of the characters that are not in @var{set1}).
|
||||
Currently @command{tr} fully supports only single-byte characters.
|
||||
Eventually it will support multibyte characters; when it does, the
|
||||
@option{-C} option will cause it to complement the set of characters,
|
||||
whereas @option{-c} will cause it to complement the set of values.
|
||||
This distinction will matter only when some values are not characters,
|
||||
and this is possible only in locales using multibyte encodings when
|
||||
the input contains encoding errors.
|
||||
Instead of @var{array1}, use its complement (all characters not
|
||||
specified by @var{string1}), in ascending order. Use this option with
|
||||
caution in multibyte locales where its meaning is not always clear
|
||||
or portable; see @ref{Character arrays}.
|
||||
|
||||
@item -d
|
||||
@itemx --delete
|
||||
@opindex -d
|
||||
@opindex --delete
|
||||
Delete characters in @var{set1}, do not translate
|
||||
Delete characters in @var{array1}; do not translate.
|
||||
|
||||
@item -s
|
||||
@itemx --squeeze-repeats
|
||||
@opindex -s
|
||||
@opindex --squeeze-repeats
|
||||
Replace each sequence of a repeated character that is listed in
|
||||
the last specified @var{set}, with a single occurrence of that character.
|
||||
the last specified @var{array}, with a single occurrence of that character.
|
||||
|
||||
@item -t
|
||||
@itemx --truncate-set1
|
||||
@opindex -t
|
||||
@opindex --truncate-set1
|
||||
First truncate @var{set1} to length of @var{set2}.
|
||||
Truncate @var{array1} to the length of @var{array2}.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -6954,23 +6952,41 @@ First truncate @var{set1} to length of @var{set2}.
|
||||
@exitstatus
|
||||
|
||||
@menu
|
||||
* Character sets:: Specifying sets of characters.
|
||||
* Translating:: Changing one set of characters to another.
|
||||
* Character arrays:: Specifying arrays of characters.
|
||||
* Translating:: Changing characters to other characters.
|
||||
* Squeezing and deleting:: Removing characters.
|
||||
@end menu
|
||||
|
||||
|
||||
@node Character sets
|
||||
@subsection Specifying sets of characters
|
||||
@node Character arrays
|
||||
@subsection Specifying arrays of characters
|
||||
|
||||
@cindex specifying sets of characters
|
||||
@cindex arrays of characters in @command{tr}
|
||||
|
||||
The format of the @var{set1} and @var{set2} arguments resembles
|
||||
the format of regular expressions; however, they are not regular
|
||||
expressions, only lists of characters. Most characters simply
|
||||
represent themselves in these strings, but the strings can contain
|
||||
the shorthands listed below, for convenience. Some of them can be
|
||||
used only in @var{set1} or @var{set2}, as noted below.
|
||||
The @var{string1} and @var{string2} operands are not regular
|
||||
expressions, even though they may look similar. Instead, they
|
||||
merely represent arrays of characters. As a GNU extension to POSIX,
|
||||
an empty string operand represents an empty array of characters.
|
||||
|
||||
The interpretation of @var{string1} and @var{string2} depends on locale.
|
||||
GNU @command{tr} fully supports only safe single-byte locales,
|
||||
where each possible input byte represents a single character.
|
||||
Unfortunately, this means GNU @command{tr} will not handle commands
|
||||
like @samp{tr $'\u7530' $'\u68EE'} the way you might expect,
|
||||
since (assuming a UTF-8 encoding) this is equivalent to
|
||||
@samp{tr '\347\224\260' '\346\243\256'} and GNU @command{tr} will
|
||||
simply transliterate all @samp{\347} bytes to @samp{\346} bytes, etc.
|
||||
POSIX does not clearly specify the behavior of @command{tr} in locales
|
||||
where characters are represented by byte sequences instead of by
|
||||
individual bytes, or where data might contain invalid bytes that are
|
||||
encoding errors. To avoid problems in this area, you can run
|
||||
@command{tr} in a safe single-byte locale by using a shell command
|
||||
like @samp{LC_ALL=C tr} instead of plain @command{tr}.
|
||||
|
||||
Although most characters simply represent themselves in @var{string1}
|
||||
and @var{string2}, the strings can contain shorthands listed below,
|
||||
for convenience. Some shorthands can be used only in @var{string1} or
|
||||
@var{string2}, as noted below.
|
||||
|
||||
@table @asis
|
||||
|
||||
@@ -6981,38 +6997,42 @@ The following backslash escape sequences are recognized:
|
||||
|
||||
@table @samp
|
||||
@item \a
|
||||
Control-G.
|
||||
Bell (BEL, Control-G).
|
||||
@item \b
|
||||
Control-H.
|
||||
Backspace (BS, Control-H).
|
||||
@item \f
|
||||
Control-L.
|
||||
Form feed (FF, Control-L).
|
||||
@item \n
|
||||
Control-J.
|
||||
Newline (LF, Control-J).
|
||||
@item \r
|
||||
Control-M.
|
||||
Carriage return (CR, Control-M).
|
||||
@item \t
|
||||
Control-I.
|
||||
Tab (HT, Control-I).
|
||||
@item \v
|
||||
Control-K.
|
||||
Vertical tab (VT, Control-K).
|
||||
@item \@var{ooo}
|
||||
The 8-bit character with the value given by @var{ooo}, which is 1 to 3
|
||||
octal digits. Note that @samp{\400} is interpreted as the two-byte
|
||||
sequence, @samp{\040} @samp{0}.
|
||||
The eight-bit byte with the value given by @var{ooo}, which is the longest
|
||||
sequence of one to three octal digits following the backslash.
|
||||
For portability, @var{ooo} should represent a value that fits in eight bits.
|
||||
As a GNU extension to POSIX, if the value would not fit, then only the
|
||||
first two digits of @var{ooo} are used, e.g., @samp{\400}
|
||||
is equivalent to @samp{\0400} and represents a two-byte sequence.
|
||||
@item \\
|
||||
A backslash.
|
||||
@end table
|
||||
|
||||
While a backslash followed by a character not listed above is
|
||||
interpreted as that character, the backslash also effectively
|
||||
removes any special significance, so it is useful to escape
|
||||
@samp{[}, @samp{]}, @samp{*}, and @samp{-}.
|
||||
It is an error if no character follows an unescaped backslash.
|
||||
As a GNU extension, a backslash followed by a character not listed
|
||||
above is interpreted as that character, removing any special
|
||||
significance; this can be used to escape the characters
|
||||
@samp{[} and @samp{-} when they would otherwise be special.
|
||||
|
||||
@item Ranges
|
||||
@cindex ranges
|
||||
|
||||
The notation @samp{@var{m}-@var{n}} expands to all of the characters
|
||||
The notation @samp{@var{m}-@var{n}} expands to the characters
|
||||
from @var{m} through @var{n}, in ascending order. @var{m} should
|
||||
collate before @var{n}; if it doesn't, an error results. As an example,
|
||||
not collate after @var{n}; if it does, an error results. As an example,
|
||||
@samp{0-9} is the same as @samp{0123456789}.
|
||||
|
||||
GNU @command{tr} does not support the System V syntax that uses square
|
||||
@@ -7022,38 +7042,37 @@ to themselves. However, they should be avoided because they sometimes
|
||||
behave unexpectedly. For example, @samp{tr -d '[0-9]'} deletes brackets
|
||||
as well as digits.
|
||||
|
||||
Many historically common and even accepted uses of ranges are not
|
||||
Many historically common and even accepted uses of ranges are not fully
|
||||
portable. For example, on EBCDIC hosts using the @samp{A-Z}
|
||||
range will not do what most would expect because @samp{A} through @samp{Z}
|
||||
are not contiguous as they are in ASCII@.
|
||||
If you can rely on a POSIX compliant version of @command{tr}, then
|
||||
the best way to work around this is to use character classes (see below).
|
||||
One way to work around this is to use character classes (see below).
|
||||
Otherwise, it is most portable (and most ugly) to enumerate the members
|
||||
of the ranges.
|
||||
|
||||
@item Repeated characters
|
||||
@cindex repeated characters
|
||||
|
||||
The notation @samp{[@var{c}*@var{n}]} in @var{set2} expands to @var{n}
|
||||
The notation @samp{[@var{c}*@var{n}]} in @var{string2} expands to @var{n}
|
||||
copies of character @var{c}. Thus, @samp{[y*6]} is the same as
|
||||
@samp{yyyyyy}. The notation @samp{[@var{c}*]} in @var{string2} expands
|
||||
to as many copies of @var{c} as are needed to make @var{set2} as long as
|
||||
@var{set1}. If @var{n} begins with @samp{0}, it is interpreted in
|
||||
octal, otherwise in decimal.
|
||||
to as many copies of @var{c} as are needed to make @var{array2} as long as
|
||||
@var{array1}. If @var{n} begins with @samp{0}, it is interpreted in
|
||||
octal, otherwise in decimal. A zero-valued @var{n} is treated as if
|
||||
it were absent.
|
||||
|
||||
@item Character classes
|
||||
@cindex character classes
|
||||
|
||||
The notation @samp{[:@var{class}:]} expands to all of the characters in
|
||||
the (predefined) class @var{class}. The characters expand in no
|
||||
particular order, except for the @code{upper} and @code{lower} classes,
|
||||
which expand in ascending order. When the @option{--delete} (@option{-d})
|
||||
The notation @samp{[:@var{class}:]} expands to all characters in
|
||||
the (predefined) class @var{class}. When the @option{--delete} (@option{-d})
|
||||
and @option{--squeeze-repeats} (@option{-s}) options are both given, any
|
||||
character class can be used in @var{set2}. Otherwise, only the
|
||||
character class can be used in @var{string2}. Otherwise, only the
|
||||
character classes @code{lower} and @code{upper} are accepted in
|
||||
@var{set2}, and then only if the corresponding character class
|
||||
@var{string2}, and then only if the corresponding character class
|
||||
(@code{upper} and @code{lower}, respectively) is specified in the same
|
||||
relative position in @var{set1}. Doing this specifies case conversion.
|
||||
relative position in @var{string1}. Doing this specifies case conversion.
|
||||
Except for case conversion, a class's characters appear in no particular order.
|
||||
The class names are given below; an error results when an invalid class
|
||||
name is given.
|
||||
|
||||
@@ -7099,10 +7118,13 @@ Hexadecimal digits.
|
||||
@item Equivalence classes
|
||||
@cindex equivalence classes
|
||||
|
||||
The syntax @samp{[=@var{c}=]} expands to all of the characters that are
|
||||
equivalent to @var{c}, in no particular order. Equivalence classes are
|
||||
a relatively recent invention intended to support non-English alphabets.
|
||||
But there seems to be no standard way to define them or determine their
|
||||
The syntax @samp{[=@var{c}=]} expands to all characters equivalent to
|
||||
@var{c}, in no particular order. These equivalence classes are
|
||||
allowed in @var{string2} only when @option{--delete} (@option{-d}) and
|
||||
@option{--squeeze-repeats} @option{-s} are both given.
|
||||
|
||||
Although equivalence classes are intended to support non-English alphabets,
|
||||
there seems to be no standard way to define them or determine their
|
||||
contents. Therefore, they are not fully implemented in GNU @command{tr};
|
||||
each character's equivalence class consists only of that character,
|
||||
which is of no particular use.
|
||||
@@ -7115,13 +7137,14 @@ which is of no particular use.
|
||||
|
||||
@cindex translating characters
|
||||
|
||||
@command{tr} performs translation when @var{set1} and @var{set2} are
|
||||
@command{tr} performs translation when @var{string1} and @var{string2} are
|
||||
both given and the @option{--delete} (@option{-d}) option is not given.
|
||||
@command{tr} translates each character of its input that is in @var{set1}
|
||||
to the corresponding character in @var{set2}. Characters not in
|
||||
@var{set1} are passed through unchanged. When a character appears more
|
||||
than once in @var{set1} and the corresponding characters in @var{set2}
|
||||
are not all the same, only the final one is used. For example, these
|
||||
@command{tr} translates each character of its input that is in @var{array1}
|
||||
to the corresponding character in @var{array2}. Characters not in
|
||||
@var{array1} are passed through unchanged.
|
||||
|
||||
As a GNU extension to POSIX, when a character appears more than once
|
||||
in @var{array1}, only the final instance is used. For example, these
|
||||
two commands are equivalent:
|
||||
|
||||
@example
|
||||
@@ -7139,17 +7162,17 @@ tr '[:lower:]' '[:upper:]'
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
But note that using ranges like @code{a-z} above is not portable.
|
||||
However, ranges like @code{a-z} are not portable outside the C locale.
|
||||
|
||||
When @command{tr} is performing translation, @var{set1} and @var{set2}
|
||||
typically have the same length. If @var{set1} is shorter than
|
||||
@var{set2}, the extra characters at the end of @var{set2} are ignored.
|
||||
When @command{tr} is performing translation, @var{array1} and @var{array2}
|
||||
typically have the same length. If @var{array1} is shorter than
|
||||
@var{array2}, the extra characters at the end of @var{array2} are ignored.
|
||||
|
||||
On the other hand, making @var{set1} longer than @var{set2} is not
|
||||
On the other hand, making @var{array1} longer than @var{array2} is not
|
||||
portable; POSIX says that the result is undefined. In this situation,
|
||||
BSD @command{tr} pads @var{set2} to the length of @var{set1} by repeating
|
||||
the last character of @var{set2} as many times as necessary. System V
|
||||
@command{tr} truncates @var{set1} to the length of @var{set2}.
|
||||
BSD @command{tr} pads @var{array2} to the length of @var{array1} by repeating
|
||||
the last character of @var{array2} as many times as necessary. System V
|
||||
@command{tr} truncates @var{array1} to the length of @var{array2}.
|
||||
|
||||
By default, GNU @command{tr} handles this case like BSD @command{tr}.
|
||||
When the @option{--truncate-set1} (@option{-t}) option is given,
|
||||
@@ -7165,13 +7188,12 @@ tr -cs A-Za-z0-9 '\012'
|
||||
|
||||
@noindent
|
||||
because it converts only zero bytes (the first element in the
|
||||
complement of @var{set1}), rather than all non-alphanumerics, to
|
||||
complement of @var{array1}), rather than all non-alphanumerics, to
|
||||
newlines.
|
||||
|
||||
@noindent
|
||||
By the way, the above idiom is not portable because it uses ranges, and
|
||||
it assumes that the octal code for newline is 012.
|
||||
Assuming a POSIX compliant @command{tr}, here is a better
|
||||
it assumes that the octal code for newline is 012. Here is a better
|
||||
way to write it:
|
||||
|
||||
@example
|
||||
@@ -7187,20 +7209,20 @@ tr -cs '[:alnum:]' '[\n*]'
|
||||
@cindex removing characters
|
||||
|
||||
When given just the @option{--delete} (@option{-d}) option, @command{tr}
|
||||
removes any input characters that are in @var{set1}.
|
||||
removes any input characters that are in @var{array1}.
|
||||
|
||||
When given just the @option{--squeeze-repeats} (@option{-s}) option
|
||||
and not translating, @command{tr} replaces each input sequence of a
|
||||
repeated character that is in @var{set1} with a single occurrence of
|
||||
repeated character that is in @var{array1} with a single occurrence of
|
||||
that character.
|
||||
|
||||
When given both @option{--delete} and @option{--squeeze-repeats}, @command{tr}
|
||||
first performs any deletions using @var{set1}, then squeezes repeats
|
||||
from any remaining characters using @var{set2}.
|
||||
first performs any deletions using @var{array1}, then squeezes repeats
|
||||
from any remaining characters using @var{array2}.
|
||||
|
||||
The @option{--squeeze-repeats} option may also be used when translating,
|
||||
in which case @command{tr} first performs translation, then squeezes
|
||||
repeats from any remaining characters using @var{set2}.
|
||||
repeats from any remaining characters using @var{array2}.
|
||||
|
||||
Here are some examples to illustrate various combinations of options:
|
||||
|
||||
@@ -7224,7 +7246,7 @@ tr -cs '[:alnum:]' '[\n*]'
|
||||
|
||||
@item
|
||||
Convert each sequence of repeated newlines to a single newline.
|
||||
I.e., delete blank lines:
|
||||
I.e., delete empty lines:
|
||||
|
||||
@example
|
||||
tr -s '\n'
|
||||
@@ -7278,16 +7300,6 @@ Or you can use @samp{--} to terminate option processing:
|
||||
tr -d -- -axM
|
||||
@end example
|
||||
|
||||
More generally, use the character class notation @code{[=c=]}
|
||||
with @samp{-} (or any other character) in place of the @samp{c}:
|
||||
|
||||
@example
|
||||
tr -d '[=-=]axM'
|
||||
@end example
|
||||
|
||||
Note how single quotes are used in the above example to protect the
|
||||
square brackets from interpretation by a shell.
|
||||
|
||||
@end itemize
|
||||
|
||||
|
||||
@@ -8109,7 +8121,7 @@ may be omitted, or one of:
|
||||
@end itemize
|
||||
Specifying @option{--color} and no @var{when} is equivalent to
|
||||
@option{--color=always}.
|
||||
If piping a colorized listing through a pager like @command{less},
|
||||
If piping a colored listing through a pager like @command{less},
|
||||
use the pager's @option{-R} option to pass the color codes to the terminal.
|
||||
|
||||
@vindex LS_COLORS
|
||||
@@ -8238,14 +8250,6 @@ List files horizontally, with as many as will fit on each line,
|
||||
separated by @samp{, } (a comma and a space),
|
||||
and with no other information.
|
||||
|
||||
@item --zero
|
||||
@opindex --zero
|
||||
@outputNUL
|
||||
This option is incompatible with the @option{--dired} (@option{-D}) option.
|
||||
This option also implies the options @option{--show-control-chars},
|
||||
@option{-1}, @option{--color=none}, and
|
||||
@option{--quoting-style=literal} (@option{-N}).
|
||||
|
||||
@item -p
|
||||
@itemx --indicator-style=slash
|
||||
@opindex -p
|
||||
@@ -8287,6 +8291,14 @@ is 80. With a @var{cols} value of @samp{0}, there is no limit on
|
||||
the length of the output line, and that single output line will
|
||||
be delimited with spaces, not tabs.
|
||||
|
||||
@item --zero
|
||||
@opindex --zero
|
||||
@outputNUL
|
||||
This option is incompatible with the @option{--dired} (@option{-D}) option.
|
||||
This option also implies the options @option{--show-control-chars},
|
||||
@option{-1}, @option{--color=none}, and
|
||||
@option{--quoting-style=literal} (@option{-N}).
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -8624,6 +8636,12 @@ Print the (compiled-in) default color configuration database. This
|
||||
output is itself a valid configuration file, and is fairly descriptive
|
||||
of the possibilities.
|
||||
|
||||
@item --print-ls-colors
|
||||
@opindex --print-ls-colors
|
||||
@cindex printing ls colors
|
||||
Print the LS_COLORS entries on separate lines,
|
||||
each colored as per the color they represent.
|
||||
|
||||
@end table
|
||||
|
||||
@exitstatus
|
||||
@@ -9148,9 +9166,8 @@ option, and overrides the @option{--preserve=all} and @option{-a} options.
|
||||
@pindex dd
|
||||
@cindex converting while copying a file
|
||||
|
||||
@command{dd} copies a file (from standard input to standard output, by
|
||||
default) with a changeable I/O block size, while optionally performing
|
||||
conversions on it. Synopses:
|
||||
@command{dd} copies input to output with a changeable I/O block size,
|
||||
while optionally performing conversions on the data. Synopses:
|
||||
|
||||
@example
|
||||
dd [@var{operand}]@dots{}
|
||||
@@ -9158,7 +9175,43 @@ dd @var{option}
|
||||
@end example
|
||||
|
||||
The only options are @option{--help} and @option{--version}.
|
||||
@xref{Common options}. @command{dd} accepts the following operands,
|
||||
@xref{Common options}.
|
||||
|
||||
By default, @command{dd} copies standard input to standard output.
|
||||
To copy, @command{dd} repeatedly does the following steps in order:
|
||||
|
||||
@enumerate
|
||||
@item
|
||||
Read an input block.
|
||||
|
||||
@item
|
||||
If converting via @samp{sync}, pad as needed to meet the input block size.
|
||||
Pad with spaces if converting via @samp{block} or @samp{unblock}, NUL
|
||||
bytes otherwise.
|
||||
|
||||
@item
|
||||
If @samp{bs=} is given and no conversion mentioned in steps (4) or (5)
|
||||
is given, output the data as a single block and skip all remaining steps.
|
||||
|
||||
@item
|
||||
If the @samp{swab} conversion is given, swap each pair of input bytes.
|
||||
If the input data length is odd, preserve the last input byte
|
||||
(since there is nothing to swap it with).
|
||||
|
||||
@item
|
||||
If any of the conversions @samp{swab}, @samp{block}, @samp{unblock},
|
||||
@samp{lcase}, @samp{ucase}, @samp{ascii}, @samp{ebcdic} and @samp{ibm}
|
||||
are given, do these conversions. These conversions operate
|
||||
independently of input blocking, and might deal with records that span
|
||||
block boundaries.
|
||||
|
||||
@item
|
||||
Aggregate the resulting data into output blocks of the specified size,
|
||||
and output each output block in turn. Do not pad the last output block;
|
||||
it can be shorter than usual.
|
||||
@end enumerate
|
||||
|
||||
@command{dd} accepts the following operands,
|
||||
whose syntax was inspired by the DD (data definition) statement of
|
||||
OS/360 JCL.
|
||||
|
||||
@@ -9171,8 +9224,7 @@ Read from @var{file} instead of standard input.
|
||||
@item of=@var{file}
|
||||
@opindex of
|
||||
Write to @var{file} instead of standard output. Unless
|
||||
@samp{conv=notrunc} is given, @command{dd} truncates @var{file} to zero
|
||||
bytes (or the size specified with @samp{seek=}).
|
||||
@samp{conv=notrunc} is given, truncate @var{file} before writing it.
|
||||
|
||||
@item ibs=@var{bytes}
|
||||
@opindex ibs
|
||||
@@ -9212,28 +9264,37 @@ When converting variable-length records to fixed-length ones
|
||||
use @var{bytes} as the fixed record length.
|
||||
|
||||
@item skip=@var{n}
|
||||
@itemx iseek=@var{n}
|
||||
@opindex skip
|
||||
@opindex iseek
|
||||
Skip @var{n} @samp{ibs}-byte blocks in the input file before copying.
|
||||
If @samp{iflag=skip_bytes} is specified, @var{n} is interpreted
|
||||
If @var{n} ends in the letter @samp{B}, interpret @var{n}
|
||||
as a byte count rather than a block count.
|
||||
(@samp{B} and the @samp{iseek=} spelling are GNU extensions to POSIX.)
|
||||
|
||||
@item seek=@var{n}
|
||||
@itemx oseek=@var{n}
|
||||
@opindex seek
|
||||
Skip @var{n} @samp{obs}-byte blocks in the output file before copying.
|
||||
if @samp{oflag=seek_bytes} is specified, @var{n} is interpreted
|
||||
@opindex oseek
|
||||
Skip @var{n} @samp{obs}-byte blocks in the output file before
|
||||
truncating or copying.
|
||||
If @var{n} ends in the letter @samp{B}, interpret @var{n}
|
||||
as a byte count rather than a block count.
|
||||
(@samp{B} and the @samp{oseek=} spelling are GNU extensions to POSIX.)
|
||||
|
||||
@item count=@var{n}
|
||||
@opindex count
|
||||
Copy @var{n} @samp{ibs}-byte blocks from the input file, instead
|
||||
of everything until the end of the file.
|
||||
if @samp{iflag=count_bytes} is specified, @var{n} is interpreted
|
||||
as a byte count rather than a block count.
|
||||
Note if the input may return short reads as could be the case
|
||||
If @var{n} ends in the letter @samp{B},
|
||||
interpret @var{n} as a byte count rather than a block count;
|
||||
this is a GNU extension to POSIX.
|
||||
If short reads occur, as could be the case
|
||||
when reading from a pipe for example, @samp{iflag=fullblock}
|
||||
will ensure that @samp{count=} corresponds to complete input blocks
|
||||
rather than the traditional POSIX specified behavior of counting
|
||||
input read operations.
|
||||
ensures that @samp{count=} counts complete input blocks
|
||||
rather than input read operations.
|
||||
As an extension to POSIX, @samp{count=0} copies zero blocks
|
||||
instead of copying all blocks.
|
||||
|
||||
@item status=@var{level}
|
||||
@opindex status
|
||||
@@ -9279,6 +9340,8 @@ An additional line like @samp{1 truncated record} or @samp{10
|
||||
truncated records} is output after the @samp{records out} line if
|
||||
@samp{conv=block} processing truncated one or more input records.
|
||||
|
||||
The @samp{status=} operand is a GNU extension to POSIX.
|
||||
|
||||
@item conv=@var{conversion}[,@var{conversion}]@dots{}
|
||||
@opindex conv
|
||||
Convert the file as specified by the @var{conversion} argument(s).
|
||||
@@ -9326,6 +9389,8 @@ Remove any trailing spaces in each @samp{cbs}-sized input block,
|
||||
and append a newline.
|
||||
|
||||
The @samp{block} and @samp{unblock} conversions are mutually exclusive.
|
||||
If you use either of these conversions, you should also use the
|
||||
@samp{cbs=} operand.
|
||||
|
||||
@item lcase
|
||||
@opindex lcase@r{, converting to}
|
||||
@@ -9351,12 +9416,12 @@ Similarly, when the output is a device rather than a file,
|
||||
NUL input blocks are not copied, and therefore this conversion
|
||||
is most useful with virtual or pre zeroed devices.
|
||||
|
||||
The @samp{sparse} conversion is a GNU extension to POSIX.
|
||||
|
||||
@item swab
|
||||
@opindex swab @r{(byte-swapping)}
|
||||
@cindex byte-swapping
|
||||
Swap every pair of input bytes. GNU @command{dd}, unlike others, works
|
||||
when an odd number of bytes are read---the last byte is simply copied
|
||||
(since there is nothing to swap it with).
|
||||
Swap every pair of input bytes.
|
||||
|
||||
@item sync
|
||||
@opindex sync @r{(padding with ASCII NULs)}
|
||||
@@ -9381,7 +9446,8 @@ output file itself.
|
||||
@cindex creating output file, avoiding
|
||||
Do not create the output file; the output file must already exist.
|
||||
|
||||
The @samp{excl} and @samp{nocreat} conversions are mutually exclusive.
|
||||
The @samp{excl} and @samp{nocreat} conversions are mutually exclusive,
|
||||
and are GNU extensions to POSIX.
|
||||
|
||||
@item notrunc
|
||||
@opindex notrunc
|
||||
@@ -9396,14 +9462,18 @@ Continue after read errors.
|
||||
@item fdatasync
|
||||
@opindex fdatasync
|
||||
@cindex synchronized data writes, before finishing
|
||||
Synchronize output data just before finishing. This forces a physical
|
||||
write of output data.
|
||||
Synchronize output data just before finishing,
|
||||
even if there were write errors.
|
||||
This forces a physical write of output data.
|
||||
This conversion is a GNU extension to POSIX.
|
||||
|
||||
@item fsync
|
||||
@opindex fsync
|
||||
@cindex synchronized data and metadata writes, before finishing
|
||||
Synchronize output data and metadata just before finishing. This
|
||||
forces a physical write of output data and metadata.
|
||||
Synchronize output data and metadata just before finishing,
|
||||
even if there were write errors.
|
||||
This forces a physical write of output data and metadata.
|
||||
This conversion is a GNU extension to POSIX.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -9417,8 +9487,7 @@ argument(s). (No spaces around any comma(s).)
|
||||
Access the output file using the flags specified by the @var{flag}
|
||||
argument(s). (No spaces around any comma(s).)
|
||||
|
||||
Here are the flags. Not every flag is supported on every operating
|
||||
system.
|
||||
Here are the flags.
|
||||
|
||||
@table @samp
|
||||
|
||||
@@ -9559,30 +9628,10 @@ as they may return short reads. In that case,
|
||||
this flag is needed to ensure that a @samp{count=} argument is
|
||||
interpreted as a block count rather than a count of read operations.
|
||||
|
||||
@item count_bytes
|
||||
@opindex count_bytes
|
||||
Interpret the @samp{count=} operand as a byte count,
|
||||
rather than a block count, which allows specifying
|
||||
a length that is not a multiple of the I/O block size.
|
||||
This flag can be used only with @code{iflag}.
|
||||
|
||||
@item skip_bytes
|
||||
@opindex skip_bytes
|
||||
Interpret the @samp{skip=} operand as a byte count,
|
||||
rather than a block count, which allows specifying
|
||||
an offset that is not a multiple of the I/O block size.
|
||||
This flag can be used only with @code{iflag}.
|
||||
|
||||
@item seek_bytes
|
||||
@opindex seek_bytes
|
||||
Interpret the @samp{seek=} operand as a byte count,
|
||||
rather than a block count, which allows specifying
|
||||
an offset that is not a multiple of the I/O block size.
|
||||
This flag can be used only with @code{oflag}.
|
||||
|
||||
@end table
|
||||
|
||||
These flags are not supported on all systems, and @samp{dd} rejects
|
||||
These flags are all GNU extensions to POSIX.
|
||||
They are not supported on all systems, and @samp{dd} rejects
|
||||
attempts to use them when they are not supported. When reading from
|
||||
standard input or writing to standard output, the @samp{nofollow} and
|
||||
@samp{noctty} flags should not be specified, and the other flags
|
||||
@@ -9591,34 +9640,42 @@ affected file descriptors, even after @command{dd} exits.
|
||||
|
||||
@end table
|
||||
|
||||
The behavior of @command{dd} is unspecified if operands other than
|
||||
@samp{conv=}, @samp{iflag=}, @samp{oflag=}, and @samp{status=} are
|
||||
specified more than once.
|
||||
|
||||
@cindex multipliers after numbers
|
||||
The numeric-valued strings above (@var{n} and @var{bytes})
|
||||
are unsigned decimal integers that
|
||||
can be followed by a multiplier: @samp{b}=512, @samp{c}=1,
|
||||
@samp{w}=2, @samp{x@var{m}}=@var{m}, or any of the
|
||||
standard block size suffixes like @samp{k}=1024 (@pxref{Block size}).
|
||||
These multipliers are GNU extensions to POSIX, except that
|
||||
POSIX allows @var{bytes} to be followed by @samp{k}, @samp{b}, and
|
||||
@samp{x@var{m}}.
|
||||
Block sizes (i.e., specified by @var{bytes} strings) must be nonzero.
|
||||
|
||||
Any block size you specify via @samp{bs=}, @samp{ibs=}, @samp{obs=}, @samp{cbs=}
|
||||
should not be too large---values larger than a few megabytes
|
||||
are generally wasteful or (as in the gigabyte..exabyte case) downright
|
||||
counterproductive or error-inducing.
|
||||
|
||||
To process data that is at an offset or size that is not a
|
||||
multiple of the I/O@ block size, you can use the @samp{skip_bytes},
|
||||
@samp{seek_bytes} and @samp{count_bytes} flags. Alternatively
|
||||
the traditional method of separate @command{dd} invocations can be used.
|
||||
To process data with offset or size that is not a multiple of the I/O
|
||||
block size, you can use a numeric string @var{n} that ends in the
|
||||
letter @samp{B}.
|
||||
For example, the following shell commands copy data
|
||||
in 512 KiB blocks between a flash drive and a tape, but do not save
|
||||
or restore a 1 MiB area at the start of the flash drive:
|
||||
in 1 MiB blocks between a flash drive and a tape, but do not save
|
||||
or restore a 512-byte area at the start of the flash drive:
|
||||
|
||||
@example
|
||||
flash=/dev/sda
|
||||
tape=/dev/st0
|
||||
|
||||
# Copy all but the initial 1 MiB from flash to tape.
|
||||
(dd bs=1M skip=1 count=0 && dd bs=512k) <$flash >$tape
|
||||
# Copy all but the initial 512 bytes from flash to tape.
|
||||
dd if=$flash iseek=512B bs=1MiB of=$tape
|
||||
|
||||
# Copy from tape back to flash, leaving initial 1 MiB alone.
|
||||
(dd bs=1M seek=1 count=0 && dd bs=512k) <$tape >$flash
|
||||
# Copy from tape back to flash, leaving initial 512 bytes alone.
|
||||
dd if=$tape bs=1MiB of=$flash oseek=512B
|
||||
@end example
|
||||
|
||||
@cindex ddrescue
|
||||
@@ -9739,8 +9796,8 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
@itemx --compare
|
||||
@opindex -C
|
||||
@opindex --compare
|
||||
Compare each pair of source and destination files, and if the destination has
|
||||
identical content and any specified owner, group, permissions, and possibly
|
||||
Compare content of source and destination files, and if there would be no
|
||||
change to the destination content, owner, group, permissions, and possibly
|
||||
SELinux context, then do not modify the destination at all.
|
||||
Note this option is best used in conjunction with @option{--user},
|
||||
@option{--group} and @option{--mode} options, lest @command{install}
|
||||
@@ -11261,7 +11318,8 @@ or group ID, then you may specify it with a leading @samp{+}.
|
||||
Some older scripts may still use @samp{.} in place of the @samp{:} separator.
|
||||
POSIX 1003.1-2001 (@pxref{Standards conformance}) does not
|
||||
require support for that, but for backward compatibility GNU
|
||||
@command{chown} supports @samp{.} so long as no ambiguity results.
|
||||
@command{chown} supports @samp{.} so long as no ambiguity results,
|
||||
although it issues a warning and support may be removed in future versions.
|
||||
New scripts should avoid the use of @samp{.} because it is not
|
||||
portable, and because it has undesirable results if the entire
|
||||
@var{owner@samp{.}group} happens to identify a user whose name
|
||||
@@ -11609,7 +11667,7 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
@opindex -c
|
||||
@opindex --changes
|
||||
Verbosely describe the action for each @var{file} whose permissions
|
||||
actually changes.
|
||||
actually change.
|
||||
|
||||
@item -f
|
||||
@itemx --silent
|
||||
@@ -12550,6 +12608,7 @@ Always read the already cached attributes if available.
|
||||
|
||||
@item never
|
||||
Always sychronize with the latest file system attributes.
|
||||
This also mounts automounted files.
|
||||
|
||||
@item default
|
||||
Leave the caching behavior to the underlying file system.
|
||||
@@ -12896,6 +12955,13 @@ echo [@var{option}]@dots{} [@var{string}]@dots{}
|
||||
|
||||
@mayConflictWithShellBuiltIn{echo}
|
||||
|
||||
Due to historical and backwards compatibility reasons, certain bare option-like
|
||||
strings cannot be passed to @command{echo} as non-option arguments.
|
||||
It is therefore not advisable to use @command{echo} for printing unknown or
|
||||
variable arguments. The @command{printf} command is recommended as a more
|
||||
portable and flexible replacement for tasks historically performed by
|
||||
@command{echo}. @xref{printf invocation}.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
Options must precede operands, and the normally-special argument
|
||||
@samp{--} has no special meaning and is treated like any other
|
||||
@@ -12961,13 +13027,15 @@ If the @env{POSIXLY_CORRECT} environment variable is set, then when
|
||||
option-like arguments instead of treating them as options. For
|
||||
example, @code{echo -ne hello} outputs @samp{-ne hello} instead of
|
||||
plain @samp{hello}. Also backslash escapes are always enabled.
|
||||
Note to echo the string @samp{-n}, one of the characters
|
||||
can be escaped in either octal or hexadecimal representation.
|
||||
For example, @code{echo -e '\x2dn'}.
|
||||
|
||||
POSIX does not require support for any options, and says
|
||||
that the behavior of @command{echo} is implementation-defined if any
|
||||
@var{string} contains a backslash or if the first argument is
|
||||
@option{-n}. Portable programs can use the @command{printf} command
|
||||
if they need to omit trailing newlines or output control characters or
|
||||
backslashes. @xref{printf invocation}.
|
||||
@var{string} contains a backslash or if the first argument is @option{-n}.
|
||||
Portable programs should use the @command{printf} command instead.
|
||||
@xref{printf invocation}.
|
||||
|
||||
@exitstatus
|
||||
|
||||
@@ -13383,7 +13451,7 @@ True if @var{file} exists and has its @dfn{sticky} bit set.
|
||||
@item -r @var{file}
|
||||
@opindex -r
|
||||
@cindex readable file check
|
||||
True if @var{file} exists and read permission is granted.
|
||||
True if @var{file} exists and the user has read access.
|
||||
|
||||
@item -u @var{file}
|
||||
@opindex -u
|
||||
@@ -13393,12 +13461,12 @@ True if @var{file} exists and has its set-user-ID bit set.
|
||||
@item -w @var{file}
|
||||
@opindex -w
|
||||
@cindex writable file check
|
||||
True if @var{file} exists and write permission is granted.
|
||||
True if @var{file} exists and the user has write access.
|
||||
|
||||
@item -x @var{file}
|
||||
@opindex -x
|
||||
@cindex executable file check
|
||||
True if @var{file} exists and execute permission is granted
|
||||
True if @var{file} exists and the user has execute access
|
||||
(or search permission, if it is a directory).
|
||||
|
||||
@item -O @var{file}
|
||||
@@ -13910,11 +13978,11 @@ If a file being written to does not already exist, it is created. If a
|
||||
file being written to already exists, the data it previously contained
|
||||
is overwritten unless the @option{-a} option is used.
|
||||
|
||||
In previous versions of GNU coreutils (v5.3.0 - v8.23), a @var{file} of @samp{-}
|
||||
In previous versions of GNU Coreutils (v5.3.0 -- v8.23),
|
||||
a @var{file} of @samp{-}
|
||||
caused @command{tee} to send another copy of input to standard output.
|
||||
However, as the interleaved output was not very useful, @command{tee} now
|
||||
conforms to POSIX which explicitly mandates it to treat @samp{-} as a file
|
||||
with such name.
|
||||
conforms to POSIX and treats @samp{-} as a file name.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@@ -15967,6 +16035,11 @@ date [-u|--utc|--universal] @c this avoids a newline in the output
|
||||
[ MMDDhhmm[[CC]YY][.ss] ]
|
||||
@end example
|
||||
|
||||
The @command{date} command displays the date and time.
|
||||
With the @option{--set} (@option{-s}) option, or with
|
||||
@samp{MMDDhhmm[[CC]YY][.ss]},
|
||||
it sets the date and time.
|
||||
|
||||
@vindex LC_TIME
|
||||
Invoking @command{date} with no @var{format} argument is equivalent to invoking
|
||||
it with a default format that depends on the @env{LC_TIME} locale category.
|
||||
@@ -16218,6 +16291,12 @@ The following optional flags can appear after the @samp{%}:
|
||||
(hyphen) Do not pad the field; useful if the output is intended for
|
||||
human consumption.
|
||||
This is a GNU extension.
|
||||
As a special case, @samp{%-N} outputs only enough trailing digits to
|
||||
not lose information, assuming that the timestamp's resolution is the
|
||||
same as the current hardware clock. For example, if the hardware
|
||||
clock resolution is 1 microsecond, @samp{%s.%-N} outputs something
|
||||
like @samp{1640890100.395710}.
|
||||
|
||||
@item _
|
||||
(underscore) Pad with spaces; useful if you need a fixed
|
||||
number of characters in the output, but zeros are too distracting.
|
||||
@@ -16294,17 +16373,18 @@ modifiers are GNU extensions.
|
||||
@cindex time setting
|
||||
@cindex appropriate privileges
|
||||
|
||||
If given an argument that does not start with @samp{+}, @command{date} sets
|
||||
the system clock to the date and time specified by that argument (as
|
||||
described below). You must have appropriate privileges to set the
|
||||
system clock. Note for changes to persist across a reboot, the
|
||||
You must have appropriate privileges to set the
|
||||
system clock. For changes to persist across a reboot, the
|
||||
hardware clock may need to be updated from the system clock, which
|
||||
might not happen automatically on your system.
|
||||
|
||||
The argument must consist entirely of digits, which have the following
|
||||
meaning:
|
||||
To set the clock, you can use the @option{--set} (@option{-s}) option
|
||||
(@pxref{Options for date}). To set the clock without using GNU
|
||||
extensions, you can give @command{date} an argument of the form
|
||||
@samp{MMDDhhmm[[CC]YY][.ss]} where each two-letter
|
||||
component stands for two digits with the following meanings:
|
||||
|
||||
@table @samp
|
||||
@table @var
|
||||
@item MM
|
||||
month
|
||||
@item DD
|
||||
@@ -16334,6 +16414,7 @@ relative to Universal Time rather than to the local time zone.
|
||||
@cindex options for @command{date}
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
Except for @option{-u}, these options are all GNU extensions to POSIX.
|
||||
|
||||
@table @samp
|
||||
|
||||
@@ -16421,6 +16502,19 @@ for the @option{--date} (@option{-d}) and @option{--file}
|
||||
Display the date and time of the last modification of @var{file},
|
||||
instead of the current date and time.
|
||||
|
||||
@item --resolution
|
||||
@opindex --resolution
|
||||
Display the timestamp resolution instead of the time.
|
||||
Current clock timestamps that are output by @command{date}
|
||||
are integer multiples of the timestamp resolution.
|
||||
With this option, the format defaults to @samp{%s.%N}.
|
||||
For example, if the clock resolution is 1 millsecond,
|
||||
the output is:
|
||||
|
||||
@example
|
||||
0.001000000
|
||||
@end example
|
||||
|
||||
@item -R
|
||||
@itemx --rfc-email
|
||||
@opindex -R
|
||||
@@ -16449,7 +16543,8 @@ For compatibility with older versions of @command{date},
|
||||
Display the date using a format specified by
|
||||
@uref{https://tools.ietf.org/search/rfc3339, Internet
|
||||
RFC 3339}. This is like @option{--iso-8601}, except that a space rather
|
||||
than a @samp{T} separates dates from times.
|
||||
than a @samp{T} separates dates from times, and a period rather than
|
||||
a comma separates seconds from subseconds.
|
||||
@dateParseNote
|
||||
|
||||
The argument @var{timespec} specifies how much of the time to include.
|
||||
@@ -18273,8 +18368,9 @@ The specified @var{duration} starts from the point in time when
|
||||
@command{timeout} sends the initial signal to @var{command}, i.e.,
|
||||
not from the beginning when the @var{command} is started.
|
||||
|
||||
This option has no effect if @command{timeout}'s duration is 0 which
|
||||
disables the associated timeout.
|
||||
This option has no effect if either the main @var{duration}
|
||||
of the @command{timeout} command, or the @var{duration} specified
|
||||
to this option, is 0.
|
||||
|
||||
This option may be useful if the selected signal did not kill the @var{command},
|
||||
either because the signal was blocked or ignored, or if the @var{command} takes
|
||||
@@ -18321,7 +18417,7 @@ Exit status:
|
||||
the exit status of @var{command} otherwise
|
||||
@end display
|
||||
|
||||
In case of the @samp{KILL(9)} signal, @command{timeout} returns with
|
||||
In the case of the @samp{KILL(9)} signal, @command{timeout} returns with
|
||||
exit status 137, regardless of whether that signal is sent to @var{command}
|
||||
or to @command{timeout} itself, i.e., these cases cannot be distinguished.
|
||||
In the latter case, the @var{command} process may still be alive after
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@c File mode bits
|
||||
|
||||
@c Copyright (C) 1994--2021 Free Software Foundation, Inc.
|
||||
@c Copyright (C) 1994--2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@c GNU Version-sort ordering documentation
|
||||
|
||||
@c Copyright (C) 2019--2021 Free Software Foundation, Inc.
|
||||
@c Copyright (C) 2019--2022 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,76 @@ 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.
|
||||
|
||||
@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 +648,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 +659,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 +675,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 +691,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 +718,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 +730,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 +755,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 +763,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 +779,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 +835,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 +857,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,
|
||||
strvercmp(3)} function to compare two strings, and
|
||||
@uref{http://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 +884,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 +901,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
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declare an access pattern hint for files.
|
||||
Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2022 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declare an access pattern hint for files.
|
||||
Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2022 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
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -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-2022 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 ();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Barebones heap implementation supporting only insert and pop.
|
||||
|
||||
Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2022 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Barebones heap implementation supporting only insert and pop.
|
||||
|
||||
Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2022 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 ();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Align/Truncate a string in a given screen width
|
||||
Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2022 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,6 +19,8 @@
|
||||
#include <config.h>
|
||||
#include "mbsalign.h"
|
||||
|
||||
#include "minmax.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@@ -28,10 +30,6 @@
|
||||
#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 +82,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? */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Align/Truncate a string in a given screen width
|
||||
Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2009-2022 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 ();
|
||||
|
||||
@@ -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-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998, 1999 Colin Plumb.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random integers.
|
||||
|
||||
Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random integers.
|
||||
|
||||
Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate random permutations.
|
||||
|
||||
Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2022 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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "attribute.h"
|
||||
#include "count-leading-zeros.h"
|
||||
#include "hash.h"
|
||||
#include "verify.h"
|
||||
@@ -32,7 +33,7 @@
|
||||
|
||||
/* 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);
|
||||
@@ -117,7 +118,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});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate buffers of random data.
|
||||
|
||||
Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2022 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
|
||||
@@ -40,25 +40,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 +102,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 +143,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 +190,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 +311,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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Generate buffers of random data.
|
||||
|
||||
Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2022 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
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Root device and inode number checking.
|
||||
|
||||
Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2022 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. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Include and determine availability of smack routines
|
||||
Copyright (C) 2013-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2013-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare integer strings.
|
||||
|
||||
Copyright (C) 2005-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2022 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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare numeric strings. This is an internal include file.
|
||||
|
||||
Copyright (C) 1988-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Compare numeric strings.
|
||||
|
||||
Copyright (C) 2005-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2022 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)
|
||||
{
|
||||
|
||||
@@ -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
118
gl/lib/targetdir.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/* Target directory operands for coreutils
|
||||
|
||||
Copyright 2004-2022 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);
|
||||
}
|
||||
44
gl/lib/targetdir.h
Normal file
44
gl/lib/targetdir.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Target directory operands for coreutils
|
||||
|
||||
Copyright 2022 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 <stdbool.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
|
||||
@@ -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-2022 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,10 +21,12 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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 +50,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 +70,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;
|
||||
|
||||
@@ -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-2022 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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* xfts.c -- a wrapper for fts_open
|
||||
|
||||
Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2022 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
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
|
||||
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;
|
||||
|
||||
@@ -6,6 +6,7 @@ lib/mbsalign.c
|
||||
lib/mbsalign.h
|
||||
|
||||
Depends-on:
|
||||
minmax
|
||||
wchar
|
||||
wctype
|
||||
wcwidth
|
||||
|
||||
@@ -14,6 +14,7 @@ inline
|
||||
fopen-safer
|
||||
getrandom
|
||||
quote
|
||||
minmax
|
||||
stdalign
|
||||
stdbool
|
||||
stdint
|
||||
|
||||
25
gl/modules/targetdir
Normal file
25
gl/modules/targetdir
Normal 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
|
||||
@@ -11,6 +11,8 @@ Depends-on:
|
||||
error
|
||||
errno
|
||||
quote
|
||||
stdbool
|
||||
verify
|
||||
xstrtoimax
|
||||
xstrtoumax
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Test that fadvise works as advertised.
|
||||
Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2022 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Test that mbsalign works as advertised.
|
||||
Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Test the ISAAC or ISAAC64 pseudorandom number generator.
|
||||
|
||||
Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2010-2022 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
|
||||
|
||||
2
gnulib
2
gnulib
Submodule gnulib updated: 9aca7b6733...58c597d13b
12
init.cfg
12
init.cfg
@@ -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-2022 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' ' ')
|
||||
@@ -540,7 +541,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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Exercise chdir-long's sample main program.
|
||||
|
||||
# Copyright (C) 2005-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2005-2022 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
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#serial 27
|
||||
# Check declarations for this package.
|
||||
|
||||
dnl Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 1997-2022 Free Software Foundation, Inc.
|
||||
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#serial 2
|
||||
dnl Copyright (C) 2007-2021 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2007-2022 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.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
dnl Misc type-related macros for coreutils.
|
||||
|
||||
# Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998-2022 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
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# xattr.m4 - check for Extended Attributes (Linux)
|
||||
# serial 4
|
||||
|
||||
# Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2022 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.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 2018-2022 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>.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2022 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>.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2022 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>.
|
||||
|
||||
2
man/df.x
2
man/df.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2022 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>.
|
||||
|
||||
2
man/du.x
2
man/du.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2022 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>.
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
echo \- display a line of text
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
printf(1)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2022 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
|
||||
|
||||
11
man/help2man
11
man/help2man
@@ -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;
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
2
man/ls.x
2
man/ls.x
@@ -2,3 +2,5 @@
|
||||
ls \- list directory contents
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
dircolors(1)
|
||||
|
||||
2
man/rm.x
2
man/rm.x
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 1998-2022 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>.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'\" Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
||||
'\" Copyright (C) 2009-2022 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>.
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
'\" Copyright (C) 1998-2022 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)
|
||||
|
||||
9
man/tr.x
9
man/tr.x
@@ -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 .
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# List of files which contain translatable strings.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2022 Free Software Foundation, Inc.
|
||||
|
||||
# These are nominally temporary...
|
||||
lib/argmatch.c
|
||||
|
||||
@@ -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-2022 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2019-2021 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2019-2022 Free Software Foundation, Inc.
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification,
|
||||
# are permitted in any medium without royalty provided the copyright
|
||||
|
||||
@@ -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,12 @@ 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';
|
||||
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 +151,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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* basename -- strip directory and suffix from file names
|
||||
Copyright (C) 1990-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-2022 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
|
||||
|
||||
65
src/basenc.c
65
src/basenc.c
@@ -1,5 +1,5 @@
|
||||
/* Base64, base32, and similar encoding/decoding strings or files.
|
||||
Copyright (C) 2004-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004-2022 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,13 +175,13 @@ 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. */
|
||||
@@ -196,7 +196,7 @@ 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. */
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
int blake2b_stream( FILE *stream, void *resstream, size_t outbytes );
|
||||
int blake2b_stream (FILE *stream, void *resstream, size_t outbytes)
|
||||
_GL_ATTRIBUTE_NONNULL ((1));
|
||||
typedef int ( *blake2fn )( FILE *, void *, size_t );
|
||||
#define BLAKE2S_OUTBYTES 32
|
||||
#define BLAKE2B_OUTBYTES 64
|
||||
|
||||
@@ -18,18 +18,12 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __has_attribute
|
||||
# if __has_attribute (packed)
|
||||
# define BLAKE2_PACKED(x) x __attribute__ ((packed))
|
||||
# endif
|
||||
#endif
|
||||
#if !defined BLAKE2_PACKED && defined _MSC_VER
|
||||
/* Pack a structure if possible. This might save space, and is not
|
||||
needed for correctness. */
|
||||
#ifdef _MSC_VER
|
||||
# define BLAKE2_PACKED(x) __pragma (pack (push, 1)) x __pragma (pack (pop))
|
||||
#endif
|
||||
#ifndef BLAKE2_PACKED
|
||||
/* This should be good enough on other platforms.
|
||||
If it's not good on yours, please file a bug report. */
|
||||
# define BLAKE2_PACKED(x) x
|
||||
#else
|
||||
# define BLAKE2_PACKED(x) x _GL_ATTRIBUTE_PACKED
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@@ -145,8 +139,8 @@ extern "C" {
|
||||
|
||||
/* Padded structs result in a compile-time error */
|
||||
enum {
|
||||
BLAKE2_DUMMY_1 = 1/(sizeof(blake2s_param) == BLAKE2S_OUTBYTES),
|
||||
BLAKE2_DUMMY_2 = 1/(sizeof(blake2b_param) == BLAKE2B_OUTBYTES)
|
||||
BLAKE2_DUMMY_1 = 1 / (sizeof (blake2s_param) == BLAKE2S_OUTBYTES),
|
||||
BLAKE2_DUMMY_2 = 1 / (sizeof (blake2b_param) == BLAKE2B_OUTBYTES)
|
||||
};
|
||||
|
||||
/* Streaming API */
|
||||
@@ -158,7 +152,8 @@ extern "C" {
|
||||
|
||||
int blake2b_init( blake2b_state *S, size_t outlen );
|
||||
int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen );
|
||||
int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
|
||||
int blake2b_init_param (blake2b_state *S, const blake2b_param *P)
|
||||
_GL_ATTRIBUTE_NONNULL ();
|
||||
int blake2b_update( blake2b_state *S, const void *in, size_t inlen );
|
||||
int blake2b_final( blake2b_state *S, void *out, size_t outlen );
|
||||
|
||||
|
||||
@@ -156,11 +156,11 @@ int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t k
|
||||
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+0]]; \
|
||||
a = a + b + m[blake2b_sigma[r][2 * i + 0]]; \
|
||||
d = rotr64(d ^ a, 32); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 24); \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+1]]; \
|
||||
a = a + b + m[blake2b_sigma[r][2 * i + 1]]; \
|
||||
d = rotr64(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 63); \
|
||||
|
||||
229
src/cat.c
229
src/cat.c
@@ -1,5 +1,5 @@
|
||||
/* cat -- concatenate files and print on the standard output.
|
||||
Copyright (C) 1988-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2022 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
|
||||
@@ -33,6 +33,8 @@
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "alignalloc.h"
|
||||
#include "idx.h"
|
||||
#include "ioblksize.h"
|
||||
#include "die.h"
|
||||
#include "error.h"
|
||||
@@ -140,6 +142,7 @@ next_line_num (void)
|
||||
*endp-- = '0';
|
||||
}
|
||||
while (endp >= line_num_start);
|
||||
|
||||
if (line_num_start > line_buf)
|
||||
*--line_num_start = '1';
|
||||
else
|
||||
@@ -148,28 +151,20 @@ next_line_num (void)
|
||||
line_num_print--;
|
||||
}
|
||||
|
||||
/* Plain cat. Copies the file behind 'input_desc' to STDOUT_FILENO.
|
||||
/* Plain cat. Copy the file behind 'input_desc' to STDOUT_FILENO.
|
||||
BUF (of size BUFSIZE) is the I/O buffer, used by reads and writes.
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
simple_cat (
|
||||
/* Pointer to the buffer, used by reads and writes. */
|
||||
char *buf,
|
||||
|
||||
/* Number of characters preferably read or written by each read and write
|
||||
call. */
|
||||
size_t bufsize)
|
||||
simple_cat (char *buf, idx_t bufsize)
|
||||
{
|
||||
/* Actual number of characters read, and therefore written. */
|
||||
size_t n_read;
|
||||
|
||||
/* Loop until the end of the file. */
|
||||
|
||||
while (true)
|
||||
{
|
||||
/* Read a block of input. */
|
||||
|
||||
n_read = safe_read (input_desc, buf, bufsize);
|
||||
size_t n_read = safe_read (input_desc, buf, bufsize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
{
|
||||
error (0, errno, "%s", quotef (infile));
|
||||
@@ -183,12 +178,8 @@ simple_cat (
|
||||
|
||||
/* Write this block out. */
|
||||
|
||||
{
|
||||
/* The following is ok, since we know that 0 < n_read. */
|
||||
size_t n = n_read;
|
||||
if (full_write (STDOUT_FILENO, buf, n) != n)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
if (full_write (STDOUT_FILENO, buf, n_read) != n_read)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +190,7 @@ simple_cat (
|
||||
static inline void
|
||||
write_pending (char *outbuf, char **bpout)
|
||||
{
|
||||
size_t n_write = *bpout - outbuf;
|
||||
idx_t n_write = *bpout - outbuf;
|
||||
if (0 < n_write)
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, outbuf, n_write) != n_write)
|
||||
@@ -208,7 +199,12 @@ write_pending (char *outbuf, char **bpout)
|
||||
}
|
||||
}
|
||||
|
||||
/* Cat the file behind INPUT_DESC to the file behind OUTPUT_DESC.
|
||||
/* Copy the file behind 'input_desc' to STDOUT_FILENO.
|
||||
Use INBUF and read INSIZE with each call,
|
||||
and OUTBUF and write OUTSIZE with each call.
|
||||
(The buffers are a bit larger than the I/O sizes.)
|
||||
The remaining boolean args say what 'cat' options to use.
|
||||
|
||||
Return true if successful.
|
||||
Called if any option more than -u was specified.
|
||||
|
||||
@@ -216,43 +212,13 @@ write_pending (char *outbuf, char **bpout)
|
||||
an explicit test for buffer end unnecessary. */
|
||||
|
||||
static bool
|
||||
cat (
|
||||
/* Pointer to the beginning of the input buffer. */
|
||||
char *inbuf,
|
||||
|
||||
/* Number of characters read in each read call. */
|
||||
size_t insize,
|
||||
|
||||
/* Pointer to the beginning of the output buffer. */
|
||||
char *outbuf,
|
||||
|
||||
/* Number of characters written by each write call. */
|
||||
size_t outsize,
|
||||
|
||||
/* Variables that have values according to the specified options. */
|
||||
bool show_nonprinting,
|
||||
bool show_tabs,
|
||||
bool number,
|
||||
bool number_nonblank,
|
||||
bool show_ends,
|
||||
bool squeeze_blank)
|
||||
cat (char *inbuf, idx_t insize, char *outbuf, idx_t outsize,
|
||||
bool show_nonprinting, bool show_tabs, bool number, bool number_nonblank,
|
||||
bool show_ends, bool squeeze_blank)
|
||||
{
|
||||
/* Last character read from the input buffer. */
|
||||
unsigned char ch;
|
||||
|
||||
/* Pointer to the next character in the input buffer. */
|
||||
char *bpin;
|
||||
|
||||
/* Pointer to the first non-valid byte in the input buffer, i.e., the
|
||||
current end of the buffer. */
|
||||
char *eob;
|
||||
|
||||
/* Pointer to the position where the next character shall be written. */
|
||||
char *bpout;
|
||||
|
||||
/* Number of characters read by the last read call. */
|
||||
size_t n_read;
|
||||
|
||||
/* Determines how many consecutive newlines there have been in the
|
||||
input. 0 newlines makes NEWLINES -1, 1 newline makes NEWLINES 1,
|
||||
etc. Initially 0 to indicate that we are at the beginning of a
|
||||
@@ -269,10 +235,15 @@ cat (
|
||||
/* The inbuf pointers are initialized so that BPIN > EOB, and thereby input
|
||||
is read immediately. */
|
||||
|
||||
eob = inbuf;
|
||||
bpin = eob + 1;
|
||||
/* Pointer to the first non-valid byte in the input buffer, i.e., the
|
||||
current end of the buffer. */
|
||||
char *eob = inbuf;
|
||||
|
||||
bpout = outbuf;
|
||||
/* Pointer to the next character in the input buffer. */
|
||||
char *bpin = eob + 1;
|
||||
|
||||
/* Pointer to the position where the next character shall be written. */
|
||||
char *bpout = outbuf;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -283,7 +254,7 @@ cat (
|
||||
if (outbuf + outsize <= bpout)
|
||||
{
|
||||
char *wp = outbuf;
|
||||
size_t remaining_bytes;
|
||||
idx_t remaining_bytes;
|
||||
do
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, wp, outsize) != outsize)
|
||||
@@ -342,7 +313,7 @@ cat (
|
||||
|
||||
/* Read more input into INBUF. */
|
||||
|
||||
n_read = safe_read (input_desc, inbuf, insize);
|
||||
size_t n_read = safe_read (input_desc, inbuf, insize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
{
|
||||
error (0, errno, "%s", quotef (infile));
|
||||
@@ -528,38 +499,45 @@ cat (
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy data from input to output using copy_file_range if possible.
|
||||
Return 1 if successful, 0 if ordinary read+write should be tried,
|
||||
-1 if a serious problem has been diagnosed. */
|
||||
|
||||
static int
|
||||
copy_cat (void)
|
||||
{
|
||||
/* Copy at most COPY_MAX bytes at a time; this is min
|
||||
(SSIZE_MAX, SIZE_MAX) truncated to a value that is
|
||||
surely aligned well. */
|
||||
ssize_t copy_max = MIN (SSIZE_MAX, SIZE_MAX) >> 30 << 30;
|
||||
|
||||
/* copy_file_range does not support some cases, and it
|
||||
incorrectly returns 0 when reading from the proc file
|
||||
system on the Linux kernel through at least 5.6.19 (2020),
|
||||
so fall back on read+write if the copy_file_range is
|
||||
unsupported or the input file seems empty. */
|
||||
|
||||
for (bool some_copied = false; ; some_copied = true)
|
||||
switch (copy_file_range (input_desc, NULL, STDOUT_FILENO, NULL,
|
||||
copy_max, 0))
|
||||
{
|
||||
case 0:
|
||||
return some_copied;
|
||||
|
||||
case -1:
|
||||
if (errno == ENOSYS || is_ENOTSUP (errno) || errno == EINVAL
|
||||
|| errno == EBADF || errno == EXDEV || errno == ETXTBSY
|
||||
|| errno == EPERM)
|
||||
return 0;
|
||||
error (0, errno, "%s", quotef (infile));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
/* Optimal size of i/o operations of output. */
|
||||
size_t outsize;
|
||||
|
||||
/* Optimal size of i/o operations of input. */
|
||||
size_t insize;
|
||||
|
||||
size_t page_size = getpagesize ();
|
||||
|
||||
/* Pointer to the input buffer. */
|
||||
char *inbuf;
|
||||
|
||||
/* Pointer to the output buffer. */
|
||||
char *outbuf;
|
||||
|
||||
bool ok = true;
|
||||
int c;
|
||||
|
||||
/* Index in argv to processed argument. */
|
||||
int argind;
|
||||
|
||||
/* Device number of the output (file or whatever). */
|
||||
dev_t out_dev;
|
||||
|
||||
/* I-node number of the output. */
|
||||
ino_t out_ino;
|
||||
|
||||
/* True if the output is a regular file. */
|
||||
bool out_isreg;
|
||||
|
||||
/* Nonzero if we have ever read standard input. */
|
||||
bool have_read_stdin = false;
|
||||
|
||||
@@ -602,6 +580,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Parse command line options. */
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long (argc, argv, "benstuvAET", long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
@@ -666,10 +645,15 @@ main (int argc, char **argv)
|
||||
if (fstat (STDOUT_FILENO, &stat_buf) < 0)
|
||||
die (EXIT_FAILURE, errno, _("standard output"));
|
||||
|
||||
outsize = io_blksize (stat_buf);
|
||||
out_dev = stat_buf.st_dev;
|
||||
out_ino = stat_buf.st_ino;
|
||||
out_isreg = S_ISREG (stat_buf.st_mode) != 0;
|
||||
/* Optimal size of i/o operations of output. */
|
||||
idx_t outsize = io_blksize (stat_buf);
|
||||
|
||||
/* Device and I-node number of the output. */
|
||||
dev_t out_dev = stat_buf.st_dev;
|
||||
ino_t out_ino = stat_buf.st_ino;
|
||||
|
||||
/* True if the output is a regular file. */
|
||||
bool out_isreg = S_ISREG (stat_buf.st_mode) != 0;
|
||||
|
||||
if (! (number || show_ends || squeeze_blank))
|
||||
{
|
||||
@@ -677,19 +661,20 @@ main (int argc, char **argv)
|
||||
xset_binary_mode (STDOUT_FILENO, O_BINARY);
|
||||
}
|
||||
|
||||
/* Check if any of the input files are the same as the output file. */
|
||||
|
||||
/* Main loop. */
|
||||
|
||||
infile = "-";
|
||||
argind = optind;
|
||||
int argind = optind;
|
||||
bool ok = true;
|
||||
idx_t page_size = getpagesize ();
|
||||
|
||||
do
|
||||
{
|
||||
if (argind < argc)
|
||||
infile = argv[argind];
|
||||
|
||||
if (STREQ (infile, "-"))
|
||||
bool reading_stdin = STREQ (infile, "-");
|
||||
if (reading_stdin)
|
||||
{
|
||||
have_read_stdin = true;
|
||||
input_desc = STDIN_FILENO;
|
||||
@@ -713,7 +698,9 @@ main (int argc, char **argv)
|
||||
ok = false;
|
||||
goto contin;
|
||||
}
|
||||
insize = io_blksize (stat_buf);
|
||||
|
||||
/* Optimal size of i/o operations of input. */
|
||||
idx_t insize = io_blksize (stat_buf);
|
||||
|
||||
fdadvise (input_desc, 0, 0, FADVISE_SEQUENTIAL);
|
||||
|
||||
@@ -730,23 +717,37 @@ main (int argc, char **argv)
|
||||
goto contin;
|
||||
}
|
||||
|
||||
/* Pointer to the input buffer. */
|
||||
char *inbuf;
|
||||
|
||||
/* Select which version of 'cat' to use. If any format-oriented
|
||||
options were given use 'cat'; otherwise use 'simple_cat'. */
|
||||
options were given use 'cat'; if not, use 'copy_cat' if it
|
||||
works, 'simple_cat' otherwise. */
|
||||
|
||||
if (! (number || show_ends || show_nonprinting
|
||||
|| show_tabs || squeeze_blank))
|
||||
{
|
||||
insize = MAX (insize, outsize);
|
||||
inbuf = xmalloc (insize + page_size - 1);
|
||||
|
||||
ok &= simple_cat (ptr_align (inbuf, page_size), insize);
|
||||
int copy_cat_status =
|
||||
out_isreg && S_ISREG (stat_buf.st_mode) ? copy_cat () : 0;
|
||||
if (copy_cat_status != 0)
|
||||
{
|
||||
inbuf = NULL;
|
||||
ok &= 0 < copy_cat_status;
|
||||
}
|
||||
else
|
||||
{
|
||||
insize = MAX (insize, outsize);
|
||||
inbuf = xalignalloc (page_size, insize);
|
||||
ok &= simple_cat (inbuf, insize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
inbuf = xmalloc (insize + 1 + page_size - 1);
|
||||
/* Allocate, with an extra byte for a newline sentinel. */
|
||||
inbuf = xalignalloc (page_size, insize + 1);
|
||||
|
||||
/* Why are
|
||||
(OUTSIZE - 1 + INSIZE * 4 + LINE_COUNTER_BUF_LEN + PAGE_SIZE - 1)
|
||||
(OUTSIZE - 1 + INSIZE * 4 + LINE_COUNTER_BUF_LEN)
|
||||
bytes allocated for the output buffer?
|
||||
|
||||
A test whether output needs to be written is done when the input
|
||||
@@ -764,24 +765,26 @@ main (int argc, char **argv)
|
||||
positions.
|
||||
|
||||
Align the output buffer to a page size boundary, for efficiency
|
||||
on some paging implementations, so add PAGE_SIZE - 1 bytes to the
|
||||
request to make room for the alignment. */
|
||||
on some paging implementations. */
|
||||
|
||||
outbuf = xmalloc (outsize - 1 + insize * 4 + LINE_COUNTER_BUF_LEN
|
||||
+ page_size - 1);
|
||||
idx_t bufsize;
|
||||
if (INT_MULTIPLY_WRAPV (insize, 4, &bufsize)
|
||||
|| INT_ADD_WRAPV (bufsize, outsize, &bufsize)
|
||||
|| INT_ADD_WRAPV (bufsize, LINE_COUNTER_BUF_LEN - 1, &bufsize))
|
||||
xalloc_die ();
|
||||
char *outbuf = xalignalloc (page_size, bufsize);
|
||||
|
||||
ok &= cat (ptr_align (inbuf, page_size), insize,
|
||||
ptr_align (outbuf, page_size), outsize, show_nonprinting,
|
||||
ok &= cat (inbuf, insize, outbuf, outsize, show_nonprinting,
|
||||
show_tabs, number, number_nonblank, show_ends,
|
||||
squeeze_blank);
|
||||
|
||||
free (outbuf);
|
||||
alignfree (outbuf);
|
||||
}
|
||||
|
||||
free (inbuf);
|
||||
alignfree (inbuf);
|
||||
|
||||
contin:
|
||||
if (!STREQ (infile, "-") && close (input_desc) < 0)
|
||||
if (!reading_stdin && close (input_desc) < 0)
|
||||
{
|
||||
error (0, errno, "%s", quotef (infile));
|
||||
ok = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chcon -- change security context of files
|
||||
Copyright (C) 2005-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2022 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chgrp -- change group ownership of files
|
||||
Copyright (C) 1989-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2022 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,7 +313,5 @@ main (int argc, char **argv)
|
||||
(uid_t) -1, gid,
|
||||
(uid_t) -1, (gid_t) -1, &chopt);
|
||||
|
||||
IF_LINT (chopt_free (&chopt));
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
10
src/chmod.c
10
src/chmod.c
@@ -1,5 +1,5 @@
|
||||
/* chmod -- change permission modes of files
|
||||
Copyright (C) 1989-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2022 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
|
||||
@@ -44,8 +44,8 @@ struct change_status
|
||||
enum
|
||||
{
|
||||
CH_NO_STAT,
|
||||
CH_NOT_APPLIED,
|
||||
CH_FAILED,
|
||||
CH_NOT_APPLIED,
|
||||
CH_NO_CHANGE_REQUESTED,
|
||||
CH_SUCCEEDED
|
||||
}
|
||||
@@ -322,7 +322,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
if ( ! recurse)
|
||||
fts_set (fts, ent, FTS_SKIP);
|
||||
|
||||
return CH_NO_CHANGE_REQUESTED <= ch.status;
|
||||
return CH_NOT_APPLIED <= ch.status;
|
||||
}
|
||||
|
||||
/* Recursively change the modes of the specified FILES (the last entry
|
||||
@@ -567,7 +567,5 @@ main (int argc, char **argv)
|
||||
ok = process_files (argv + optind,
|
||||
FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT);
|
||||
|
||||
IF_LINT (free (change));
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* chown-core.c -- core functions for changing ownership.
|
||||
Copyright (C) 2000-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2022 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
|
||||
@@ -73,6 +73,28 @@ chopt_free (struct Chown_option *chopt)
|
||||
free (chopt->group_name);
|
||||
}
|
||||
|
||||
/* Convert the numeric user-id, UID, to a string stored in xmalloc'd memory,
|
||||
and return it. Use the decimal representation of the ID. */
|
||||
|
||||
static char *
|
||||
uid_to_str (uid_t uid)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
return xstrdup (TYPE_SIGNED (uid_t) ? imaxtostr (uid, buf)
|
||||
: umaxtostr (uid, buf));
|
||||
}
|
||||
|
||||
/* Convert the numeric group-id, GID, to a string stored in xmalloc'd memory,
|
||||
and return it. Use the decimal representation of the ID. */
|
||||
|
||||
static char *
|
||||
gid_to_str (gid_t gid)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
return xstrdup (TYPE_SIGNED (gid_t) ? imaxtostr (gid, buf)
|
||||
: umaxtostr (gid, buf));
|
||||
}
|
||||
|
||||
/* Convert the numeric group-id, GID, to a string stored in xmalloc'd memory,
|
||||
and return it. If there's no corresponding group name, use the decimal
|
||||
representation of the ID. */
|
||||
@@ -80,11 +102,8 @@ chopt_free (struct Chown_option *chopt)
|
||||
extern char *
|
||||
gid_to_name (gid_t gid)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
struct group *grp = getgrgid (gid);
|
||||
return xstrdup (grp ? grp->gr_name
|
||||
: TYPE_SIGNED (gid_t) ? imaxtostr (gid, buf)
|
||||
: umaxtostr (gid, buf));
|
||||
return grp ? xstrdup (grp->gr_name) : gid_to_str (gid);
|
||||
}
|
||||
|
||||
/* Convert the numeric user-id, UID, to a string stored in xmalloc'd memory,
|
||||
@@ -94,11 +113,8 @@ gid_to_name (gid_t gid)
|
||||
extern char *
|
||||
uid_to_name (uid_t uid)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
struct passwd *pwd = getpwuid (uid);
|
||||
return xstrdup (pwd ? pwd->pw_name
|
||||
: TYPE_SIGNED (uid_t) ? imaxtostr (uid, buf)
|
||||
: umaxtostr (uid, buf));
|
||||
return pwd ? xstrdup (pwd->pw_name) : uid_to_str (uid);
|
||||
}
|
||||
|
||||
/* Allocate a string representing USER and GROUP. */
|
||||
@@ -484,11 +500,21 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
: CH_SUCCEEDED);
|
||||
char *old_usr = file_stats ? uid_to_name (file_stats->st_uid) : NULL;
|
||||
char *old_grp = file_stats ? gid_to_name (file_stats->st_gid) : NULL;
|
||||
char *new_usr = chopt->user_name
|
||||
? chopt->user_name : uid != -1
|
||||
? uid_to_str (uid) : NULL;
|
||||
char *new_grp = chopt->group_name
|
||||
? chopt->group_name : gid != -1
|
||||
? gid_to_str (gid) : NULL;
|
||||
describe_change (file_full_name, ch_status,
|
||||
old_usr, old_grp,
|
||||
chopt->user_name, chopt->group_name);
|
||||
new_usr, new_grp);
|
||||
free (old_usr);
|
||||
free (old_grp);
|
||||
if (new_usr != chopt->user_name)
|
||||
free (new_usr);
|
||||
if (new_grp != chopt->group_name)
|
||||
free (new_grp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user