mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
118 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d10eb8b1e | ||
|
|
c0a121c9bc | ||
|
|
c9e4ea6ee2 | ||
|
|
819265b8be | ||
|
|
a9b904a282 | ||
|
|
7dc398a30f | ||
|
|
8fc12909f6 | ||
|
|
1777d0dfe3 | ||
|
|
56fce1aed7 | ||
|
|
36cc6ac787 | ||
|
|
62dd4b63c5 | ||
|
|
3a1595a3fb | ||
|
|
f8291d0ec4 | ||
|
|
05bee6f116 | ||
|
|
584e38d8b3 | ||
|
|
c420cfef77 | ||
|
|
be9a42e7ac | ||
|
|
20a5a60c61 | ||
|
|
0ba945b050 | ||
|
|
8c4b6ba09b | ||
|
|
ac6feeb9f2 | ||
|
|
ef5758c328 | ||
|
|
0a9302e7f7 | ||
|
|
9e66806e28 | ||
|
|
f6b2f46714 | ||
|
|
f267926f2d | ||
|
|
6f6f599867 | ||
|
|
2dc09bf809 | ||
|
|
98dacf492e | ||
|
|
b48a444e35 | ||
|
|
6416762b73 | ||
|
|
a8fc4edca5 | ||
|
|
3f7091359a | ||
|
|
0f5dc96354 | ||
|
|
5ef03d6c5b | ||
|
|
8915368ee3 | ||
|
|
b4f9559537 | ||
|
|
88d4b3461e | ||
|
|
4c38625ef3 | ||
|
|
946359f101 | ||
|
|
9f793def3c | ||
|
|
628a5e16dd | ||
|
|
773d15a702 | ||
|
|
c872a1d8a5 | ||
|
|
dfe0d336a0 | ||
|
|
3dcbcf98f4 | ||
|
|
dd9df4ab02 | ||
|
|
54158a45fa | ||
|
|
da2f637888 | ||
|
|
cab29edcf1 | ||
|
|
b44d4b6b0e | ||
|
|
d75820e516 | ||
|
|
46e0137277 | ||
|
|
c403c31e88 | ||
|
|
4edb86215d | ||
|
|
64bc4f20e8 | ||
|
|
141645d9c6 | ||
|
|
0c31cdc2d1 | ||
|
|
4323ed2bde | ||
|
|
c971ed9377 | ||
|
|
998fe29301 | ||
|
|
612c2c95c3 | ||
|
|
a7b4fa01dd | ||
|
|
dae35bac98 | ||
|
|
168a6b6a0f | ||
|
|
59e2e55d0f | ||
|
|
2590389aab | ||
|
|
9a6c97eb29 | ||
|
|
0b5bd805bd | ||
|
|
f5268e2749 | ||
|
|
cba49d57da | ||
|
|
a2f81776ad | ||
|
|
11d84c10ce | ||
|
|
58c98f2342 | ||
|
|
7ae60bf26f | ||
|
|
d4de2dc83a | ||
|
|
45b46f4951 | ||
|
|
9f650d0870 | ||
|
|
ed509250a2 | ||
|
|
543696a9af | ||
|
|
86573d33a7 | ||
|
|
cea6d15720 | ||
|
|
69cc8d5cb7 | ||
|
|
dd2253f49d | ||
|
|
f53a0e1062 | ||
|
|
628b1d5e7e | ||
|
|
f86bb6967d | ||
|
|
819aa9eba7 | ||
|
|
86914603b5 | ||
|
|
6e8f368e07 | ||
|
|
5d43617e8a | ||
|
|
5d4952059f | ||
|
|
c7ecdb0fcb | ||
|
|
aad0bde0b5 | ||
|
|
0caead1ea0 | ||
|
|
9c566ad04a | ||
|
|
3e8586bc54 | ||
|
|
014fead953 | ||
|
|
e489fd04d6 | ||
|
|
31423c76e8 | ||
|
|
cd349fdca2 | ||
|
|
eccf54368f | ||
|
|
7ba0e90c55 | ||
|
|
954ef23ed9 | ||
|
|
e55d882811 | ||
|
|
f28c7d959b | ||
|
|
3b498ba141 | ||
|
|
39243f0ea8 | ||
|
|
a4da48c4f5 | ||
|
|
d89755469b | ||
|
|
b81cdbf31e | ||
|
|
0a6bbb5947 | ||
|
|
6beca4248f | ||
|
|
37b8bfda56 | ||
|
|
21a6a7f64c | ||
|
|
6454dd0f2f | ||
|
|
d0f18197fc | ||
|
|
21f4da0fb9 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -40,8 +40,8 @@ coreutils-*.tar.bz2
|
||||
coreutils-*.tar.bz2.sig
|
||||
coreutils-*.tar.gz
|
||||
coreutils-*.tar.gz.sig
|
||||
coreutils-*.tar.lzma
|
||||
coreutils-*.tar.lzma.sig
|
||||
coreutils-*.tar.xz
|
||||
coreutils-*.tar.xz.sig
|
||||
gnulib-tests
|
||||
lib/.cvsignore
|
||||
lib/.gitignore
|
||||
@@ -60,6 +60,7 @@ lib/selinux
|
||||
lib/unistr
|
||||
lib/uniwidth
|
||||
lib/unused-parameter.h
|
||||
lib/warn-on-use.h
|
||||
m4/.cvsignore
|
||||
m4/.gitignore
|
||||
maint.mk
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.2
|
||||
8.4
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
gl/lib/randint.c
|
||||
lib/euidaccess-stat.c
|
||||
gl/tests/test-mbsalign.c
|
||||
|
||||
1
.x-sc_prohibit_empty_lines_at_EOF
Normal file
1
.x-sc_prohibit_empty_lines_at_EOF
Normal file
@@ -0,0 +1 @@
|
||||
^tests/pr/
|
||||
@@ -1,3 +1,2 @@
|
||||
configure.ac
|
||||
*.m4
|
||||
ChangeLog*
|
||||
|
||||
105
HACKING
105
HACKING
@@ -233,6 +233,107 @@ Try to make the summary line fit one of the following forms:
|
||||
maint: change-description
|
||||
|
||||
|
||||
Curly braces: use judiciously
|
||||
=============================
|
||||
Omit the curly braces around an "if", "while", "for" etc. body only when
|
||||
that body occupies a single line. In every other case we require the braces.
|
||||
This ensures that it is trivially easy to identify a single-*statement* loop:
|
||||
each has only one *line* in its body.
|
||||
|
||||
Omitting braces with a single-line body is fine:
|
||||
|
||||
while (expr)
|
||||
single_line_stmt ();
|
||||
|
||||
However, the moment your loop/if/else body extends onto a second line,
|
||||
for whatever reason (even if it's just an added comment), then you should
|
||||
add braces. Otherwise, it would be too easy to insert a statement just
|
||||
before that comment (without adding braces), thinking it is already a
|
||||
multi-statement loop:
|
||||
|
||||
while (true)
|
||||
/* comment... */ // BAD: multi-line body without braces
|
||||
single_line_stmt ();
|
||||
|
||||
Do this instead:
|
||||
|
||||
while (true)
|
||||
{ /* Always put braces around a multi-line body. */
|
||||
/* explanation... */
|
||||
single_line_stmt ();
|
||||
}
|
||||
|
||||
There is one exception: when the second body line is not at the same
|
||||
indentation level as the first body line.
|
||||
|
||||
if (expr)
|
||||
error (0, 0, _("a diagnostic that would make this line"
|
||||
" extend past the 80-column limit"));
|
||||
|
||||
It is safe to omit the braces in the code above, since the
|
||||
further-indented second body line makes it obvious that this is still
|
||||
a single-statement body.
|
||||
|
||||
To reiterate, don't do this:
|
||||
|
||||
if (expr)
|
||||
while (expr_2) // BAD: multi-line body without braces
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
Do this, instead:
|
||||
|
||||
if (expr)
|
||||
{
|
||||
while (expr_2)
|
||||
{
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
However, there is one exception in the other direction, when even a
|
||||
one-line block should have braces. That occurs when that one-line,
|
||||
brace-less block is an "else" block, and the corresponding "then" block
|
||||
*does* use braces. In that case, either put braces around the "else"
|
||||
block, or negate the "if"-condition and swap the bodies, putting the
|
||||
one-line block first and making the longer, multi-line block be the
|
||||
"else" block.
|
||||
|
||||
if (expr)
|
||||
{
|
||||
...
|
||||
...
|
||||
}
|
||||
else
|
||||
x = y; // BAD: braceless "else" with braced "then"
|
||||
|
||||
This is preferred, especially when the multi-line body is more than a
|
||||
few lines long, because it is easier to read and grasp the semantics of
|
||||
an if-then-else block when the simpler block occurs first, rather than
|
||||
after the more involved block:
|
||||
|
||||
if (!expr)
|
||||
x = y; /* more readable */
|
||||
else
|
||||
{
|
||||
...
|
||||
...
|
||||
}
|
||||
|
||||
If you'd rather not negate the condition, then add braces:
|
||||
|
||||
if (expr)
|
||||
{
|
||||
...
|
||||
...
|
||||
}
|
||||
else
|
||||
{
|
||||
x = y;
|
||||
}
|
||||
|
||||
|
||||
Use SPACE-only indentation in all[*] files
|
||||
==========================================
|
||||
We use space-only indentation in nearly all files.
|
||||
@@ -310,9 +411,9 @@ Nearly every significant change must be accompanied by a test suite
|
||||
addition that exercises it. If you fix a bug, add at least one test that
|
||||
fails without the patch, but that succeeds once your patch is applied.
|
||||
If you add a feature, add tests to exercise as much of the new code
|
||||
as possible. Note to run tests/misc/newtest in isolation you can do:
|
||||
as possible. Note to run tests/misc/new-test in isolation you can do:
|
||||
|
||||
(cd tests && make check TESTS=misc/newtest VERBOSE=yes)
|
||||
(cd tests && make check TESTS=misc/new-test VERBOSE=yes)
|
||||
|
||||
There are hundreds of tests in the tests/ directories. You can use
|
||||
tests/sample-test as a template, or one of the various Perl-based ones
|
||||
|
||||
@@ -47,6 +47,7 @@ syntax_check_exceptions = \
|
||||
.x-sc_po_check \
|
||||
.x-sc_program_name \
|
||||
.x-sc_prohibit_atoi_atof \
|
||||
.x-sc_prohibit_empty_lines_at_EOF \
|
||||
.x-sc_prohibit_fail_0 \
|
||||
.x-sc_prohibit_magic_number_exit \
|
||||
.x-sc_prohibit_stat_st_blocks \
|
||||
|
||||
73
NEWS
73
NEWS
@@ -1,5 +1,78 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 8.5 (2010-04-23) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
cp and mv once again support preserving extended attributes.
|
||||
[bug introduced in coreutils-8.4]
|
||||
|
||||
cp now preserves "capabilities" when also preserving file ownership.
|
||||
|
||||
ls --color once again honors the 'NORMAL' dircolors directive.
|
||||
[bug introduced in coreutils-6.11]
|
||||
|
||||
sort -M now handles abbreviated months that are aligned using blanks
|
||||
in the locale database. Also locales with 8 bit characters are
|
||||
handled correctly, including multi byte locales with the caveat
|
||||
that multi byte characters are matched case sensitively.
|
||||
|
||||
sort again handles obsolescent key formats (+POS -POS) correctly.
|
||||
Previously if -POS was specified, 1 field too many was used in the sort.
|
||||
[bug introduced in coreutils-7.2]
|
||||
|
||||
** New features
|
||||
|
||||
join now accepts the --header option, to treat the first line of each
|
||||
file as a header line to be joined and printed unconditionally.
|
||||
|
||||
timeout now accepts the --kill-after option which sends a kill
|
||||
signal to the monitored command if it's still running the specified
|
||||
duration after the initial signal was sent.
|
||||
|
||||
who: the "+/-" --mesg (-T) indicator of whether a user/tty is accepting
|
||||
messages could be incorrectly listed as "+", when in fact, the user was
|
||||
not accepting messages (mesg no). Before, who would examine only the
|
||||
permission bits, and not consider the group of the TTY device file.
|
||||
Thus, if a login tty's group would change somehow e.g., to "root",
|
||||
that would make it unwritable (via write(1)) by normal users, in spite
|
||||
of whatever the permission bits might imply. Now, when configured
|
||||
using the --with-tty-group[=NAME] option, who also compares the group
|
||||
of the TTY device with NAME (or "tty" if no group name is specified).
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
ls --color no longer emits the final 3-byte color-resetting escape
|
||||
sequence when it would be a no-op.
|
||||
|
||||
join -t '' no longer emits an error and instead operates on
|
||||
each line as a whole (even if they contain NUL characters).
|
||||
|
||||
|
||||
* Noteworthy changes in release 8.4 (2010-01-13) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
nproc --all is now guaranteed to be as large as the count
|
||||
of available processors, which may not have been the case
|
||||
on GNU/Linux systems with neither /proc nor /sys available.
|
||||
[bug introduced in coreutils-8.1]
|
||||
|
||||
** Build-related
|
||||
|
||||
Work around a build failure when using buggy <sys/capability.h>.
|
||||
Alternatively, configure with --disable-libcap.
|
||||
|
||||
Compilation would fail on systems using glibc-2.7..2.9 due to changes in
|
||||
gnulib's wchar.h that tickled a bug in at least those versions of glibc's
|
||||
own <wchar.h> header. Now, gnulib works around the bug in those older
|
||||
glibc <wchar.h> headers.
|
||||
|
||||
Building would fail with a link error (cp/copy.o) when XATTR headers
|
||||
were installed without the corresponding library. Now, configure
|
||||
detects that and disables xattr support, as one would expect.
|
||||
|
||||
|
||||
* Noteworthy changes in release 8.3 (2010-01-07) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
@@ -28,6 +28,12 @@ You can get a copy of the source repository like this:
|
||||
$ git clone git://git.sv.gnu.org/coreutils
|
||||
$ cd coreutils
|
||||
|
||||
As an optional step, if you already have a copy of the gnulib git
|
||||
repository on your hard drive, then you can use it as a reference to
|
||||
reduce download time and disk space requirements:
|
||||
|
||||
$ export GNULIB_SRCDIR=/path/to/gnulib
|
||||
|
||||
The next step is to get and check other files needed to build,
|
||||
which are extracted from other source packages:
|
||||
|
||||
|
||||
@@ -14,22 +14,26 @@ I.E. the tools checked for by the bootstrap script and include:
|
||||
- Texinfo <http://www.gnu.org/software/texinfo/>
|
||||
|
||||
Note please try to install/build official packages for your system.
|
||||
If these are not available then one can make them available only to
|
||||
the coreutils build using the following instructions. Even if the
|
||||
official packages for your system are too old, please install them
|
||||
as they may be required to build the newer versions. The examples
|
||||
below build into $HOME/coreutils/deps/, so first ensure that your
|
||||
$PATH is set correctly, which can be done for the current shell like:
|
||||
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.
|
||||
|
||||
export PATH=$HOME/coreutils/deps/bin:$PATH
|
||||
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:
|
||||
|
||||
prefix=$HOME/coreutils/deps
|
||||
export PATH=$prefix/bin:$PATH
|
||||
|
||||
* autoconf *
|
||||
|
||||
# Note Autoconf 2.62 or newer is needed to build automake-1.11
|
||||
# Note Autoconf 2.62 or newer is needed to build automake-1.11.1
|
||||
git clone --depth=1 git://git.sv.gnu.org/autoconf.git
|
||||
git checkout v2.62
|
||||
autoreconf -vi
|
||||
./configure --prefix=$HOME/coreutils/deps
|
||||
./configure --prefix=$prefix
|
||||
make install
|
||||
|
||||
* automake *
|
||||
@@ -37,12 +41,12 @@ $PATH is set correctly, which can be done for the current shell like:
|
||||
# Note help2man is required to build automake fully
|
||||
git clone git://git.sv.gnu.org/automake.git
|
||||
cd automake
|
||||
git checkout -b branch-1.11 --track origin/branch-1.11
|
||||
git checkout v1.11.1
|
||||
./bootstrap
|
||||
./configure --prefix=$HOME/coreutils/deps
|
||||
./configure --prefix=$prefix
|
||||
make install
|
||||
|
||||
coreutils uses XZ utils (successor to LZMA) to create
|
||||
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.
|
||||
|
||||
@@ -51,7 +55,7 @@ requires version 1.10a or newer, as well as the xz program itself.
|
||||
git clone git://ctrl.tukaani.org/xz.git
|
||||
cd xz
|
||||
./autogen.sh
|
||||
./configure --prefix=$HOME/coreutils/deps
|
||||
./configure --prefix=$prefix
|
||||
make install
|
||||
|
||||
Now one can build coreutils as described in README-hacking.
|
||||
Now you can build this package as described in README-hacking.
|
||||
|
||||
@@ -13,26 +13,34 @@ Here are most of the steps we (maintainers) follow when making a release.
|
||||
* Ensure that you're on "master" with no uncommitted diffs.
|
||||
This should produce no output: git checkout master; git diff
|
||||
|
||||
* Run bootstrap: ./bootstrap
|
||||
* Run bootstrap one last time. This downloads any new translations:
|
||||
|
||||
./bootstrap
|
||||
|
||||
FIXME: enable excluded programs like arch? to get their manual pages?
|
||||
|
||||
* Pre-release testing:
|
||||
Ensure that make check syntax-check succeeds.
|
||||
On at least one SELinux-enabled (enforcing) and one non-SELinux system,
|
||||
run all tests, both root-only and regular.
|
||||
Run *all* non-root tests, including expensive and very expensive ones i.e.,
|
||||
run this: make -j1 check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
|
||||
|
||||
Run the root-only tests:
|
||||
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
|
||||
Run the following on at least one SELinux-enabled (enforcing) and
|
||||
one non-SELinux system:
|
||||
|
||||
* Run "make distcheck"
|
||||
make distcheck
|
||||
make -j1 check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
|
||||
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
|
||||
|
||||
Note the -j1 above. If you use -jN, for larger N, some of the expensive
|
||||
tests are likely to interfere with concurrent performance-measuring or
|
||||
timing-sensitive tests, resulting in spurious failures.
|
||||
|
||||
If "make distcheck" doesn't run "make syntax-check" for you, then run
|
||||
it manually:
|
||||
|
||||
make syntax-check
|
||||
|
||||
* Set the date, version number, and release type [stable/alpha/beta] on
|
||||
line 3 of NEWS, commit that, and tag the release by running e.g.,
|
||||
|
||||
build-aux/do-release-commit-and-tag 8.1 beta
|
||||
build-aux/do-release-commit-and-tag 8.x stable
|
||||
|
||||
* Run the following to create release tarballs. Your choice selects the
|
||||
corresponding upload-to destination in the emitted gnupload command.
|
||||
@@ -56,16 +64,18 @@ Once all the builds and tests have passed,
|
||||
download all tarball/signature pairs and use gpg --verify to ensure
|
||||
that they're all valid.
|
||||
|
||||
* Push the new tag:
|
||||
* Push the NEWS-updating changes and the new tag:
|
||||
|
||||
v=$(cat .prev-version)
|
||||
git push origin tag v$v
|
||||
git push origin master tag v$v
|
||||
|
||||
* Send the gpg-signed announcement mail, e.g.,
|
||||
|
||||
To: info-gnu@gnu.org, coreutils-announce@gnu.org
|
||||
Cc: coordinator@translationproject.org, bug-coreutils@gnu.org
|
||||
Subject: coreutils-8.0 released [beta]
|
||||
To: info-gnu@gnu.org
|
||||
Cc: coordinator@translationproject.org, coreutils@gnu.org
|
||||
Cc: coreutils-announce@gnu.org
|
||||
Subject: coreutils-8.0 released [stable]
|
||||
Mail-Followup-To: bug-coreutils@gnu.org
|
||||
|
||||
* Approve the announcement here:
|
||||
http://lists.gnu.org/mailman/admindb/coreutils-announce
|
||||
@@ -78,9 +88,11 @@ Once all the builds and tests have passed,
|
||||
the Main -> "Select Features" menu item, or via this link:
|
||||
https://savannah.gnu.org/project/admin/editgroupfeatures.php?group=coreutils)
|
||||
|
||||
Subject: coreutils-0.0 released [beta]
|
||||
The announcement is here:
|
||||
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/54
|
||||
Subject: coreutils-8.0 released [stable]
|
||||
|
||||
+verbatim+
|
||||
...paste the announcement here...
|
||||
-verbatim-
|
||||
|
||||
Then go here to approve it:
|
||||
https://savannah.gnu.org/news/approve.php?group=coreutils
|
||||
|
||||
7
THANKS
7
THANKS
@@ -12,10 +12,12 @@ Aaron Hawley ashawley@uvm.edu
|
||||
Achim Blumensath blume@corona.oche.de
|
||||
Adam Jimerson vendion@charter.net
|
||||
Adam Klein aklein@debian.org
|
||||
Adam Sampson ats@offog.org
|
||||
Adrian Bunk bunk@stusta.de
|
||||
AIDA Shinra shinra@j10n.org
|
||||
Akim Demaille demaille@inf.enst.fr
|
||||
Alain Magloire alain@qnx.com
|
||||
Alan Curry pacman@kosh.dhis.org
|
||||
Alan Iwi iwi@atm.ox.ac.uk
|
||||
Albert Chin-A-Young china@thewrittenword.com
|
||||
Albert Hopkins ahopkins@dynacare.com
|
||||
@@ -177,6 +179,7 @@ Elbert Pol elbert.pol@gmail.com
|
||||
Eli Zaretskii eliz@is.elta.co.il
|
||||
Elias Pipping pipping@gentoo.org
|
||||
Emile LeBlanc leblanc@math.toronto.edu
|
||||
Emmanuel Lacour elacour@home-dn.net
|
||||
Erik Auerswald auerswal@unix-ag.uni-kl.de
|
||||
Eric Backus ericb@lsid.hp.com
|
||||
Eric Blake ebb9@byu.net
|
||||
@@ -253,6 +256,7 @@ Ilya N. Golubev gin@mo.msk.ru
|
||||
Ingo Saitz ingo@debian.org
|
||||
Ivan Labath labath3@st.fmph.uniba.sk
|
||||
Ivo Timmermans ivo@debian.org
|
||||
Jacky Fong jacky.fong@utoronto.ca
|
||||
James james@albion.glarp.com
|
||||
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
|
||||
James Lemley James.Lemley@acxiom.com
|
||||
@@ -334,6 +338,7 @@ Keith Owens kaos@audio.apana.org.au
|
||||
Keith Thompson kst@cts.com
|
||||
Ken Pizzini kenp@halcyon.com
|
||||
Kevin Mudrick kmudrick@healthmarketscience.com
|
||||
Kim Hansen kim@i9.dk
|
||||
Kirk Kelsey kirk.kelsey@0x4b.net
|
||||
Kristin E Thomas kristint@us.ibm.com
|
||||
Kjetil Torgrim Homme kjetilho@ifi.uio.no
|
||||
@@ -494,6 +499,7 @@ Philippe Schnoebelen Philippe.Schnoebelen@imag.fr
|
||||
Phillip Jones mouse@datastacks.com
|
||||
Piergiorgio Sartor sartor@sony.de
|
||||
Pieter Bowman bowman@math.utah.edu
|
||||
Piotr Gackiewicz gacek@intertele.pl
|
||||
Piotr Kwapulinski kwap@univ.gda.pl
|
||||
Prashant TR tr@eth.net
|
||||
Priit Jõerüüt jemm4jemm@yahoo.com
|
||||
@@ -630,6 +636,7 @@ Wolfram Kleff kleff@cs.uni-bonn.de
|
||||
Won-kyu Park wkpark@chem.skku.ac.kr
|
||||
Yanko Kaneti yaneti@declera.com
|
||||
Yann Dirson dirson@debian.org
|
||||
Yutaka Amanai yasai-itame1942@jade.plala.or.jp
|
||||
Zvi Har'El rl@math.technion.ac.il
|
||||
|
||||
;; Local Variables:
|
||||
|
||||
7
TODO
7
TODO
@@ -34,6 +34,9 @@ printf:
|
||||
platforms where the native *printf(3) is deficient.
|
||||
Suggestion from Eric Blake.
|
||||
|
||||
consider adding some implementation of the "col" utility
|
||||
Suggested by Karl Berry.
|
||||
|
||||
renice: POSIX utility, needs implementing.
|
||||
suggestion from Karl Berry (among others).
|
||||
Bob Proulx is working on this.
|
||||
@@ -59,10 +62,6 @@ Integrate use of sendfile, suggested here:
|
||||
http://mail.gnu.org/archive/html/bug-fileutils/2003-03/msg00030.html
|
||||
I don't plan to do that, since a few tests demonstrate no significant benefit.
|
||||
|
||||
Should printf '\0123' print "\n3"?
|
||||
per report from TAKAI Kousuke on Mar 27
|
||||
http://mail.gnu.org/archive/html/bug-coreutils/2003-03/index.html
|
||||
|
||||
printf: consider adapting builtins/printf.def from bash
|
||||
|
||||
tail: don't use xlseek; it *exits*.
|
||||
|
||||
75
bootstrap
75
bootstrap
@@ -1,4 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Print a version string.
|
||||
scriptversion=2010-02-24.17; # UTC
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
@@ -17,7 +19,15 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Written by Paul Eggert.
|
||||
# Originally written by Paul Eggert. The canonical version of this
|
||||
# script is maintained as build-aux/bootstrap in gnulib, however, to
|
||||
# be useful to your project, you should place a copy of it under
|
||||
# version control in the top-level directory of your project. The
|
||||
# intent is that all customization can be done with a bootstrap.conf
|
||||
# file also maintained in your version control; gnulib comes with a
|
||||
# template build-aux/bootstrap.conf to get you started.
|
||||
|
||||
# Please report bugs or propose patches to bug-gnulib@gnu.org.
|
||||
|
||||
nl='
|
||||
'
|
||||
@@ -43,7 +53,7 @@ Options:
|
||||
sources reside. Use this if you already
|
||||
have gnulib sources on your machine, and
|
||||
do not want to waste your bandwidth downloading
|
||||
them again.
|
||||
them again. Defaults to \$GNULIB_SRCDIR.
|
||||
--copy Copy files instead of creating symbolic links.
|
||||
--force Attempt to bootstrap even if the sources seem
|
||||
not to have been checked out.
|
||||
@@ -133,7 +143,8 @@ XGETTEXT_OPTIONS='\\\
|
||||
--flag=error:3:c-format --flag=error_at_line:5:c-format\\\
|
||||
'
|
||||
|
||||
# Package bug report address for gettext files
|
||||
# Package bug report address and copyright holder for gettext files
|
||||
COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
|
||||
MSGID_BUGS_ADDRESS=bug-$package@gnu.org
|
||||
|
||||
# Files we don't want to import.
|
||||
@@ -160,7 +171,6 @@ vc_ignore=auto
|
||||
# die otherwise.
|
||||
find_tool ()
|
||||
{
|
||||
# Find sha1sum, named gsha1sum on MacPorts.
|
||||
find_tool_envvar=$1
|
||||
shift
|
||||
find_tool_names=$@
|
||||
@@ -188,8 +198,8 @@ find_tool ()
|
||||
eval "export $find_tool_envvar"
|
||||
}
|
||||
|
||||
# Find sha1sum, named gsha1sum on MacPorts.
|
||||
find_tool SHA1SUM sha1sum gsha1sum
|
||||
# Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
|
||||
find_tool SHA1SUM sha1sum gsha1sum shasum
|
||||
|
||||
# Override the default configuration, if necessary.
|
||||
# Make sure that bootstrap.conf is sourced from the current directory
|
||||
@@ -390,7 +400,7 @@ fi
|
||||
|
||||
cleanup_gnulib() {
|
||||
status=$?
|
||||
rm -fr gnulib
|
||||
rm -fr "$gnulib_path"
|
||||
exit $status
|
||||
}
|
||||
|
||||
@@ -398,6 +408,8 @@ git_modules_config () {
|
||||
test -f .gitmodules && git config --file .gitmodules "$@"
|
||||
}
|
||||
|
||||
gnulib_path=`git_modules_config submodule.gnulib.path`
|
||||
|
||||
# Get gnulib files.
|
||||
|
||||
case ${GNULIB_SRCDIR--} in
|
||||
@@ -407,30 +419,43 @@ case ${GNULIB_SRCDIR--} in
|
||||
git submodule init || exit $?
|
||||
git submodule update || exit $?
|
||||
|
||||
elif [ ! -d gnulib ]; then
|
||||
elif [ ! -d "$gnulib_path" ]; then
|
||||
echo "$0: getting gnulib files..."
|
||||
|
||||
trap cleanup_gnulib 1 2 13 15
|
||||
|
||||
git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow=
|
||||
git clone $shallow git://git.sv.gnu.org/gnulib ||
|
||||
git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
|
||||
cleanup_gnulib
|
||||
|
||||
trap - 1 2 13 15
|
||||
fi
|
||||
GNULIB_SRCDIR=gnulib
|
||||
GNULIB_SRCDIR=$gnulib_path
|
||||
;;
|
||||
*)
|
||||
# Redirect the gnulib submodule to the directory on the command line
|
||||
# if possible.
|
||||
# Use GNULIB_SRCDIR as a reference.
|
||||
if test -d "$GNULIB_SRCDIR"/.git && \
|
||||
git_modules_config submodule.gnulib.url >/dev/null; then
|
||||
git submodule init
|
||||
GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
|
||||
git_modules_config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
|
||||
echo "$0: getting gnulib files..."
|
||||
git submodule update || exit $?
|
||||
GNULIB_SRCDIR=gnulib
|
||||
if git submodule --help|grep reference > /dev/null; then
|
||||
# Prefer the one-liner available in git 1.6.4 or newer.
|
||||
git submodule update --init --reference "$GNULIB_SRCDIR" \
|
||||
"$gnulib_path" || exit $?
|
||||
else
|
||||
# This fallback allows at least git 1.5.5.
|
||||
if test -f "$gnulib_path"/gnulib-tool; then
|
||||
# Since file already exists, assume submodule init already complete.
|
||||
git submodule update || exit $?
|
||||
else
|
||||
# Older git can't clone into an empty directory.
|
||||
rmdir "$gnulib_path" 2>/dev/null
|
||||
git clone --reference "$GNULIB_SRCDIR" \
|
||||
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
|
||||
&& git submodule init && git submodule update \
|
||||
|| exit $?
|
||||
fi
|
||||
fi
|
||||
GNULIB_SRCDIR=$gnulib_path
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -594,7 +619,6 @@ cp_mark_as_generated()
|
||||
(
|
||||
echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
|
||||
echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
|
||||
echo '#line 1' &&
|
||||
sed "s!$bt_regex/!!g" "$cp_src"
|
||||
) > $cp_dst-t &&
|
||||
if cmp -s "$cp_dst-t" "$cp_dst"; then
|
||||
@@ -637,7 +661,7 @@ slurp() {
|
||||
for excluded_file in $excluded_files; do
|
||||
test "$dir/$file" = "$excluded_file" && continue 2
|
||||
done
|
||||
if test $file = Makefile.am; then
|
||||
if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
|
||||
copied=$copied${sep}$gnulib_mk; sep=$nl
|
||||
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
|
||||
sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
|
||||
@@ -655,7 +679,7 @@ slurp() {
|
||||
rm -f $dir/$file
|
||||
sed '
|
||||
/^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
|
||||
AC_DEFUN([AM_INTL_SUBDIR], [
|
||||
AC_DEFUN([AM_INTL_SUBDIR], [])
|
||||
/^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
|
||||
AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
|
||||
$a\
|
||||
@@ -788,7 +812,8 @@ if test $with_gettext = yes; then
|
||||
rm -f po/Makevars
|
||||
sed '
|
||||
/^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
|
||||
/^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
|
||||
/^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
|
||||
/^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
|
||||
/^XGETTEXT_OPTIONS *=/{
|
||||
s/$/ \\/
|
||||
a\
|
||||
@@ -818,3 +843,11 @@ fi
|
||||
bootstrap_epilogue
|
||||
|
||||
echo "$0: done. Now you can run './configure'."
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
||||
@@ -97,7 +97,6 @@ gnulib_modules="
|
||||
fsusage
|
||||
fsync
|
||||
ftello
|
||||
ftruncate
|
||||
fts
|
||||
getdate
|
||||
getgroups
|
||||
@@ -322,6 +321,7 @@ makeinfo -
|
||||
perl 5.5
|
||||
rsync -
|
||||
tar -
|
||||
xz -
|
||||
"
|
||||
|
||||
# Automake requires that ChangeLog exist.
|
||||
|
||||
134
cfg.mk
134
cfg.mk
@@ -18,7 +18,8 @@
|
||||
manual_title = Core GNU utilities
|
||||
|
||||
# Tests not to run as part of "make distcheck".
|
||||
local-checks-to-skip =
|
||||
local-checks-to-skip = \
|
||||
sc_texinfo_acronym
|
||||
|
||||
# Tools used to bootstrap this package, used for "announcement".
|
||||
bootstrap-tools = autoconf,automake,gnulib,bison
|
||||
@@ -26,7 +27,13 @@ bootstrap-tools = autoconf,automake,gnulib,bison
|
||||
# Now that we have better tests, make this the default.
|
||||
export VERBOSE = yes
|
||||
|
||||
old_NEWS_hash = 67237f9a765e6e1af0cb89e428ed2663
|
||||
old_NEWS_hash = 9518f4930d702a9fa6ac6b9fd06cca94
|
||||
|
||||
# Add an exemption for sc_makefile_at_at_check.
|
||||
_makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
|
||||
|
||||
# Our help-version script is in a slightly different location.
|
||||
_hv_file ?= $(srcdir)/tests/misc/help-version
|
||||
|
||||
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
|
||||
dd = $(srcdir)/src/dd.c
|
||||
@@ -90,7 +97,8 @@ sc_root_tests:
|
||||
# stays in sync with corresponding files in the repository.
|
||||
sce = syntax_check_exceptions
|
||||
sc_x_sc_dist_check:
|
||||
@test "$$( ($(VC_LIST) | sed -n '/^.x-sc_/p'; \
|
||||
@test "$$( ($(VC_LIST) | sed -n '/\.x-sc_/p' \
|
||||
| sed 's|^$(_dot_escaped_srcdir)/||'; \
|
||||
sed -n '/^$(sce) =[ ]*\\$$/,/[^\]$$/p' \
|
||||
$(srcdir)/Makefile.am \
|
||||
| sed 's/^ *//;/^$(sce) =/d' \
|
||||
@@ -126,7 +134,10 @@ headers_with_interesting_macro_defs = \
|
||||
# Don't define macros that we already get from gnulib header files.
|
||||
sc_always_defined_macros: .re-defmac
|
||||
@if test -f $(srcdir)/src/system.h; then \
|
||||
trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
|
||||
trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0; \
|
||||
am__exit='(exit $rc); exit $rc'; \
|
||||
trap "rc=129; $$am__exit" 1; trap "rc=130; $$am__exit" 2; \
|
||||
trap "rc=131; $$am__exit" 3; trap "rc=143; $$am__exit" 15; \
|
||||
grep -f .re-defmac $$($(VC_LIST)) \
|
||||
&& { echo '$(ME): define the above via some gnulib .h file' \
|
||||
1>&2; exit 1; } || :; \
|
||||
@@ -145,7 +156,10 @@ sc_always_defined_macros: .re-defmac
|
||||
# the headers already included via system.h.
|
||||
sc_system_h_headers: .re-list
|
||||
@if test -f $(srcdir)/src/system.h; then \
|
||||
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
|
||||
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0; \
|
||||
am__exit='(exit $rc); exit $rc'; \
|
||||
trap "rc=129; $$am__exit" 1; trap "rc=130; $$am__exit" 2; \
|
||||
trap "rc=131; $$am__exit" 3; trap "rc=143; $$am__exit" 15; \
|
||||
grep -nE -f .re-list \
|
||||
$$($(VC_LIST_EXCEPT) | grep '^src/') \
|
||||
&& { echo '$(ME): the above are already included via system.h'\
|
||||
@@ -161,11 +175,26 @@ sc_sun_os_names:
|
||||
|
||||
ALL_RECURSIVE_TARGETS += sc_tight_scope
|
||||
sc_tight_scope:
|
||||
@$(MAKE) -C src $@
|
||||
@$(MAKE) -s -C src $@
|
||||
|
||||
ALL_RECURSIVE_TARGETS += sc_check-AUTHORS
|
||||
sc_check-AUTHORS:
|
||||
@$(MAKE) -C src $@
|
||||
@$(MAKE) -s -C src $@
|
||||
|
||||
# Option descriptions should not start with a capital letter
|
||||
# One could grep source directly as follows:
|
||||
# grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
|
||||
# but that would miss descriptions not on the same line as the -option.
|
||||
ALL_RECURSIVE_TARGETS += sc_option_desc_uppercase
|
||||
sc_option_desc_uppercase:
|
||||
@$(MAKE) -s -C src all_programs
|
||||
@$(MAKE) -s -C man $@
|
||||
|
||||
# Ensure all man/*.[1x] files are present
|
||||
ALL_RECURSIVE_TARGETS += sc_man_file_correlation
|
||||
sc_man_file_correlation:
|
||||
@$(MAKE) -s -C src all_programs
|
||||
@$(MAKE) -s -C man $@
|
||||
|
||||
# Perl-based tests used to exec perl from a #!/bin/sh script.
|
||||
# Now they all start with #!/usr/bin/perl and the portability
|
||||
@@ -180,15 +209,15 @@ sc_no_exec_perl_coreutils:
|
||||
|
||||
# Don't use "readlink" or "readlinkat" directly
|
||||
sc_prohibit_readlink:
|
||||
@re='\<readlink(at)? \(' \
|
||||
msg='do not use readlink(at); use via xreadlink or areadlink*' \
|
||||
$(_prohibit_regexp)
|
||||
@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:
|
||||
@re='\<l?stat '':|&l?stat\>' \
|
||||
msg='stat() and lstat() may be function-like macros' \
|
||||
$(_prohibit_regexp)
|
||||
@prohibit='\<l?stat '':|&l?stat\>' \
|
||||
halt='stat() and lstat() may be function-like macros' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Ensure that date's --help output stays in sync with the info
|
||||
# documentation for GNU strftime. The only exception is %N,
|
||||
@@ -199,7 +228,7 @@ sc_strftime_check:
|
||||
grep '^ %. ' $(srcdir)/src/date.c | sort \
|
||||
| $(extract_char) > $@-src; \
|
||||
{ echo N; \
|
||||
info libc date calendar format | grep '^ `%.'\' \
|
||||
info libc date calendar format 2>/dev/null|grep '^ `%.'\'\
|
||||
| $(extract_char); } | sort > $@-info; \
|
||||
diff -u $@-src $@-info || exit 1; \
|
||||
rm -f $@-src $@-info; \
|
||||
@@ -207,22 +236,22 @@ sc_strftime_check:
|
||||
|
||||
# Indent only with spaces.
|
||||
sc_prohibit_tab_based_indentation:
|
||||
@re='^ * ' \
|
||||
msg='TAB in indentation; use only spaces' \
|
||||
$(_prohibit_regexp)
|
||||
@prohibit='^ * ' \
|
||||
halt='TAB in indentation; use only spaces' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
|
||||
sc_prohibit_emacs__indent_tabs_mode__setting:
|
||||
@re='^( *[*#] *)?indent-tabs-mode:' \
|
||||
msg='use of emacs indent-tabs-mode: setting' \
|
||||
$(_prohibit_regexp)
|
||||
@prohibit='^( *[*#] *)?indent-tabs-mode:' \
|
||||
halt='use of emacs indent-tabs-mode: setting' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Ensure that each file that contains fail=1 also contains fail=0.
|
||||
# Otherwise, setting file=1 in the environment would make tests fail unexpectedly.
|
||||
sc_prohibit_fail_0:
|
||||
@re='\<fail=0\>' \
|
||||
msg='fail=0 initialization' \
|
||||
$(_prohibit_regexp)
|
||||
@prohibit='\<fail=0\>' \
|
||||
halt='fail=0 initialization' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Ensure that "stdio--.h" is used where appropriate.
|
||||
sc_require_stdio_safer:
|
||||
@@ -238,9 +267,62 @@ sc_require_stdio_safer:
|
||||
|
||||
# Prefer xnanosleep over other less-precise sleep methods
|
||||
sc_prohibit_sleep:
|
||||
@re='\<(nano|u)?sleep \(' \
|
||||
msg='prefer xnanosleep over other sleep interfaces' \
|
||||
$(_prohibit_regexp)
|
||||
@prohibit='\<(nano|u)?sleep \(' \
|
||||
halt='prefer xnanosleep over other sleep interfaces' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
###########################################################
|
||||
_p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
|
||||
_pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
|
||||
_pre_anchored = ^\($(_pre)\)
|
||||
_comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
|
||||
# help font-lock mode: '
|
||||
|
||||
# A sed expression that removes ANSI C and ISO C99 comments.
|
||||
# Derived from the one in GNU gettext's 'moopp' preprocessor.
|
||||
_sed_remove_comments = \
|
||||
/[/][/*]/{ \
|
||||
ta; \
|
||||
:a; \
|
||||
s,$(_pre_anchored)//.*,\1,; \
|
||||
te; \
|
||||
s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,; \
|
||||
ta; \
|
||||
/^$(_pre)[/][*]/{ \
|
||||
s,$(_pre_anchored)/[*].*,\1 ,; \
|
||||
tu; \
|
||||
:u; \
|
||||
n; \
|
||||
s,^\($(_comment_and_close),,; \
|
||||
tv; \
|
||||
s,^.*$$,,; \
|
||||
bu; \
|
||||
:v; \
|
||||
}; \
|
||||
:e; \
|
||||
}
|
||||
# Quote all single quotes.
|
||||
_sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
|
||||
# help font-lock mode: '
|
||||
|
||||
_space_before_paren_exempt =? \\n\\$$
|
||||
_space_before_paren_exempt = \
|
||||
(^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
|
||||
# Ensure that there is a space before each open parenthesis in C code.
|
||||
sc_space_before_open_paren:
|
||||
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
|
||||
fail=0; \
|
||||
for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do \
|
||||
sed '$(_sed_rm_comments_q)' $$c 2>/dev/null \
|
||||
| grep -i '[[:alnum:]](' \
|
||||
| grep -vE '$(_space_before_paren_exempt)' \
|
||||
| grep . && { fail=1; echo "*** $$c"; }; \
|
||||
done; \
|
||||
test $$fail = 1 && \
|
||||
{ echo '$(ME): the above files lack a space-before-open-paren' \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
|
||||
include $(srcdir)/dist-check.mk
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
* df: (coreutils)df invocation. Report file system disk usage.
|
||||
* dir: (coreutils)dir invocation. List directories briefly.
|
||||
* dircolors: (coreutils)dircolors invocation. Color setup for ls.
|
||||
* dirname: (coreutils)dirname invocation. Strip non-directory suffix.
|
||||
* dirname: (coreutils)dirname invocation. Strip last file name component.
|
||||
* du: (coreutils)du invocation. Report on disk usage.
|
||||
* echo: (coreutils)echo invocation. Print a line of text.
|
||||
* env: (coreutils)env invocation. Modify the environment.
|
||||
@@ -197,7 +197,7 @@ Free Documentation License''.
|
||||
* File name manipulation:: dirname basename pathchk mktemp
|
||||
* Working context:: pwd stty printenv tty
|
||||
* User information:: id logname whoami groups users who
|
||||
* System context:: date arch uname hostname hostid uptime
|
||||
* System context:: date arch nproc uname hostname hostid uptime
|
||||
* SELinux context:: chcon runcon
|
||||
* Modified command invocation:: chroot env nice nohup stdbuf su timeout
|
||||
* Process control:: kill
|
||||
@@ -377,7 +377,7 @@ Redirection
|
||||
File name manipulation
|
||||
|
||||
* basename invocation:: Strip directory and suffix from a file name
|
||||
* dirname invocation:: Strip non-directory suffix from a file name
|
||||
* dirname invocation:: Strip last file name component
|
||||
* pathchk invocation:: Check file name validity and portability
|
||||
* mktemp invocation:: Create temporary file or directory
|
||||
|
||||
@@ -4126,6 +4126,11 @@ is counted from the first nonblank character of the field.
|
||||
@vindex POSIXLY_CORRECT
|
||||
On older systems, @command{sort} supports an obsolete origin-zero
|
||||
syntax @samp{+@var{pos1} [-@var{pos2}]} for specifying sort keys.
|
||||
The obsolete sequence @samp{sort +@var{a}.@var{x} -@var{b}.@var{y}}
|
||||
is equivalent to @samp{sort -k @var{a+1}.@var{x+1},@var{b}} if @var{y}
|
||||
is @samp{0} or absent, otherwise it is equivalent to @samp{sort -k
|
||||
@var{a+1}.@var{x+1},@var{b+1}.@var{y}}.
|
||||
|
||||
This obsolete behavior can be enabled or disabled with the
|
||||
@env{_POSIX2_VERSION} environment variable (@pxref{Standards
|
||||
conformance}); it can also be enabled when @env{POSIXLY_CORRECT} is
|
||||
@@ -5318,7 +5323,13 @@ of selected bytes.
|
||||
Select for printing only the fields listed in @var{field-list}.
|
||||
Fields are separated by a TAB character by default. Also print any
|
||||
line that contains no delimiter character, unless the
|
||||
@option{--only-delimited} (@option{-s}) option is specified
|
||||
@option{--only-delimited} (@option{-s}) option is specified.
|
||||
Note @command{cut} does not support specifying runs of whitespace as a
|
||||
delimiter, so to achieve that common functionality one can pre-process
|
||||
with @command{tr} like:
|
||||
@example
|
||||
tr -s '[:blank:]' '\t' | cut -f@dots{}
|
||||
@end example
|
||||
|
||||
@item -d @var{input_delim_byte}
|
||||
@itemx --delimiter=@var{input_delim_byte}
|
||||
@@ -5462,6 +5473,8 @@ locales and options if the output of @command{sort} is fed to
|
||||
sort a file on its default join field, but if you select a non-default
|
||||
locale, join field, separator, or comparison options, then you should
|
||||
do so consistently between @command{join} and @command{sort}.
|
||||
If @samp{join -t ''} is specified then the whole line is considered which
|
||||
matches the default operation of sort.
|
||||
|
||||
If the input has no unpairable lines, a @acronym{GNU} extension is
|
||||
available; the sort order can be any order that considers two fields
|
||||
@@ -5515,6 +5528,15 @@ Do not check that both input files are in sorted order. This is the default.
|
||||
Replace those output fields that are missing in the input with
|
||||
@var{string}.
|
||||
|
||||
@item --header
|
||||
@opindex --header
|
||||
Treat the first line of each input file as a header line. The header lines will
|
||||
be joined and printed as the first output line. If @option{-o} is used to
|
||||
specify output format, the header line will be printed according to the
|
||||
specified format. The header lines will not be checked for ordering even if
|
||||
@option{--check-order} is specified. Also if the header lines from each file
|
||||
do not match, the heading fields from the first file will be used.
|
||||
|
||||
@item -i
|
||||
@itemx --ignore-case
|
||||
@opindex -i
|
||||
@@ -5563,7 +5585,10 @@ option---are subject to the specified @var{field-list}.
|
||||
Use character @var{char} as the input and output field separator.
|
||||
Treat as significant each occurrence of @var{char} in the input file.
|
||||
Use @samp{sort -t @var{char}}, without the @option{-b} option of
|
||||
@samp{sort}, to produce this ordering.
|
||||
@samp{sort}, to produce this ordering. If @samp{join -t ''} is specified,
|
||||
the whole line is considered, matching the default operation of sort.
|
||||
If @samp{-t '\0'} is specified then the @acronym{ASCII} @sc{nul}
|
||||
character is used to delimit the fields.
|
||||
|
||||
@item -v @var{file-number}
|
||||
Print a line for each unpairable line in file @var{file-number}
|
||||
@@ -7487,19 +7512,18 @@ $ mkdir b c; (cd b; : > a; ln -s a b); cp -aL b c; ls -i1 c/b
|
||||
@end smallexample
|
||||
|
||||
@itemx context
|
||||
Preserve SELinux security context of the file. @command{cp} will fail
|
||||
if the preserving of SELinux security context is not succesful.
|
||||
Preserve SELinux security context of the file, or fail with full diagnostics.
|
||||
@itemx xattr
|
||||
Preserve extended attributes if @command{cp} is built with xattr support,
|
||||
and xattrs are supported and enabled on your file system.
|
||||
If SELinux context and/or ACLs are implemented using xattrs,
|
||||
Preserve extended attributes of the file, or fail with full diagnostics.
|
||||
If @command{cp} is built without xattr support, ignore this option.
|
||||
If SELinux context, ACLs or Capabilities are implemented using xattrs,
|
||||
they are preserved by this option as well.
|
||||
@itemx all
|
||||
Preserve all file attributes.
|
||||
Equivalent to specifying all of the above, but with the difference
|
||||
that failure to preserve SELinux security context or extended attributes
|
||||
does not change @command{cp}'s exit status.
|
||||
@command{cp} does diagnose such failures.
|
||||
does not change @command{cp}'s exit status. In contrast to @option{-a},
|
||||
all but @samp{Operation not supported} warnings are output.
|
||||
@end table
|
||||
|
||||
Using @option{--preserve} with no @var{attribute_list} is equivalent
|
||||
@@ -8255,7 +8279,9 @@ the destination partition and the second and third would be left on the
|
||||
original partition.
|
||||
|
||||
@cindex extended attributes, xattr
|
||||
@command{mv} always tries to copy extended attributes (xattr).
|
||||
@command{mv} always tries to copy extended attributes (xattr), which may
|
||||
include SELinux context, ACLs or Capabilities.
|
||||
Upon failure all but @samp{Operation not supported} warnings are output.
|
||||
|
||||
@cindex prompting, and @command{mv}
|
||||
If a destination file exists but is normally unwritable, standard input
|
||||
@@ -8698,7 +8724,7 @@ The intended use of this is to shred a removed temporary file.
|
||||
For example:
|
||||
|
||||
@example
|
||||
i=`tempfile -m 0600`
|
||||
i=`mktemp`
|
||||
exec 3<>"$i"
|
||||
rm -- "$i"
|
||||
echo "Hello, world" >&3
|
||||
@@ -11888,7 +11914,7 @@ This section describes commands that manipulate file names.
|
||||
|
||||
@menu
|
||||
* basename invocation:: Strip directory and suffix from a file name.
|
||||
* dirname invocation:: Strip non-directory suffix from a file name.
|
||||
* dirname invocation:: Strip last file name component.
|
||||
* pathchk invocation:: Check file name validity and portability.
|
||||
* mktemp invocation:: Create temporary file or directory.
|
||||
@end menu
|
||||
@@ -11949,7 +11975,7 @@ basename include/stdio.h .h
|
||||
|
||||
|
||||
@node dirname invocation
|
||||
@section @command{dirname}: Strip non-directory suffix from a file name
|
||||
@section @command{dirname}: Strip last file name component
|
||||
|
||||
@pindex dirname
|
||||
@cindex directory components, printing
|
||||
@@ -11957,7 +11983,7 @@ basename include/stdio.h .h
|
||||
@cindex non-directory suffix, stripping
|
||||
|
||||
@command{dirname} prints all but the final slash-delimited component of
|
||||
a string (presumably a file name). Synopsis:
|
||||
a string (presumably a file name, but also works on directories). Synopsis:
|
||||
|
||||
@example
|
||||
dirname @var{name}
|
||||
@@ -15201,31 +15227,25 @@ might find this idea strange at first.
|
||||
still running after the specified time interval. Synopsis:
|
||||
|
||||
@example
|
||||
timeout [@var{option}] @var{number}[smhd] @var{command} [@var{arg}]@dots{}
|
||||
timeout [@var{option}] @var{duration} @var{command} [@var{arg}]@dots{}
|
||||
@end example
|
||||
|
||||
@cindex time units
|
||||
@var{number} is an integer followed by an optional unit; the default
|
||||
is seconds. The units are:
|
||||
|
||||
@table @samp
|
||||
@item s
|
||||
seconds
|
||||
@item m
|
||||
minutes
|
||||
@item h
|
||||
hours
|
||||
@item d
|
||||
days
|
||||
@end table
|
||||
|
||||
@var{command} must not be a special built-in utility (@pxref{Special
|
||||
built-in utilities}).
|
||||
|
||||
The program accepts the following option. Also see @ref{Common options}.
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
Options must precede operands.
|
||||
|
||||
@table @samp
|
||||
@item -k @var{duration}
|
||||
@itemx --kill-after=@var{duration}
|
||||
@opindex -k
|
||||
@opindex --kill-after
|
||||
Ensure the monitored @var{command} is killed by also sending a @samp{KILL}
|
||||
signal, after the specified @var{duration}. Without this option, if the
|
||||
selected signal proves not to be fatal, @command{timeout} does not kill
|
||||
the @var{command}.
|
||||
|
||||
@item -s @var{signal}
|
||||
@itemx --signal=@var{signal}
|
||||
@opindex -s
|
||||
@@ -15233,9 +15253,18 @@ Options must precede operands.
|
||||
Send this @var{signal} to @var{command} on timeout, rather than the
|
||||
default @samp{TERM} signal. @var{signal} may be a name like @samp{HUP}
|
||||
or a number. Also see @xref{Signal specifications}.
|
||||
|
||||
@end table
|
||||
|
||||
@cindex time units
|
||||
@var{duration} is an integer followed by an optional unit:
|
||||
@display
|
||||
@samp{s} for seconds (the default)
|
||||
@samp{m} for minutes
|
||||
@samp{h} for hours
|
||||
@samp{d} for days
|
||||
@end display
|
||||
A duration of 0 disables the associated timeout.
|
||||
|
||||
@cindex exit status of @command{timeout}
|
||||
Exit status:
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#endif
|
||||
|
||||
/* Replace non printable chars.
|
||||
Note \t and \n etc. are non printable.
|
||||
Return 1 if replacement made, 0 otherwise. */
|
||||
|
||||
static bool
|
||||
@@ -119,17 +120,17 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
|
||||
ALIGNMENT specifies whether to left- or right-justify or to center.
|
||||
If SRC requires more than *WIDTH columns, truncate it to fit.
|
||||
When centering, the number of trailing spaces may be one less than the
|
||||
number of leading spaces. The FLAGS parameter is unused at present.
|
||||
number of leading spaces.
|
||||
Return the length in bytes required for the final result, not counting
|
||||
the trailing NUL. A return value of DEST_SIZE or larger means there
|
||||
wasn't enough space. DEST will be NUL terminated in any case.
|
||||
Return (size_t) -1 upon error (invalid multi-byte sequence in SRC,
|
||||
or malloc failure).
|
||||
or malloc failure), unless MBA_UNIBYTE_FALLBACK is specified.
|
||||
Update *WIDTH to indicate how many columns were used before padding. */
|
||||
|
||||
size_t
|
||||
mbsalign (const char *src, char *dest, size_t dest_size,
|
||||
size_t *width, mbs_align_t align, int flags _UNUSED_PARAMETER_)
|
||||
size_t *width, mbs_align_t align, int flags)
|
||||
{
|
||||
size_t ret = -1;
|
||||
size_t src_size = strlen (src) + 1;
|
||||
@@ -149,12 +150,22 @@ mbsalign (const char *src, char *dest, size_t dest_size,
|
||||
{
|
||||
size_t src_chars = mbstowcs (NULL, src, 0);
|
||||
if (src_chars == (size_t) -1)
|
||||
goto mbsalign_cleanup;
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
src_chars += 1; /* make space for NUL */
|
||||
str_wc = malloc (src_chars * sizeof (wchar_t));
|
||||
if (str_wc == NULL)
|
||||
goto mbsalign_cleanup;
|
||||
if (mbstowcs (str_wc, src, src_chars) > 0)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
if (mbstowcs (str_wc, src, src_chars) != 0)
|
||||
{
|
||||
str_wc[src_chars - 1] = L'\0';
|
||||
wc_enabled = true;
|
||||
@@ -165,27 +176,36 @@ mbsalign (const char *src, char *dest, size_t dest_size,
|
||||
|
||||
/* If we transformed or need to truncate the source string
|
||||
then create a modified copy of it. */
|
||||
if (conversion || (n_cols > *width))
|
||||
if (wc_enabled && (conversion || (n_cols > *width)))
|
||||
{
|
||||
newstr = malloc (src_size);
|
||||
if (newstr == NULL)
|
||||
goto mbsalign_cleanup;
|
||||
str_to_print = newstr;
|
||||
if (wc_enabled)
|
||||
if (conversion)
|
||||
{
|
||||
/* May have increased the size by converting
|
||||
\t to \uFFFD for example. */
|
||||
src_size = wcstombs (NULL, str_wc, 0) + 1;
|
||||
}
|
||||
newstr = malloc (src_size);
|
||||
if (newstr == NULL)
|
||||
{
|
||||
n_cols = wc_truncate (str_wc, *width);
|
||||
n_used_bytes = wcstombs (newstr, str_wc, src_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
n_cols = *width;
|
||||
n_used_bytes = n_cols;
|
||||
memcpy (newstr, src, n_cols);
|
||||
newstr[n_cols] = '\0';
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
else
|
||||
goto mbsalign_cleanup;
|
||||
}
|
||||
str_to_print = newstr;
|
||||
n_cols = wc_truncate (str_wc, *width);
|
||||
n_used_bytes = wcstombs (newstr, str_wc, src_size);
|
||||
}
|
||||
|
||||
if (*width > n_cols)
|
||||
mbsalign_unibyte:
|
||||
|
||||
if (n_cols > *width) /* Unibyte truncation required. */
|
||||
{
|
||||
n_cols = *width;
|
||||
n_used_bytes = n_cols;
|
||||
}
|
||||
|
||||
if (*width > n_cols) /* Padding required. */
|
||||
n_spaces = *width - n_cols;
|
||||
|
||||
/* indicate to caller how many cells needed (not including padding). */
|
||||
@@ -197,16 +217,11 @@ mbsalign (const char *src, char *dest, size_t dest_size,
|
||||
/* Write as much NUL terminated output to DEST as possible. */
|
||||
if (dest_size != 0)
|
||||
{
|
||||
size_t start_spaces, end_spaces;
|
||||
char *dest_end = dest + dest_size - 1;
|
||||
size_t start_spaces = n_spaces / 2 + n_spaces % 2;
|
||||
size_t end_spaces = n_spaces / 2;
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case MBS_ALIGN_CENTER:
|
||||
start_spaces = n_spaces / 2 + n_spaces % 2;
|
||||
end_spaces = n_spaces / 2;
|
||||
break;
|
||||
case MBS_ALIGN_LEFT:
|
||||
start_spaces = 0;
|
||||
end_spaces = n_spaces;
|
||||
@@ -215,10 +230,16 @@ mbsalign (const char *src, char *dest, size_t dest_size,
|
||||
start_spaces = n_spaces;
|
||||
end_spaces = 0;
|
||||
break;
|
||||
case MBS_ALIGN_CENTER:
|
||||
default:
|
||||
start_spaces = n_spaces / 2 + n_spaces % 2;
|
||||
end_spaces = n_spaces / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
dest = mbs_align_pad (dest, dest_end, start_spaces);
|
||||
dest = mempcpy(dest, str_to_print, MIN (n_used_bytes, dest_end - dest));
|
||||
size_t space_left = dest_end - dest;
|
||||
dest = mempcpy (dest, str_to_print, MIN (n_used_bytes, space_left));
|
||||
mbs_align_pad (dest, dest_end, end_spaces);
|
||||
}
|
||||
|
||||
@@ -229,3 +250,39 @@ mbsalign_cleanup:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* A wrapper around mbsalign() to dynamically allocate the
|
||||
minimum amount of memory to store the result.
|
||||
Return NULL on failure. */
|
||||
|
||||
char *
|
||||
ambsalign (const char *src, size_t *width, mbs_align_t align, int flags)
|
||||
{
|
||||
size_t orig_width = *width;
|
||||
size_t size = *width; /* Start with enough for unibyte mode. */
|
||||
size_t req = size;
|
||||
char *buf = NULL;
|
||||
|
||||
while (req >= size)
|
||||
{
|
||||
size = req + 1; /* Space for NUL. */
|
||||
char *nbuf = realloc (buf, size);
|
||||
if (nbuf == NULL)
|
||||
{
|
||||
free (buf);
|
||||
buf = NULL;
|
||||
break;
|
||||
}
|
||||
buf = nbuf;
|
||||
*width = orig_width;
|
||||
req = mbsalign (src, buf, size, width, align, flags);
|
||||
if (req == (size_t) -1)
|
||||
{
|
||||
free (buf);
|
||||
buf = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,29 @@
|
||||
|
||||
typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
|
||||
|
||||
enum {
|
||||
/* Use unibyte mode for invalid multibyte strings or
|
||||
or when heap memory is exhausted. */
|
||||
MBA_UNIBYTE_FALLBACK = 0x0001,
|
||||
|
||||
#if 0 /* Other possible options. */
|
||||
/* Skip invalid multibyte chars rather than failing */
|
||||
MBA_IGNORE_INVALID = 0x0002,
|
||||
|
||||
/* Align multibyte strings using "figure space" (\u2007) */
|
||||
MBA_USE_FIGURE_SPACE = 0x0004,
|
||||
|
||||
/* Don't add any padding */
|
||||
MBA_TRUNCATE_ONLY = 0x0008,
|
||||
|
||||
/* Don't truncate */
|
||||
MBA_PAD_ONLY = 0x0010,
|
||||
#endif
|
||||
};
|
||||
|
||||
size_t
|
||||
mbsalign (const char *src, char *dest, size_t dest_size,
|
||||
size_t *width, mbs_align_t align, int flags);
|
||||
|
||||
char *
|
||||
ambsalign (const char *src, size_t *width, mbs_align_t align, int flags);
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
diff --git c/lib/regcomp.c i/lib/regcomp.c
|
||||
index 6472ff6..665b2ab 100644
|
||||
--- c/lib/regcomp.c
|
||||
+++ i/lib/regcomp.c
|
||||
@@ -18,6 +18,8 @@
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
+#include "intprops.h"
|
||||
+#include "verify.h"
|
||||
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
|
||||
size_t length, reg_syntax_t syntax);
|
||||
static void re_compile_fastmap_iter (regex_t *bufp,
|
||||
@@ -541,7 +543,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
|
||||
diff --git a/lib/regcomp.c b/lib/regcomp.c
|
||||
index d5968bd..4926676 100644
|
||||
--- a/lib/regcomp.c
|
||||
+++ b/lib/regcomp.c
|
||||
@@ -541,7 +541,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
|
||||
size_t errbuf_size;
|
||||
#else /* size_t might promote */
|
||||
size_t
|
||||
@@ -20,7 +11,7 @@ index 6472ff6..665b2ab 100644
|
||||
char *_Restrict_ errbuf, size_t errbuf_size)
|
||||
#endif
|
||||
{
|
||||
@@ -1375,7 +1377,7 @@ calc_first (void *extra, bin_tree_t *node)
|
||||
@@ -1383,7 +1383,7 @@ calc_first (void *extra, bin_tree_t *node)
|
||||
|
||||
/* Pass 2: compute NEXT on the tree. Preorder visit. */
|
||||
static reg_errcode_t
|
||||
@@ -29,17 +20,7 @@ index 6472ff6..665b2ab 100644
|
||||
{
|
||||
switch (node->token.type)
|
||||
{
|
||||
@@ -2571,7 +2573,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
|
||||
/* This loop is actually executed only when end != REG_MISSING,
|
||||
to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
|
||||
already created the start+1-th copy. */
|
||||
- if ((Idx) -1 < 0 || end != REG_MISSING)
|
||||
+ verify (! TYPE_SIGNED (Idx));
|
||||
+ if (end != REG_MISSING)
|
||||
for (i = start + 2; i <= end; ++i)
|
||||
{
|
||||
elem = duplicate_tree (elem, dfa);
|
||||
@@ -2731,7 +2734,8 @@ static reg_errcode_t
|
||||
@@ -2744,7 +2744,8 @@ static reg_errcode_t
|
||||
internal_function
|
||||
build_collating_symbol (bitset_t sbcset,
|
||||
# ifdef RE_ENABLE_I18N
|
||||
@@ -49,7 +30,7 @@ index 6472ff6..665b2ab 100644
|
||||
# endif
|
||||
const unsigned char *name)
|
||||
{
|
||||
@@ -3309,7 +3313,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
|
||||
@@ -3323,7 +3324,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
|
||||
|
||||
static reg_errcode_t
|
||||
parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
|
||||
@@ -59,7 +40,7 @@ index 6472ff6..665b2ab 100644
|
||||
reg_syntax_t syntax, bool accept_hyphen)
|
||||
{
|
||||
#ifdef RE_ENABLE_I18N
|
||||
@@ -3396,8 +3401,9 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
|
||||
@@ -3410,8 +3412,9 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
|
||||
|
||||
static reg_errcode_t
|
||||
#ifdef RE_ENABLE_I18N
|
||||
@@ -71,7 +52,7 @@ index 6472ff6..665b2ab 100644
|
||||
#else /* not RE_ENABLE_I18N */
|
||||
build_equiv_class (bitset_t sbcset, const unsigned char *name)
|
||||
#endif /* not RE_ENABLE_I18N */
|
||||
@@ -3798,7 +3804,7 @@ free_token (re_token_t *node)
|
||||
@@ -3816,7 +3819,7 @@ free_token (re_token_t *node)
|
||||
and its children. */
|
||||
|
||||
static reg_errcode_t
|
||||
|
||||
11
gl/modules/mbsalign-tests
Normal file
11
gl/modules/mbsalign-tests
Normal file
@@ -0,0 +1,11 @@
|
||||
Files:
|
||||
tests/test-mbsalign.c
|
||||
tests/macros.h
|
||||
|
||||
Depends-on:
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
TESTS += test-mbsalign
|
||||
check_PROGRAMS += test-mbsalign
|
||||
100
gl/tests/test-mbsalign.c
Normal file
100
gl/tests/test-mbsalign.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/* Test that mbsalign works as advertised.
|
||||
Copyright (C) 2010 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Pádraig Brady. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "mbsalign.h"
|
||||
#include "macros.h"
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char dest[4 * 16 + 1];
|
||||
size_t width, n;
|
||||
|
||||
/* Test unibyte truncation. */
|
||||
width = 4;
|
||||
n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 4);
|
||||
|
||||
/* Test center alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
|
||||
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
|
||||
|
||||
if (setlocale (LC_ALL, "en_US.UTF8"))
|
||||
{
|
||||
/* Check invalid input is flagged. */
|
||||
width = 4;
|
||||
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == (size_t) -1);
|
||||
|
||||
/* Check invalid input is treated as unibyte */
|
||||
width = 4;
|
||||
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width,
|
||||
MBS_ALIGN_LEFT, MBA_UNIBYTE_FALLBACK);
|
||||
ASSERT (n == 4);
|
||||
|
||||
/* Test multibyte center alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
|
||||
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
|
||||
|
||||
/* Test multibyte left alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (*(dest + n - 1) == ' ' && *(dest + n - 2) == ' ');
|
||||
|
||||
/* Test multibyte right alignment. */
|
||||
width = 4;
|
||||
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_RIGHT, 0);
|
||||
ASSERT (*(dest) == ' ' && *(dest + 1) == ' ');
|
||||
|
||||
/* multibyte multicell truncation. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("日月火水", dest, sizeof dest, &width,
|
||||
MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 6); /* 2 characters */
|
||||
|
||||
/* multibyte unicell truncation. */
|
||||
width = 3; /* cells */
|
||||
n = mbsalign ("¹²³⁴", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 6); /* 3 characters */
|
||||
|
||||
/* Check independence from dest buffer. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("¹²³⁴", dest, 0, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 9); /* 4 characters */
|
||||
|
||||
/* Check that width is updated with cells required before padding. */
|
||||
width = 4; /* cells */
|
||||
n = mbsalign ("¹²³", dest, 0, &width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (width == 3);
|
||||
|
||||
/* Test case where output is larger than input
|
||||
(as tab converted to multi byte replacement char). */
|
||||
width = 4;
|
||||
n = mbsalign ("t\tés" /* 6 including NUL */ , dest, sizeof dest,
|
||||
&width, MBS_ALIGN_LEFT, 0);
|
||||
ASSERT (n == 7);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
2
gnulib
2
gnulib
Submodule gnulib updated: cb361c968d...6d126a8f1b
@@ -35,8 +35,8 @@ AC_DEFUN([coreutils_MACROS],
|
||||
|
||||
AC_REQUIRE([AC_FUNC_FSEEKO])
|
||||
|
||||
# By default, argmatch should fail calling usage (1).
|
||||
AC_DEFINE([ARGMATCH_DIE], [usage (1)],
|
||||
# By default, argmatch should fail calling usage (EXIT_FAILURE).
|
||||
AC_DEFINE([ARGMATCH_DIE], [usage (EXIT_FAILURE)],
|
||||
[Define to the function xargmatch calls on failures.])
|
||||
AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
|
||||
[Define to the declaration of the xargmatch failure function.])
|
||||
@@ -64,6 +64,7 @@ AC_DEFUN([coreutils_MACROS],
|
||||
LIBS=$coreutils_saved_libs
|
||||
|
||||
# Used by sort.c.
|
||||
AC_CHECK_FUNCS_ONCE([posix_fadvise])
|
||||
AC_CHECK_FUNCS_ONCE([nl_langinfo])
|
||||
|
||||
# Used by tail.c.
|
||||
@@ -144,6 +145,25 @@ AC_DEFUN([coreutils_MACROS],
|
||||
])
|
||||
|
||||
AC_REQUIRE([AM_LANGINFO_CODESET])
|
||||
|
||||
# Accept configure options: --with-tty-group[=GROUP], --without-tty-group
|
||||
# You can determine the group of a TTY via 'stat --format %G /dev/tty'
|
||||
# Omitting this option is equivalent to using --without-tty-group.
|
||||
AC_ARG_WITH([tty-group],
|
||||
AS_HELP_STRING([--with-tty-group[[[=NAME]]]],
|
||||
[group used by system for TTYs, "tty" when not specified]
|
||||
[ (default: do not rely on any group used for TTYs)]),
|
||||
[tty_group_name=$withval],
|
||||
[tty_group_name=no])
|
||||
|
||||
if test "x$tty_group_name" != xno; then
|
||||
if test "x$tty_group_name" = xyes; then
|
||||
tty_group_name=tty
|
||||
fi
|
||||
AC_MSG_NOTICE([TTY group used by system set to "$tty_group_name"])
|
||||
AC_DEFINE_UNQUOTED([TTY_GROUP_NAME], ["$tty_group_name"],
|
||||
[group used by system for TTYs])
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_CHECK_ALL_HEADERS],
|
||||
|
||||
33
m4/xattr.m4
33
m4/xattr.m4
@@ -1,4 +1,5 @@
|
||||
# xattr.m4 - check for Extended Attributes (Linux)
|
||||
# serial 3
|
||||
|
||||
# Copyright (C) 2003, 2008-2010 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
@@ -15,25 +16,29 @@ AC_DEFUN([gl_FUNC_XATTR],
|
||||
[do not support extended attributes]),
|
||||
[use_xattr=$enableval], [use_xattr=yes])
|
||||
|
||||
LIB_XATTR=
|
||||
AC_SUBST([LIB_XATTR])
|
||||
|
||||
if test "$use_xattr" = "yes"; then
|
||||
AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h])
|
||||
use_xattr=no
|
||||
if test $ac_cv_header_attr_libattr_h = yes \
|
||||
&& test $ac_cv_header_attr_error_context_h = yes; then
|
||||
use_xattr=1
|
||||
else
|
||||
use_xattr=0
|
||||
&& test $ac_cv_header_attr_error_context_h = yes; then
|
||||
xattr_saved_LIBS=$LIBS
|
||||
AC_SEARCH_LIBS([attr_copy_file], [attr],
|
||||
[test "$ac_cv_search_attr_copy_file" = "none required" ||
|
||||
LIB_XATTR=$ac_cv_search_attr_copy_file])
|
||||
AC_CHECK_FUNCS([attr_copy_file])
|
||||
LIBS=$xattr_saved_LIBS
|
||||
if test $ac_cv_func_attr_copy_file = yes; then
|
||||
use_xattr=yes
|
||||
fi
|
||||
fi
|
||||
if test $use_xattr = no; then
|
||||
AC_MSG_WARN([libattr development library was not found or not usable.])
|
||||
AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([USE_XATTR], [$use_xattr],
|
||||
[Define if you want extended attribute support.])
|
||||
LIB_XATTR=
|
||||
xattr_saved_LIBS=$LIBS
|
||||
AC_SEARCH_LIBS([attr_copy_file], [attr],
|
||||
[test "$ac_cv_search_attr_copy_file" = "none required" ||
|
||||
LIB_XATTR=$ac_cv_search_attr_copy_file])
|
||||
AC_CHECK_FUNCS([attr_copy_file])
|
||||
LIBS=$xattr_saved_LIBS
|
||||
AC_SUBST([LIB_XATTR])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([USE_XATTR], [`test $use_xattr != yes; echo $?`],
|
||||
[Define if you want extended attribute support.])
|
||||
])
|
||||
|
||||
@@ -173,7 +173,15 @@ mapped_name = `echo $*|sed 's/^install$$/ginstall/; s/^test$$/[/'`
|
||||
;; \
|
||||
esac
|
||||
|
||||
distcheck-hook: check-x-vs-1 check-programs-vs-x
|
||||
# Option descriptions should not start with a capital letter
|
||||
.PHONY: sc_option_desc_uppercase
|
||||
sc_option_desc_uppercase: $(dist_man1_MANS) $(NO_INSTALL_PROGS_DEFAULT:%=%.1)
|
||||
@grep '^\\fB\\-' -A1 *.1 | LC_ALL=C grep '\.1.[A-Z][a-z]' && \
|
||||
{ echo 1>&2 '$(ME): found initial capitals in --help'; \
|
||||
exit 1; } || :;
|
||||
|
||||
.PHONY: sc_man_file_correlation
|
||||
sc_man_file_correlation: check-x-vs-1 check-programs-vs-x
|
||||
|
||||
# Sort in traditional ASCII order, regardless of the current locale;
|
||||
# otherwise we may get into trouble with distinct strings that the
|
||||
@@ -186,7 +194,7 @@ ASSORT = LC_ALL=C sort
|
||||
# add them here manually.
|
||||
.PHONY: check-x-vs-1
|
||||
check-x-vs-1:
|
||||
$(AM_V_GEN)PATH=../src$(PATH_SEPARATOR)$$PATH; export PATH; \
|
||||
@PATH=../src$(PATH_SEPARATOR)$$PATH; export PATH; \
|
||||
t=$@-t; \
|
||||
(cd $(srcdir) && ls -1 *.x) | sed 's/\.x$$//' | $(ASSORT) > $$t;\
|
||||
(echo $(dist_man1_MANS) $(NO_INSTALL_PROGS_DEFAULT) \
|
||||
@@ -200,7 +208,7 @@ all_programs = \
|
||||
|
||||
.PHONY: check-programs-vs-x
|
||||
check-programs-vs-x:
|
||||
$(AM_V_GEN)status=0; \
|
||||
@status=0; \
|
||||
for p in dummy `$(all_programs)`; do \
|
||||
test $$p = dummy && continue; \
|
||||
test $$p = ginstall && p=install || : ; \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[NAME]
|
||||
dirname \- strip non-directory suffix from file name
|
||||
dirname \- strip last component from file name
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
tac \- concatenate and print files in reverse
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
\fBrev\fP(1).
|
||||
|
||||
@@ -170,6 +170,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/lib
|
||||
noinst_LIBRARIES = libver.a
|
||||
nodist_libver_a_SOURCES = version.c version.h
|
||||
|
||||
# Tell the linker to omit references to unused shared libraries.
|
||||
AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
|
||||
|
||||
# Sometimes, the expansion of $(LIBINTL) includes -lc which may
|
||||
# include modules defining variables like `optind', so libcoreutils.a
|
||||
# must precede $(LIBINTL) in order to ensure we use GNU getopt.
|
||||
@@ -391,6 +394,9 @@ who_LDADD += $(GETADDRINFO_LIB)
|
||||
hostname_LDADD += $(GETHOSTNAME_LIB)
|
||||
uname_LDADD += $(GETHOSTNAME_LIB)
|
||||
|
||||
# for strsignal
|
||||
kill_LDADD += $(LIBTHREAD)
|
||||
|
||||
$(PROGRAMS): ../lib/libcoreutils.a
|
||||
|
||||
# Get the release year from ../lib/version-etc.c.
|
||||
@@ -635,6 +641,7 @@ built_programs.list:
|
||||
|
||||
all_programs.list:
|
||||
@echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
|
||||
| sed /libstdbuf/d \
|
||||
| $(ASSORT) -u
|
||||
|
||||
# This is required because we have broken inter-directory dependencies:
|
||||
@@ -642,6 +649,11 @@ all_programs.list:
|
||||
# install a binary, require that all programs be built at distribution time.
|
||||
dist-hook: $(all_programs)
|
||||
|
||||
# Ensure that all programs are built so we can for example
|
||||
# subsequently syntax check all man pages.
|
||||
.PHONY: all_programs
|
||||
all_programs: $(all_programs)
|
||||
|
||||
pm = progs-makefile
|
||||
pr = progs-readme
|
||||
# Ensure that the list of programs in README matches the list
|
||||
@@ -672,7 +684,7 @@ au_dotdot = authors-dotdot
|
||||
au_actual = authors-actual
|
||||
.PHONY: sc_check-AUTHORS
|
||||
sc_check-AUTHORS: $(all_programs)
|
||||
$(AM_V_GEN)locale=en_US.UTF-8; \
|
||||
@locale=en_US.UTF-8; \
|
||||
LC_ALL="$$locale" ./cat --version \
|
||||
| grep ' Torbjorn ' > /dev/null \
|
||||
&& { echo "$@: skipping this check"; exit 0; }; \
|
||||
@@ -708,8 +720,11 @@ sc_check-AUTHORS: $(all_programs)
|
||||
# The second nm|grep checks for file-scope variables with `extern' scope.
|
||||
.PHONY: sc_tight_scope
|
||||
sc_tight_scope: $(bin_PROGRAMS)
|
||||
$(AM_V_GEN)t=exceptions-$$$$; \
|
||||
trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
|
||||
@t=exceptions-$$$$; \
|
||||
trap 's=$$?; rm -f $$t; exit $$s' 0; \
|
||||
am__exit='(exit $s); exit $s'; \
|
||||
trap "s=129; $$am__exit" 1; trap "s=130; $$am__exit" 2; \
|
||||
trap "s=141; $$am__exit" 13; trap "s=143; $$am__exit" 15; \
|
||||
src=`for f in $(SOURCES); do \
|
||||
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
||||
hdr=`for f in $(noinst_HEADERS); do \
|
||||
|
||||
18
src/base64.c
18
src/base64.c
@@ -29,6 +29,7 @@
|
||||
#include "xstrtol.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "xfreopen.h"
|
||||
|
||||
#include "base64.h"
|
||||
|
||||
@@ -61,11 +62,10 @@ Usage: %s [OPTION]... [FILE]\n\
|
||||
Base64 encode or decode FILE, or standard input, to standard output.\n\
|
||||
\n"), program_name);
|
||||
fputs (_("\
|
||||
-w, --wrap=COLS Wrap encoded lines after COLS character (default 76).\n\
|
||||
Use 0 to disable line wrapping.\n\
|
||||
\n\
|
||||
-d, --decode Decode data.\n\
|
||||
-i, --ignore-garbage When decoding, ignore non-alphabet characters.\n\
|
||||
-d, --decode decode data\n\
|
||||
-i, --ignore-garbage when decoding, ignore non-alphabet characters\n\
|
||||
-w, --wrap=COLS wrap encoded lines after COLS character (default 76).\n\
|
||||
Use 0 to disable line wrapping\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
@@ -290,10 +290,14 @@ main (int argc, char **argv)
|
||||
infile = "-";
|
||||
|
||||
if (STREQ (infile, "-"))
|
||||
input_fh = stdin;
|
||||
{
|
||||
if (O_BINARY)
|
||||
xfreopen (NULL, "rb", stdin);
|
||||
input_fh = stdin;
|
||||
}
|
||||
else
|
||||
{
|
||||
input_fh = fopen (infile, "r");
|
||||
input_fh = fopen (infile, "rb");
|
||||
if (input_fh == NULL)
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ With --reference, change the owner and group of each FILE to those of RFILE.\n\
|
||||
change the owner and/or group of each file only if\n\
|
||||
its current owner and/or group match those specified\n\
|
||||
here. Either may be omitted, in which case a match\n\
|
||||
is not required for the omitted attribute.\n\
|
||||
is not required for the omitted attribute\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--no-preserve-root do not treat `/' specially (the default)\n\
|
||||
|
||||
10
src/chroot.c
10
src/chroot.c
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
#include "userspec.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -162,9 +161,6 @@ main (int argc, char **argv)
|
||||
initialize_exit_failure (EXIT_CANCELED);
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "+", long_opts, NULL)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -172,9 +168,15 @@ main (int argc, char **argv)
|
||||
case USERSPEC:
|
||||
userspec = optarg;
|
||||
break;
|
||||
|
||||
case GROUPS:
|
||||
groups = optarg;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (EXIT_CANCELED);
|
||||
}
|
||||
|
||||
80
src/copy.c
80
src/copy.c
@@ -531,7 +531,8 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
security_context_t con = NULL;
|
||||
if (getfscreatecon (&con) < 0)
|
||||
{
|
||||
if (!x->reduce_diagnostics || x->require_preserve_context)
|
||||
if (x->require_preserve_context ||
|
||||
(!x->reduce_diagnostics && !errno_unsupported (errno)))
|
||||
error (0, errno, _("failed to get file system create context"));
|
||||
if (x->require_preserve_context)
|
||||
{
|
||||
@@ -544,7 +545,8 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
{
|
||||
if (fsetfilecon (dest_desc, con) < 0)
|
||||
{
|
||||
if (!x->reduce_diagnostics || x->require_preserve_context)
|
||||
if (x->require_preserve_context ||
|
||||
(!x->reduce_diagnostics && !errno_unsupported (errno)))
|
||||
error (0, errno,
|
||||
_("failed to set the security context of %s to %s"),
|
||||
quote_n (0, dst_name), quote_n (1, con));
|
||||
@@ -587,10 +589,11 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
lstat'ing the DST_NAME shows that it is a symlink, then we
|
||||
have a problem: trying to resolve this dangling symlink to
|
||||
a directory/destination-entry pair is fundamentally racy,
|
||||
so punt. If POSIXLY_CORRECT is set, simply call open again,
|
||||
but without O_EXCL (potentially dangerous). If not, fail
|
||||
with a diagnostic. These shenanigans are necessary only
|
||||
when copying, i.e., not in move_mode. */
|
||||
so punt. If x->open_dangling_dest_symlink is set (cp sets
|
||||
that when POSIXLY_CORRECT is set in the environment), simply
|
||||
call open again, but without O_EXCL (potentially dangerous).
|
||||
If not, fail with a diagnostic. These shenanigans are necessary
|
||||
only when copying, i.e., not in move_mode. */
|
||||
if (dest_desc < 0 && dest_errno == EEXIST && ! x->move_mode)
|
||||
{
|
||||
struct stat dangling_link_sb;
|
||||
@@ -797,15 +800,9 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
|
||||
if (last_write_made_hole)
|
||||
{
|
||||
if (HAVE_FTRUNCATE
|
||||
? /* ftruncate sets the file size,
|
||||
so there is no need for a write. */
|
||||
ftruncate (dest_desc, n_read_total) < 0
|
||||
: /* Seek backwards one character and write a null. */
|
||||
(lseek (dest_desc, (off_t) -1, SEEK_CUR) < 0L
|
||||
|| full_write (dest_desc, "", 1) != 1))
|
||||
if (ftruncate (dest_desc, n_read_total) < 0)
|
||||
{
|
||||
error (0, errno, _("writing %s"), quote (dst_name));
|
||||
error (0, errno, _("truncating %s"), quote (dst_name));
|
||||
return_val = false;
|
||||
goto close_src_and_dst_desc;
|
||||
}
|
||||
@@ -829,24 +826,8 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
}
|
||||
}
|
||||
|
||||
/* To allow copying xattrs on read-only files, temporarily chmod u+rw.
|
||||
This workaround is required as an inode permission check is done
|
||||
by xattr_permission() in fs/xattr.c of the GNU/Linux kernel tree. */
|
||||
if (x->preserve_xattr)
|
||||
{
|
||||
bool access_changed = false;
|
||||
|
||||
if (!(sb.st_mode & S_IWUSR) && geteuid() != 0)
|
||||
access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0;
|
||||
|
||||
if (!copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
|
||||
&& x->require_preserve_xattr)
|
||||
return_val = false;
|
||||
|
||||
if (access_changed)
|
||||
fchmod_or_lchmod (dest_desc, dst_name, dst_mode & ~omitted_permissions);
|
||||
}
|
||||
|
||||
/* Set ownership before xattrs as changing owners will
|
||||
clear capabilities. */
|
||||
if (x->preserve_ownership && ! SAME_OWNER_AND_GROUP (*src_sb, sb))
|
||||
{
|
||||
switch (set_owner (x, dst_name, dest_desc, src_sb, *new_dst, &sb))
|
||||
@@ -861,6 +842,24 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
}
|
||||
}
|
||||
|
||||
/* To allow copying xattrs on read-only files, temporarily chmod u+rw.
|
||||
This workaround is required as an inode permission check is done
|
||||
by xattr_permission() in fs/xattr.c of the GNU/Linux kernel tree. */
|
||||
if (x->preserve_xattr)
|
||||
{
|
||||
bool access_changed = false;
|
||||
|
||||
if (!(sb.st_mode & S_IWUSR) && geteuid () != 0)
|
||||
access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0;
|
||||
|
||||
if (!copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
|
||||
&& x->require_preserve_xattr)
|
||||
return_val = false;
|
||||
|
||||
if (access_changed)
|
||||
fchmod_or_lchmod (dest_desc, dst_name, dst_mode & ~omitted_permissions);
|
||||
}
|
||||
|
||||
set_author (dst_name, dest_desc, src_sb);
|
||||
|
||||
if (x->preserve_mode || x->move_mode)
|
||||
@@ -1830,7 +1829,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
{
|
||||
if (setfscreatecon (con) < 0)
|
||||
{
|
||||
if (!x->reduce_diagnostics || x->require_preserve_context)
|
||||
if (x->require_preserve_context ||
|
||||
(!x->reduce_diagnostics && !errno_unsupported (errno)))
|
||||
error (0, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (con));
|
||||
@@ -1844,15 +1844,15 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!errno_unsupported (errno) || x->require_preserve_context)
|
||||
if (x->require_preserve_context ||
|
||||
(!x->reduce_diagnostics && !errno_unsupported (errno)))
|
||||
{
|
||||
if (!x->reduce_diagnostics || x->require_preserve_context)
|
||||
error (0, errno,
|
||||
_("failed to get security context of %s"),
|
||||
quote (src_name));
|
||||
if (x->require_preserve_context)
|
||||
return false;
|
||||
error (0, errno,
|
||||
_("failed to get security context of %s"),
|
||||
quote (src_name));
|
||||
}
|
||||
if (x->require_preserve_context)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
35
src/copy.h
35
src/copy.h
@@ -180,15 +180,13 @@ struct cp_options
|
||||
Set this only if the kernel is SELinux enabled. */
|
||||
bool preserve_security_context;
|
||||
|
||||
/* Useful only when preserve_security_context is true.
|
||||
If true, a failed attempt to preserve a file's security context
|
||||
propagates failure "out" to the caller. If false, a failure to
|
||||
preserve a file's security context does not change the invoking
|
||||
application's exit status. Give diagnostics for failed syscalls
|
||||
regardless of this setting. For example, with "cp --preserve=context"
|
||||
this flag is "true", while with "cp -a", it is false. That means
|
||||
"cp -a" attempts to preserve any security context, but does not
|
||||
fail if it is unable to do so. */
|
||||
/* Useful only when preserve_context is true.
|
||||
If true, a failed attempt to preserve file's security context
|
||||
propagates failure "out" to the caller, along with full diagnostics.
|
||||
If false, a failure to preserve file's security context does not
|
||||
change the invoking application's exit status, but may output diagnostics.
|
||||
For example, with `cp --preserve=context` this flag is "true",
|
||||
while with `cp --preserve=all` or `cp -a`, it is "false". */
|
||||
bool require_preserve_context;
|
||||
|
||||
/* If true, attempt to preserve extended attributes using libattr.
|
||||
@@ -197,16 +195,19 @@ struct cp_options
|
||||
|
||||
/* Useful only when preserve_xattr is true.
|
||||
If true, a failed attempt to preserve file's extended attributes
|
||||
propagates failure "out" to the caller. If false, a failure to
|
||||
preserve file's extended attributes does not change the invoking
|
||||
application's exit status. Give diagnostics for failed syscalls
|
||||
regardless of this setting. For example, with "cp --preserve=xattr"
|
||||
this flag is "true", while with "cp --preserve=all", it is false. */
|
||||
propagates failure "out" to the caller, along with full diagnostics.
|
||||
If false, a failure to preserve file's extended attributes does not
|
||||
change the invoking application's exit status, but may output diagnostics.
|
||||
For example, with `cp --preserve=xattr` this flag is "true",
|
||||
while with `cp --preserve=all` or `cp -a`, it is "false". */
|
||||
bool require_preserve_xattr;
|
||||
|
||||
/* Used as difference boolean between cp -a and cp -dR --preserve=all.
|
||||
If true, non-mandatory failure diagnostics are not displayed. This
|
||||
should prevent poluting cp -a output.
|
||||
/* This allows us to output warnings in cases 2 and 4 below,
|
||||
while being quiet for case 1 (when reduce_diagnostics is true).
|
||||
1. cp -a try to copy xattrs with no errors
|
||||
2. cp --preserve=all copy xattrs with all but ENOTSUP warnings
|
||||
3. cp --preserve=xattr,context copy xattrs with all errors
|
||||
4. mv copy xattrs with all but ENOTSUP warnings
|
||||
*/
|
||||
bool reduce_diagnostics;
|
||||
|
||||
|
||||
4
src/cp.c
4
src/cp.c
@@ -202,12 +202,12 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-R, -r, --recursive copy directories recursively\n\
|
||||
--reflink[=WHEN] control clone/CoW copies. See below.\n\
|
||||
--reflink[=WHEN] control clone/CoW copies. See below\n\
|
||||
--remove-destination remove each existing destination file before\n\
|
||||
attempting to open it (contrast with --force)\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--sparse=WHEN control creation of sparse files. See below.\n\
|
||||
--sparse=WHEN control creation of sparse files. See below\n\
|
||||
--strip-trailing-slashes remove any trailing slashes from each SOURCE\n\
|
||||
argument\n\
|
||||
"), stdout);
|
||||
|
||||
@@ -756,7 +756,7 @@ main (int argc, char **argv)
|
||||
int optc;
|
||||
bool ok;
|
||||
bool delim_specified = false;
|
||||
char *spec_list_string IF_LINT(= NULL);
|
||||
char *spec_list_string IF_LINT (= NULL);
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
|
||||
2
src/dd.c
2
src/dd.c
@@ -1875,7 +1875,7 @@ main (int argc, char **argv)
|
||||
|
||||
offset = lseek (STDIN_FILENO, 0, SEEK_CUR);
|
||||
input_seekable = (0 <= offset);
|
||||
input_offset = MAX(0, offset);
|
||||
input_offset = MAX (0, offset);
|
||||
input_seek_errno = errno;
|
||||
|
||||
if (output_file == NULL)
|
||||
|
||||
@@ -38,9 +38,11 @@ TERM mach-color
|
||||
TERM mlterm
|
||||
TERM putty
|
||||
TERM rxvt
|
||||
TERM rxvt-256color
|
||||
TERM rxvt-cygwin
|
||||
TERM rxvt-cygwin-native
|
||||
TERM rxvt-unicode
|
||||
TERM rxvt-unicode256
|
||||
TERM screen
|
||||
TERM screen-256color
|
||||
TERM screen-256color-bce
|
||||
|
||||
@@ -787,7 +787,7 @@ eval4 (bool evaluate)
|
||||
if (evaluate)
|
||||
{
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-numeric argument"));
|
||||
error (EXPR_INVALID, 0, _("non-integer argument"));
|
||||
if (fxn != multiply && mpz_sgn (r->u.i) == 0)
|
||||
error (EXPR_INVALID, 0, _("division by zero"));
|
||||
((fxn == multiply ? mpz_mul
|
||||
@@ -824,7 +824,7 @@ eval3 (bool evaluate)
|
||||
if (evaluate)
|
||||
{
|
||||
if (!toarith (l) || !toarith (r))
|
||||
error (EXPR_INVALID, 0, _("non-numeric argument"));
|
||||
error (EXPR_INVALID, 0, _("non-integer argument"));
|
||||
(fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i);
|
||||
}
|
||||
freev (r);
|
||||
|
||||
@@ -139,14 +139,14 @@ main (int argc, char **argv)
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
|
||||
#define print_int(TYPE) \
|
||||
snprintf (limit, sizeof(limit), "%"PRIuMAX, (uintmax_t)TYPE##_MAX); \
|
||||
snprintf (limit, sizeof limit, "%"PRIuMAX, (uintmax_t)TYPE##_MAX); \
|
||||
printf (#TYPE"_MAX=%s\n", limit); \
|
||||
oflow = decimal_ascii_add (limit, "1"); \
|
||||
printf (#TYPE"_OFLOW=%s\n", oflow); \
|
||||
free (oflow); \
|
||||
if (TYPE##_MIN) \
|
||||
{ \
|
||||
snprintf (limit, sizeof(limit), "%"PRIdMAX, (intmax_t)TYPE##_MIN); \
|
||||
snprintf (limit, sizeof limit, "%"PRIdMAX, (intmax_t)TYPE##_MIN); \
|
||||
printf (#TYPE"_MIN=%s\n", limit); \
|
||||
oflow = decimal_ascii_add (limit, "-1"); \
|
||||
printf (#TYPE"_UFLOW=%s\n", oflow); \
|
||||
|
||||
67
src/join.c
67
src/join.c
@@ -137,7 +137,8 @@ static enum
|
||||
enum
|
||||
{
|
||||
CHECK_ORDER_OPTION = CHAR_MAX + 1,
|
||||
NOCHECK_ORDER_OPTION
|
||||
NOCHECK_ORDER_OPTION,
|
||||
HEADER_LINE_OPTION
|
||||
};
|
||||
|
||||
|
||||
@@ -146,6 +147,7 @@ static struct option const longopts[] =
|
||||
{"ignore-case", no_argument, NULL, 'i'},
|
||||
{"check-order", no_argument, NULL, CHECK_ORDER_OPTION},
|
||||
{"nocheck-order", no_argument, NULL, NOCHECK_ORDER_OPTION},
|
||||
{"header", no_argument, NULL, HEADER_LINE_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -157,6 +159,10 @@ static struct line uni_blank;
|
||||
/* If nonzero, ignore case when comparing join fields. */
|
||||
static bool ignore_case;
|
||||
|
||||
/* If nonzero, treat the first line of each file as column headers -
|
||||
join them without checking for ordering */
|
||||
static bool join_header_lines;
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -191,6 +197,8 @@ by whitespace. When FILE1 or FILE2 (not both) is -, read standard input.\n\
|
||||
--check-order check that the input is correctly sorted, even\n\
|
||||
if all input lines are pairable\n\
|
||||
--nocheck-order do not check that the input is correctly sorted\n\
|
||||
--header treat the first line in each file as field headers,\n\
|
||||
print them without trying to pair them\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
@@ -204,7 +212,8 @@ the remaining fields from FILE1, the remaining fields from FILE2, all\n\
|
||||
separated by CHAR.\n\
|
||||
\n\
|
||||
Important: FILE1 and FILE2 must be sorted on the join fields.\n\
|
||||
E.g., use `sort -k 1b,1' if `join' has no options.\n\
|
||||
E.g., use ` sort -k 1b,1 ' if `join' has no options,\n\
|
||||
or use ` join -t '' ' if `sort' has no options.\n\
|
||||
Note, comparisons honor the rules specified by `LC_COLLATE'.\n\
|
||||
If the input is not sorted and some lines cannot be joined, a\n\
|
||||
warning message will be given.\n\
|
||||
@@ -272,7 +281,10 @@ xfields (struct line *line)
|
||||
static void
|
||||
freeline (struct line *line)
|
||||
{
|
||||
if (line == NULL)
|
||||
return;
|
||||
free (line->fields);
|
||||
line->fields = NULL;
|
||||
free (line->buf.buffer);
|
||||
line->buf.buffer = NULL;
|
||||
}
|
||||
@@ -486,12 +498,10 @@ delseq (struct seq *seq)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < seq->alloc; i++)
|
||||
if (seq->lines[i])
|
||||
{
|
||||
if (seq->lines[i]->buf.buffer)
|
||||
freeline (seq->lines[i]);
|
||||
free (seq->lines[i]);
|
||||
}
|
||||
{
|
||||
freeline (seq->lines[i]);
|
||||
free (seq->lines[i]);
|
||||
}
|
||||
free (seq->lines);
|
||||
}
|
||||
|
||||
@@ -604,11 +614,8 @@ static void
|
||||
join (FILE *fp1, FILE *fp2)
|
||||
{
|
||||
struct seq seq1, seq2;
|
||||
struct line **linep = xmalloc (sizeof *linep);
|
||||
int diff;
|
||||
bool eof1, eof2, checktail;
|
||||
|
||||
*linep = NULL;
|
||||
bool eof1, eof2;
|
||||
|
||||
/* Read the first line of each file. */
|
||||
initseq (&seq1);
|
||||
@@ -616,6 +623,15 @@ join (FILE *fp1, FILE *fp2)
|
||||
initseq (&seq2);
|
||||
getseq (fp2, &seq2, 2);
|
||||
|
||||
if (join_header_lines && seq1.count && seq2.count)
|
||||
{
|
||||
prjoin (seq1.lines[0], seq2.lines[0]);
|
||||
prevline[0] = NULL;
|
||||
prevline[1] = NULL;
|
||||
advance_seq (fp1, &seq1, true, 1);
|
||||
advance_seq (fp2, &seq2, true, 2);
|
||||
}
|
||||
|
||||
while (seq1.count && seq2.count)
|
||||
{
|
||||
size_t i;
|
||||
@@ -691,25 +707,26 @@ join (FILE *fp1, FILE *fp2)
|
||||
seq2.count = 0;
|
||||
}
|
||||
|
||||
/* If the user did not specify --check-order, and the we read the
|
||||
/* If the user did not specify --check-order, then we read the
|
||||
tail ends of both inputs to verify that they are in order. We
|
||||
skip the rest of the tail once we have issued a warning for that
|
||||
file, unless we actually need to print the unpairable lines. */
|
||||
struct line *line = NULL;
|
||||
bool checktail = false;
|
||||
|
||||
if (check_input_order != CHECK_ORDER_DISABLED
|
||||
&& !(issued_disorder_warning[0] && issued_disorder_warning[1]))
|
||||
checktail = true;
|
||||
else
|
||||
checktail = false;
|
||||
|
||||
if ((print_unpairables_1 || checktail) && seq1.count)
|
||||
{
|
||||
if (print_unpairables_1)
|
||||
prjoin (seq1.lines[0], &uni_blank);
|
||||
seen_unpairable = true;
|
||||
while (get_line (fp1, linep, 1))
|
||||
while (get_line (fp1, &line, 1))
|
||||
{
|
||||
if (print_unpairables_1)
|
||||
prjoin (*linep, &uni_blank);
|
||||
prjoin (line, &uni_blank);
|
||||
if (issued_disorder_warning[0] && !print_unpairables_1)
|
||||
break;
|
||||
}
|
||||
@@ -720,18 +737,18 @@ join (FILE *fp1, FILE *fp2)
|
||||
if (print_unpairables_2)
|
||||
prjoin (&uni_blank, seq2.lines[0]);
|
||||
seen_unpairable = true;
|
||||
while (get_line (fp2, linep, 2))
|
||||
while (get_line (fp2, &line, 2))
|
||||
{
|
||||
if (print_unpairables_2)
|
||||
prjoin (&uni_blank, *linep);
|
||||
prjoin (&uni_blank, line);
|
||||
if (issued_disorder_warning[1] && !print_unpairables_2)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free (*linep);
|
||||
freeline (line);
|
||||
free (line);
|
||||
|
||||
free (linep);
|
||||
delseq (&seq1);
|
||||
delseq (&seq2);
|
||||
}
|
||||
@@ -1024,8 +1041,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
unsigned char newtab = optarg[0];
|
||||
if (! newtab)
|
||||
error (EXIT_FAILURE, 0, _("empty tab"));
|
||||
if (optarg[1])
|
||||
newtab = '\n'; /* '' => process the whole line. */
|
||||
else if (optarg[1])
|
||||
{
|
||||
if (STREQ (optarg, "\\0"))
|
||||
newtab = '\0';
|
||||
@@ -1052,6 +1069,10 @@ main (int argc, char **argv)
|
||||
&nfiles, &prev_optc_status, &optc_status);
|
||||
break;
|
||||
|
||||
case HEADER_LINE_OPTION:
|
||||
join_header_lines = true;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
@@ -123,6 +123,7 @@ apply_mode (FILE *stream, const char *mode)
|
||||
{
|
||||
fprintf (stderr, _("could not set buffering of %s to mode %s\n"),
|
||||
fileno_to_name (fileno (stream)), mode);
|
||||
free (buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
44
src/ls.c
44
src/ls.c
@@ -39,10 +39,6 @@
|
||||
#include <config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_CAP
|
||||
# include <sys/capability.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_TERMIOS_H
|
||||
# include <termios.h>
|
||||
#endif
|
||||
@@ -113,6 +109,13 @@
|
||||
#include "areadlink.h"
|
||||
#include "mbsalign.h"
|
||||
|
||||
/* Include <sys/capability.h> last to avoid a clash of <sys/types.h>
|
||||
include guards with some premature versions of libcap.
|
||||
For more details, see <http://bugzilla.redhat.com/483548>. */
|
||||
#ifdef HAVE_CAP
|
||||
# include <sys/capability.h>
|
||||
#endif
|
||||
|
||||
#define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \
|
||||
: (ls_mode == LS_MULTI_COL \
|
||||
? "dir" : "vdir"))
|
||||
@@ -1146,6 +1149,17 @@ restore_default_color (void)
|
||||
put_indicator (&color_indicator[C_RIGHT]);
|
||||
}
|
||||
|
||||
static void
|
||||
set_normal_color (void)
|
||||
{
|
||||
if (print_with_color && is_colored (C_NORM))
|
||||
{
|
||||
put_indicator (&color_indicator[C_LEFT]);
|
||||
put_indicator (&color_indicator[C_NORM]);
|
||||
put_indicator (&color_indicator[C_RIGHT]);
|
||||
}
|
||||
}
|
||||
|
||||
/* An ordinary signal was received; arrange for the program to exit. */
|
||||
|
||||
static void
|
||||
@@ -1439,7 +1453,15 @@ main (int argc, char **argv)
|
||||
int j;
|
||||
|
||||
if (used_color)
|
||||
restore_default_color ();
|
||||
{
|
||||
/* Skip the restore when it would be a no-op, i.e.,
|
||||
when left is "\033[" and right is "m". */
|
||||
if (!(color_indicator[C_LEFT].len == 2
|
||||
&& memcmp (color_indicator[C_LEFT].string, "\033[", 2) == 0
|
||||
&& color_indicator[C_RIGHT].len == 1
|
||||
&& color_indicator[C_RIGHT].string[0] == 'm'))
|
||||
restore_default_color ();
|
||||
}
|
||||
fflush (stdout);
|
||||
|
||||
/* Restore the default signal handling. */
|
||||
@@ -3433,6 +3455,7 @@ print_current_files (void)
|
||||
case long_format:
|
||||
for (i = 0; i < cwd_n_used; i++)
|
||||
{
|
||||
set_normal_color ();
|
||||
print_long_format (sorted_file[i]);
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
@@ -3993,7 +4016,9 @@ print_name_with_quoting (const struct fileinfo *f,
|
||||
const char* name = symlink_target ? f->linkname : f->name;
|
||||
|
||||
bool used_color_this_time
|
||||
= (print_with_color && print_color_indicator (f, symlink_target));
|
||||
= (print_with_color
|
||||
&& (print_color_indicator (f, symlink_target)
|
||||
|| is_colored (C_NORM)));
|
||||
|
||||
if (stack)
|
||||
PUSH_CURRENT_DIRED_POS (stack);
|
||||
@@ -4037,6 +4062,8 @@ print_file_name_and_frills (const struct fileinfo *f, size_t start_col)
|
||||
{
|
||||
char buf[MAX (LONGEST_HUMAN_READABLE + 1, INT_BUFSIZE_BOUND (uintmax_t))];
|
||||
|
||||
set_normal_color ();
|
||||
|
||||
if (print_inode)
|
||||
printf ("%*s ", format == with_commas ? 0 : inode_number_width,
|
||||
format_inode (buf, sizeof buf, f));
|
||||
@@ -4207,6 +4234,9 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target)
|
||||
= ext ? &(ext->seq) : &color_indicator[type];
|
||||
if (s->string != NULL)
|
||||
{
|
||||
/* Need to reset so not dealing with attribute combinations */
|
||||
if (is_colored (C_NORM))
|
||||
restore_default_color ();
|
||||
put_indicator (&color_indicator[C_LEFT]);
|
||||
put_indicator (s);
|
||||
put_indicator (&color_indicator[C_RIGHT]);
|
||||
@@ -4564,7 +4594,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-a, --all do not ignore entries starting with .\n\
|
||||
-A, --almost-all do not list implied . and ..\n\
|
||||
--author with -l, print the author of each file\n\
|
||||
-b, --escape print octal escapes for nongraphic characters\n\
|
||||
-b, --escape print C-style escapes for nongraphic characters\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--block-size=SIZE use SIZE-byte blocks. See SIZE format below\n\
|
||||
|
||||
@@ -87,7 +87,7 @@ If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and --tmpdir is implied.\n\
|
||||
specified, use $TMPDIR if set, else /tmp. With\n\
|
||||
this option, TEMPLATE must not be an absolute name.\n\
|
||||
Unlike with -t, TEMPLATE may contain slashes, but\n\
|
||||
mktemp creates only the final component.\n\
|
||||
mktemp creates only the final component\n\
|
||||
"), stdout);
|
||||
fputs ("\n", stdout);
|
||||
fputs (_("\
|
||||
|
||||
34
src/nice.c
34
src/nice.c
@@ -30,7 +30,6 @@
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -58,6 +57,8 @@
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"adjustment", required_argument, NULL, 'n'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -110,9 +111,6 @@ main (int argc, char **argv)
|
||||
initialize_exit_failure (EXIT_CANCELED);
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
|
||||
for (i = 1; i < argc; /* empty */)
|
||||
{
|
||||
char const *s = argv[i];
|
||||
@@ -124,7 +122,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
int optc;
|
||||
int c;
|
||||
int fake_argc = argc - (i - 1);
|
||||
char **fake_argv = argv + (i - 1);
|
||||
|
||||
@@ -134,14 +132,28 @@ main (int argc, char **argv)
|
||||
/* Initialize getopt_long's internal state. */
|
||||
optind = 0;
|
||||
|
||||
optc = getopt_long (fake_argc, fake_argv, "+n:", longopts, NULL);
|
||||
c = getopt_long (fake_argc, fake_argv, "+n:", longopts, NULL);
|
||||
i += optind - 1;
|
||||
|
||||
if (optc == '?')
|
||||
usage (EXIT_CANCELED);
|
||||
else if (optc == 'n')
|
||||
adjustment_given = optarg;
|
||||
else /* optc == -1 */
|
||||
switch (c)
|
||||
{
|
||||
case 'n':
|
||||
adjustment_given = optarg;
|
||||
break;
|
||||
|
||||
case -1:
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (EXIT_CANCELED);
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
6
src/pr.c
6
src/pr.c
@@ -1915,10 +1915,10 @@ init_store_cols (void)
|
||||
|
||||
free (line_vector);
|
||||
/* FIXME: here's where it was allocated. */
|
||||
line_vector = xmalloc ((total_lines + 1) * sizeof (int *));
|
||||
line_vector = xmalloc ((total_lines + 1) * sizeof *line_vector);
|
||||
|
||||
free (end_vector);
|
||||
end_vector = xmalloc (total_lines * sizeof (int *));
|
||||
end_vector = xmalloc (total_lines * sizeof *end_vector);
|
||||
|
||||
free (buff);
|
||||
buff_allocated = (use_col_separator
|
||||
@@ -2783,7 +2783,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-COLUMN, --columns=COLUMN\n\
|
||||
output COLUMN columns and print columns down,\n\
|
||||
unless -a is used. Balance number of lines in the\n\
|
||||
columns on each page.\n\
|
||||
columns on each page\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-a, --across print columns across rather than down, used together\n\
|
||||
|
||||
@@ -315,7 +315,7 @@ logical_getcwd (void)
|
||||
}
|
||||
|
||||
/* System call validation. */
|
||||
if (stat (wd, &st1) == 0 && stat (".", &st2) == 0 && SAME_INODE(st1, st2))
|
||||
if (stat (wd, &st1) == 0 && stat (".", &st2) == 0 && SAME_INODE (st1, st2))
|
||||
return wd;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
13
src/remove.c
13
src/remove.c
@@ -25,9 +25,6 @@
|
||||
#include "error.h"
|
||||
#include "euidaccess-stat.h"
|
||||
#include "file-type.h"
|
||||
#include "hash.h"
|
||||
#include "hash-pjw.h"
|
||||
#include "obstack.h"
|
||||
#include "quote.h"
|
||||
#include "remove.h"
|
||||
#include "root-dev-ino.h"
|
||||
@@ -174,9 +171,13 @@ write_protected_non_symlink (int fd_cwd,
|
||||
{
|
||||
/* This implements #1: on decent systems, either faccessat is
|
||||
native or /proc/self/fd allows us to skip a chdir. */
|
||||
if (!openat_needs_fchdir ()
|
||||
&& faccessat (fd_cwd, file, W_OK, AT_EACCESS) == 0)
|
||||
return 0;
|
||||
if (!openat_needs_fchdir ())
|
||||
{
|
||||
if (faccessat (fd_cwd, file, W_OK, AT_EACCESS) == 0)
|
||||
return 0;
|
||||
|
||||
return errno == EACCES ? 1 : -1;
|
||||
}
|
||||
|
||||
/* This implements #5: */
|
||||
size_t file_name_len = strlen (full_name);
|
||||
|
||||
6
src/rm.c
6
src/rm.c
@@ -176,9 +176,9 @@ use one of these commands:\n\
|
||||
program_name, program_name);
|
||||
fputs (_("\
|
||||
\n\
|
||||
Note that if you use rm to remove a file, it is usually possible to recover\n\
|
||||
the contents of that file. If you want more assurance that the contents are\n\
|
||||
truly unrecoverable, consider using shred.\n\
|
||||
Note that if you use rm to remove a file, it might be possible to recover\n\
|
||||
some of its contents, given sufficient expertise and/or time. For greater\n\
|
||||
assurance that the contents are truly unrecoverable, consider using shred.\n\
|
||||
"), stdout);
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
|
||||
127
src/sort.c
127
src/sort.c
@@ -32,6 +32,7 @@
|
||||
#include "filevercmp.h"
|
||||
#include "hard-locale.h"
|
||||
#include "hash.h"
|
||||
#include "ignore-value.h"
|
||||
#include "md5.h"
|
||||
#include "physmem.h"
|
||||
#include "posixver.h"
|
||||
@@ -166,7 +167,7 @@ struct keyfield
|
||||
{
|
||||
size_t sword; /* Zero-origin 'word' to start at. */
|
||||
size_t schar; /* Additional characters to skip. */
|
||||
size_t eword; /* Zero-origin first word after field. */
|
||||
size_t eword; /* Zero-origin last 'word' of key. */
|
||||
size_t echar; /* Additional characters in field. */
|
||||
bool const *ignore; /* Boolean array of characters to ignore. */
|
||||
char const *translate; /* Translation applied to characters. */
|
||||
@@ -180,7 +181,7 @@ struct keyfield
|
||||
Handle numbers in exponential notation. */
|
||||
bool human_numeric; /* Flag for sorting by human readable
|
||||
units with either SI xor IEC prefixes. */
|
||||
int si_present; /* Flag for checking for mixed SI and IEC. */
|
||||
int iec_present; /* Flag for checking for mixed SI and IEC. */
|
||||
bool month; /* Flag for comparison by month name. */
|
||||
bool reverse; /* Reverse the sense of comparison. */
|
||||
bool version; /* sort by version number */
|
||||
@@ -209,7 +210,7 @@ static bool nonprinting[UCHAR_LIM];
|
||||
static bool nondictionary[UCHAR_LIM];
|
||||
|
||||
/* Translation table folding lower case to upper. */
|
||||
static char fold_toupper[UCHAR_LIM];
|
||||
static unsigned char fold_toupper[UCHAR_LIM];
|
||||
|
||||
#define MONTHS_PER_YEAR 12
|
||||
|
||||
@@ -794,6 +795,61 @@ create_temp_file (int *pfd, bool survive_fd_exhaustion)
|
||||
return node;
|
||||
}
|
||||
|
||||
/* Predeclare an access pattern for input files.
|
||||
Ignore any errors -- this is only advisory.
|
||||
|
||||
There are a few hints we could possibly provide,
|
||||
and after careful testing it was decided that
|
||||
specifying POSIX_FADV_SEQUENTIAL was not detrimental
|
||||
to any cases. On Linux 2.6.31, this option doubles
|
||||
the size of read ahead performed and thus was seen to
|
||||
benefit these cases:
|
||||
Merging
|
||||
Sorting with a smaller internal buffer
|
||||
Reading from faster flash devices
|
||||
|
||||
In _addition_ one could also specify other hints...
|
||||
|
||||
POSIX_FADV_WILLNEED was tested, but Linux 2.6.31
|
||||
at least uses that to _synchronously_ prepopulate the cache
|
||||
with the specified range. While sort does need to
|
||||
read all of its input before outputting, a synchronous
|
||||
read of the whole file up front precludes any processing
|
||||
that sort could do in parallel with the system doing
|
||||
read ahead of the data. This was seen to have negative effects
|
||||
in a couple of cases:
|
||||
Merging
|
||||
Sorting with a smaller internal buffer
|
||||
Note this option was seen to shorten the runtime for sort
|
||||
on a multicore system with lots of RAM and other processes
|
||||
competing for CPU. It could be argued that more explicit
|
||||
scheduling hints with `nice` et. al. are more appropriate
|
||||
for this situation.
|
||||
|
||||
POSIX_FADV_NOREUSE is a possibility as it could lower
|
||||
the priority of input data in the cache as sort will
|
||||
only need to process it once. However its functionality
|
||||
has changed over Linux kernel versions and as of 2.6.31
|
||||
it does nothing and thus we can't depend on what it might
|
||||
do in future.
|
||||
|
||||
POSIX_FADV_DONTNEED is not appropriate for user specified
|
||||
input files, but for temp files we do want to drop the
|
||||
cache immediately after processing. This is done implicitly
|
||||
however when the files are unlinked. */
|
||||
|
||||
static void
|
||||
fadvise_input (FILE *fp)
|
||||
{
|
||||
#if HAVE_POSIX_FADVISE
|
||||
if (fp)
|
||||
{
|
||||
int fd = fileno (fp);
|
||||
ignore_value (posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return a stream for FILE, opened with mode HOW. A null FILE means
|
||||
standard output; HOW should be "w". When opening for input, "-"
|
||||
means standard input. To avoid confusion, do not return file
|
||||
@@ -805,10 +861,18 @@ stream_open (const char *file, const char *how)
|
||||
{
|
||||
if (!file)
|
||||
return stdout;
|
||||
if (STREQ (file, "-") && *how == 'r')
|
||||
if (*how == 'r')
|
||||
{
|
||||
have_read_stdin = true;
|
||||
return stdin;
|
||||
FILE *fp;
|
||||
if (STREQ (file, "-"))
|
||||
{
|
||||
have_read_stdin = true;
|
||||
fp = stdin;
|
||||
}
|
||||
else
|
||||
fp = fopen (file, how);
|
||||
fadvise_input (fp);
|
||||
return fp;
|
||||
}
|
||||
return fopen (file, how);
|
||||
}
|
||||
@@ -1129,7 +1193,7 @@ inittables (void)
|
||||
{
|
||||
char const *s;
|
||||
size_t s_len;
|
||||
size_t j;
|
||||
size_t j, k;
|
||||
char *name;
|
||||
|
||||
s = (char *) nl_langinfo (ABMON_1 + i);
|
||||
@@ -1137,9 +1201,10 @@ inittables (void)
|
||||
monthtab[i].name = name = xmalloc (s_len + 1);
|
||||
monthtab[i].val = i + 1;
|
||||
|
||||
for (j = 0; j < s_len; j++)
|
||||
name[j] = fold_toupper[to_uchar (s[j])];
|
||||
name[j] = '\0';
|
||||
for (j = k = 0; j < s_len; j++)
|
||||
if (! isblank (to_uchar (s[j])))
|
||||
name[k++] = fold_toupper[to_uchar (s[j])];
|
||||
name[k] = '\0';
|
||||
}
|
||||
qsort ((void *) monthtab, MONTHS_PER_YEAR,
|
||||
sizeof *monthtab, struct_month_cmp);
|
||||
@@ -1175,10 +1240,10 @@ specify_nmerge (int oi, char c, char const *s)
|
||||
if (nmerge < 2)
|
||||
{
|
||||
error (0, 0, _("invalid --%s argument %s"),
|
||||
long_options[oi].name, quote(s));
|
||||
long_options[oi].name, quote (s));
|
||||
error (SORT_FAILURE, 0,
|
||||
_("minimum --%s argument is %s"),
|
||||
long_options[oi].name, quote("2"));
|
||||
long_options[oi].name, quote ("2"));
|
||||
}
|
||||
else if (max_nmerge < nmerge)
|
||||
{
|
||||
@@ -1193,7 +1258,7 @@ specify_nmerge (int oi, char c, char const *s)
|
||||
{
|
||||
char max_nmerge_buf[INT_BUFSIZE_BOUND (unsigned int)];
|
||||
error (0, 0, _("--%s argument %s too large"),
|
||||
long_options[oi].name, quote(s));
|
||||
long_options[oi].name, quote (s));
|
||||
error (SORT_FAILURE, 0,
|
||||
_("maximum --%s argument with current rlimit is %s"),
|
||||
long_options[oi].name,
|
||||
@@ -1689,10 +1754,10 @@ numcompare (const char *a, const char *b)
|
||||
static void
|
||||
check_mixed_SI_IEC (char prefix, struct keyfield *key)
|
||||
{
|
||||
int si_present = prefix == 'i';
|
||||
if (key->si_present != -1 && si_present != key->si_present)
|
||||
int iec_present = prefix == 'i';
|
||||
if (key->iec_present != -1 && iec_present != key->iec_present)
|
||||
error (SORT_FAILURE, 0, _("both SI and IEC prefixes present on units"));
|
||||
key->si_present = si_present;
|
||||
key->iec_present = iec_present;
|
||||
}
|
||||
|
||||
/* Return an integer which represents the order of magnitude of
|
||||
@@ -2521,11 +2586,11 @@ mergefps (struct sortfile *files, size_t ntemps, size_t nfiles,
|
||||
}
|
||||
|
||||
xfclose (ofp, output_file);
|
||||
free(fps);
|
||||
free(buffer);
|
||||
free(ord);
|
||||
free(base);
|
||||
free(cur);
|
||||
free (fps);
|
||||
free (buffer);
|
||||
free (ord);
|
||||
free (base);
|
||||
free (cur);
|
||||
}
|
||||
|
||||
/* Merge lines from FILES onto OFP. NTEMPS is the number of temporary
|
||||
@@ -2724,8 +2789,8 @@ avoid_trashing_input (struct sortfile *files, size_t ntemps,
|
||||
files[i].pid = pid;
|
||||
|
||||
if (i + num_merged < nfiles)
|
||||
memmove(&files[i + 1], &files[i + num_merged],
|
||||
num_merged * sizeof *files);
|
||||
memmove (&files[i + 1], &files[i + num_merged],
|
||||
num_merged * sizeof *files);
|
||||
ntemps += 1;
|
||||
nfiles -= num_merged - 1;;
|
||||
i += num_merged;
|
||||
@@ -2799,7 +2864,7 @@ merge (struct sortfile *files, size_t ntemps, size_t nfiles,
|
||||
|
||||
/* Put the remaining input files into the last NMERGE-sized output
|
||||
window, so they will be merged in the next pass. */
|
||||
memmove(&files[out], &files[in], (nfiles - in) * sizeof *files);
|
||||
memmove (&files[out], &files[in], (nfiles - in) * sizeof *files);
|
||||
ntemps += out;
|
||||
nfiles -= in - out;
|
||||
}
|
||||
@@ -3146,7 +3211,7 @@ key_init (struct keyfield *key)
|
||||
{
|
||||
memset (key, 0, sizeof *key);
|
||||
key->eword = SIZE_MAX;
|
||||
key->si_present = -1;
|
||||
key->iec_present = -1;
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -3263,7 +3328,7 @@ main (int argc, char **argv)
|
||||
gkey.ignore = NULL;
|
||||
gkey.translate = NULL;
|
||||
gkey.numeric = gkey.general_numeric = gkey.human_numeric = false;
|
||||
gkey.si_present = -1;
|
||||
gkey.iec_present = -1;
|
||||
gkey.random = gkey.version = false;
|
||||
gkey.month = gkey.reverse = false;
|
||||
gkey.skipsblanks = gkey.skipeblanks = false;
|
||||
@@ -3324,6 +3389,16 @@ main (int argc, char **argv)
|
||||
if (*s == '.')
|
||||
s = parse_field_count (s + 1, &key->echar,
|
||||
N_("invalid number after `.'"));
|
||||
if (!key->echar && key->eword)
|
||||
{
|
||||
/* obsolescent syntax +A.x -B.y is equivalent to:
|
||||
-k A+1.x+1,B.y (when y = 0)
|
||||
-k A+1.x+1,B+1.y (when y > 0)
|
||||
So eword is decremented as in the -k case
|
||||
only when the end field (B) is specified and
|
||||
echar (y) is 0. */
|
||||
key->eword--;
|
||||
}
|
||||
if (*set_ordering (s, key, bl_end))
|
||||
badfieldspec (optarg1,
|
||||
N_("stray character in field spec"));
|
||||
|
||||
@@ -984,7 +984,7 @@ Display file or file system status.\n\
|
||||
output a newline after each use of FORMAT\n\
|
||||
--printf=FORMAT like --format, but interpret backslash escapes,\n\
|
||||
and do not output a mandatory trailing newline.\n\
|
||||
If you want a newline, include \\n in FORMAT.\n\
|
||||
If you want a newline, include \\n in FORMAT\n\
|
||||
-t, --terse print the information in terse form\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
|
||||
@@ -98,9 +98,9 @@ Run COMMAND, with modified buffering operations for its standard streams.\n\
|
||||
Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-i, --input=MODE Adjust standard input stream buffering\n\
|
||||
-o, --output=MODE Adjust standard output stream buffering\n\
|
||||
-e, --error=MODE Adjust standard error stream buffering\n\
|
||||
-i, --input=MODE adjust standard input stream buffering\n\
|
||||
-o, --output=MODE adjust standard output stream buffering\n\
|
||||
-e, --error=MODE adjust standard error stream buffering\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
|
||||
@@ -182,7 +182,7 @@ enum
|
||||
# define ST_NBLOCKS(statbuf) \
|
||||
(S_ISREG ((statbuf).st_mode) \
|
||||
|| S_ISDIR ((statbuf).st_mode) \
|
||||
? (statbuf).st_blocks * ST_BLKSIZE(statbuf)/ST_NBLOCKSIZE : 0)
|
||||
? (statbuf).st_blocks * ST_BLKSIZE (statbuf) / ST_NBLOCKSIZE : 0)
|
||||
# endif /* _CRAY */
|
||||
# endif /* not AIX PS/2 */
|
||||
# endif /* !hpux */
|
||||
|
||||
@@ -56,6 +56,8 @@
|
||||
# include "fs.h"
|
||||
# if HAVE_SYS_STATFS_H
|
||||
# include <sys/statfs.h>
|
||||
# elif HAVE_SYS_VFS_H
|
||||
# include <sys/vfs.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
#include "operand2sig.h"
|
||||
#include "cloexec.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
|
||||
#define PROGRAM_NAME "timeout"
|
||||
@@ -77,10 +76,14 @@ static int timed_out;
|
||||
static int term_signal = SIGTERM; /* same default as kill command. */
|
||||
static int monitored_pid;
|
||||
static int sigs_to_ignore[NSIG]; /* so monitor can ignore sigs it resends. */
|
||||
static unsigned long kill_after;
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"kill-after", required_argument, NULL, 'k'},
|
||||
{"signal", required_argument, NULL, 's'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
@@ -108,6 +111,13 @@ cleanup (int sig)
|
||||
sigs_to_ignore[sig] = 0;
|
||||
return;
|
||||
}
|
||||
if (kill_after)
|
||||
{
|
||||
/* Start a new timeout after which we'll send SIGKILL. */
|
||||
term_signal = SIGKILL;
|
||||
alarm (kill_after);
|
||||
kill_after = 0; /* Don't let later signals reset kill alarm. */
|
||||
}
|
||||
send_sig (0, sig);
|
||||
if (sig != SIGKILL && sig != SIGCONT)
|
||||
send_sig (0, SIGCONT);
|
||||
@@ -125,20 +135,18 @@ usage (int status)
|
||||
else
|
||||
{
|
||||
printf (_("\
|
||||
Usage: %s [OPTION] NUMBER[SUFFIX] COMMAND [ARG]...\n\
|
||||
Usage: %s [OPTION] DURATION COMMAND [ARG]...\n\
|
||||
or: %s [OPTION]\n"), program_name, program_name);
|
||||
|
||||
fputs (_("\
|
||||
Start COMMAND, and kill it if still running after NUMBER seconds.\n\
|
||||
SUFFIX may be `s' for seconds (the default), `m' for minutes,\n\
|
||||
`h' for hours or `d' for days.\n\
|
||||
Start COMMAND, and kill it if still running after DURATION.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
|
||||
fputs (_("\
|
||||
Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-k, --kill-after=DURATION\n\
|
||||
also send a KILL signal if COMMAND is still running\n\
|
||||
this long after the initial signal was sent.\n\
|
||||
-s, --signal=SIGNAL\n\
|
||||
specify the signal to be sent on timeout.\n\
|
||||
SIGNAL may be a name like `HUP' or a number.\n\
|
||||
@@ -146,6 +154,12 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
|
||||
fputs (_("\n\
|
||||
DURATION is an integer with an optional suffix:\n\
|
||||
`s' for seconds(the default), `m' for minutes, `h' for hours or `d' for days.\n\
|
||||
"), stdout);
|
||||
|
||||
fputs (_("\n\
|
||||
If the command times out, then exit with status 124. Otherwise, exit\n\
|
||||
with the status of COMMAND. If no signal is specified, send the TERM\n\
|
||||
@@ -195,11 +209,32 @@ apply_time_suffix (unsigned long *x, char suffix_char)
|
||||
return true;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
parse_duration (const char* str)
|
||||
{
|
||||
unsigned long duration;
|
||||
char *ep;
|
||||
|
||||
if (xstrtoul (str, &ep, 10, &duration, NULL)
|
||||
/* Invalid interval. Note 0 disables timeout */
|
||||
|| (duration > UINT_MAX)
|
||||
/* Extra chars after the number and an optional s,m,h,d char. */
|
||||
|| (*ep && *(ep + 1))
|
||||
/* Check any suffix char and update timeout based on the suffix. */
|
||||
|| !apply_time_suffix (&duration, *ep))
|
||||
{
|
||||
error (0, 0, _("invalid time interval %s"), quote (str));
|
||||
usage (EXIT_CANCELED);
|
||||
}
|
||||
|
||||
return duration;
|
||||
}
|
||||
|
||||
static void
|
||||
install_signal_handlers (int sigterm)
|
||||
{
|
||||
struct sigaction sa;
|
||||
sigemptyset(&sa.sa_mask); /* Allow concurrent calls to handler */
|
||||
sigemptyset (&sa.sa_mask); /* Allow concurrent calls to handler */
|
||||
sa.sa_handler = cleanup;
|
||||
sa.sa_flags = SA_RESTART; /* restart syscalls (like wait() below) */
|
||||
|
||||
@@ -217,7 +252,6 @@ main (int argc, char **argv)
|
||||
unsigned long timeout;
|
||||
char signame[SIG2STR_MAX];
|
||||
int c;
|
||||
char *ep;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -228,18 +262,24 @@ main (int argc, char **argv)
|
||||
initialize_exit_failure (EXIT_CANCELED);
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "+s:", long_options, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "+k:s:", long_options, NULL)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'k':
|
||||
kill_after = parse_duration (optarg);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
term_signal = operand2sig (optarg, signame);
|
||||
if (term_signal == -1)
|
||||
usage (EXIT_CANCELED);
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (EXIT_CANCELED);
|
||||
break;
|
||||
@@ -249,18 +289,7 @@ main (int argc, char **argv)
|
||||
if (argc - optind < 2)
|
||||
usage (EXIT_CANCELED);
|
||||
|
||||
if (xstrtoul (argv[optind], &ep, 10, &timeout, NULL)
|
||||
/* Invalid interval. Note 0 disables timeout */
|
||||
|| (timeout > UINT_MAX)
|
||||
/* Extra chars after the number and an optional s,m,h,d char. */
|
||||
|| (*ep && *(ep + 1))
|
||||
/* Check any suffix char and update timeout based on the suffix. */
|
||||
|| !apply_time_suffix (&timeout, *ep))
|
||||
{
|
||||
error (0, 0, _("invalid time interval %s"), quote (argv[optind]));
|
||||
usage (EXIT_CANCELED);
|
||||
}
|
||||
optind++;
|
||||
timeout = parse_duration (argv[optind++]);
|
||||
|
||||
argv += optind;
|
||||
|
||||
|
||||
@@ -18,12 +18,7 @@
|
||||
|
||||
This is backwards compatible with the FreeBSD utility, but is more
|
||||
flexible wrt the size specifications and the use of long options,
|
||||
to better fit the "GNU" environment.
|
||||
|
||||
Note if !defined(HAVE_FTRUNCATE) then the --skip-ftruncate configure flag
|
||||
was specified or we're in a mingw environment. In these cases gnulib
|
||||
emulation will be used and GNULIB_FTRUNCATE is defined. Note if emulation
|
||||
can't even be provided ftruncate() will return EIO. */
|
||||
to better fit the "GNU" environment. */
|
||||
|
||||
#include <config.h> /* sets _FILE_OFFSET_BITS=64 etc. */
|
||||
#include <stdio.h>
|
||||
@@ -117,7 +112,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-c, --no-create do not create any files\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-o, --io-blocks Treat SIZE as number of IO blocks instead of bytes\n\
|
||||
-o, --io-blocks treat SIZE as number of IO blocks instead of bytes\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-r, --reference=FILE use this FILE's size\n\
|
||||
|
||||
@@ -152,7 +152,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
fputs (_("\
|
||||
-D, --all-repeated[=delimit-method] print all duplicate lines\n\
|
||||
delimit-method={none(default),prepend,separate}\n\
|
||||
Delimiting is done with blank lines.\n\
|
||||
Delimiting is done with blank lines\n\
|
||||
-f, --skip-fields=N avoid comparing the first N fields\n\
|
||||
-i, --ignore-case ignore differences in case when comparing\n\
|
||||
-s, --skip-chars=N avoid comparing the first N characters\n\
|
||||
|
||||
@@ -208,11 +208,11 @@ in the run queue over the last 1, 5 and 15 minutes."));
|
||||
but such a test is hard to write. For the moment then, we
|
||||
have a hack which depends on the preprocessor used at compile
|
||||
time to tell us what the running kernel is. Ugh. */
|
||||
printf(_(" \
|
||||
printf (_(" \
|
||||
Processes in\n\
|
||||
an uninterruptible sleep state also contribute to the load average.\n"));
|
||||
#else
|
||||
printf(_("\n"));
|
||||
printf (_("\n"));
|
||||
#endif
|
||||
printf (_("\
|
||||
If FILE is not specified, use %s. %s as FILE is common.\n\
|
||||
|
||||
3
src/wc.c
3
src/wc.c
@@ -117,7 +117,8 @@ Usage: %s [OPTION]... [FILE]...\n\
|
||||
fputs (_("\
|
||||
Print newline, word, and byte counts for each FILE, and a total line if\n\
|
||||
more than one FILE is specified. With no FILE, or when FILE is -,\n\
|
||||
read standard input.\n\
|
||||
read standard input. A word is a non-zero-length sequence of characters\n\
|
||||
delimited by white space.\n\
|
||||
-c, --bytes print the byte counts\n\
|
||||
-m, --chars print the character counts\n\
|
||||
-l, --lines print the newline counts\n\
|
||||
|
||||
22
src/who.c
22
src/who.c
@@ -37,6 +37,10 @@
|
||||
#include "hard-locale.h"
|
||||
#include "quote.h"
|
||||
|
||||
#ifdef TTY_GROUP_NAME
|
||||
# include <grp.h>
|
||||
#endif
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "who"
|
||||
|
||||
@@ -308,6 +312,22 @@ print_line (int userlen, const char *user, const char state,
|
||||
free (x_exitstr);
|
||||
}
|
||||
|
||||
/* Return true if a terminal device given as PSTAT allows other users
|
||||
to send messages to; false otherwise */
|
||||
static bool
|
||||
is_tty_writable (struct stat const *pstat)
|
||||
{
|
||||
#ifdef TTY_GROUP_NAME
|
||||
/* Ensure the group of the TTY device matches TTY_GROUP_NAME, more info at
|
||||
https://bugzilla.redhat.com/454261 */
|
||||
struct group *ttygr = getgrnam (TTY_GROUP_NAME);
|
||||
if (!ttygr || (pstat->st_gid != ttygr->gr_gid))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return pstat->st_mode & S_IWGRP;
|
||||
}
|
||||
|
||||
/* Send properly parsed USER_PROCESS info to print_line. The most
|
||||
recent boot time is BOOTTIME. */
|
||||
static void
|
||||
@@ -346,7 +366,7 @@ print_user (const STRUCT_UTMP *utmp_ent, time_t boottime)
|
||||
|
||||
if (stat (line, &stats) == 0)
|
||||
{
|
||||
mesg = (stats.st_mode & S_IWGRP) ? '+' : '-';
|
||||
mesg = is_tty_writable (&stats) ? '+' : '-';
|
||||
last_change = stats.st_atime;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -23,6 +23,7 @@ root_tests = \
|
||||
cp/preserve-gid \
|
||||
cp/special-bits \
|
||||
cp/cp-mv-enotsup-xattr \
|
||||
cp/capability \
|
||||
dd/skip-seek-past-dev \
|
||||
install/install-C-root \
|
||||
ls/capability \
|
||||
@@ -225,6 +226,7 @@ TESTS = \
|
||||
misc/sort-files0-from \
|
||||
misc/sort-merge \
|
||||
misc/sort-merge-fdlimit \
|
||||
misc/sort-month \
|
||||
misc/sort-rand \
|
||||
misc/sort-version \
|
||||
misc/split-a \
|
||||
@@ -370,6 +372,7 @@ TESTS = \
|
||||
ls/abmon-align \
|
||||
ls/color-clear-to-eol \
|
||||
ls/color-dtype-dir \
|
||||
ls/color-norm \
|
||||
ls/dangle \
|
||||
ls/dired \
|
||||
ls/file-type \
|
||||
|
||||
@@ -69,6 +69,7 @@ TESTS_ENVIRONMENT = \
|
||||
fi; \
|
||||
}; \
|
||||
export \
|
||||
VERSION='$(VERSION)' \
|
||||
LOCALE_FR='$(LOCALE_FR)' \
|
||||
LOCALE_FR_UTF8='$(LOCALE_FR_UTF8)' \
|
||||
abs_top_builddir='$(abs_top_builddir)' \
|
||||
@@ -79,7 +80,7 @@ TESTS_ENVIRONMENT = \
|
||||
host_triplet='$(host_triplet)' \
|
||||
srcdir='$(srcdir)' \
|
||||
top_srcdir='$(top_srcdir)' \
|
||||
CONFIG_HEADER='$(abs_top_builddir)/lib/config.h' \
|
||||
CONFIG_HEADER='$(abs_top_builddir)/$(CONFIG_INCLUDE)' \
|
||||
CU_TEST_NAME=`basename '$(abs_srcdir)'`,`echo $$tst|sed 's,^\./,,;s,/,-,g'` \
|
||||
CC='$(CC)' \
|
||||
AWK='$(AWK)' \
|
||||
@@ -91,6 +92,7 @@ TESTS_ENVIRONMENT = \
|
||||
PERL='$(PERL)' \
|
||||
PREFERABLY_POSIX_SHELL='$(PREFERABLY_POSIX_SHELL)' \
|
||||
REPLACE_GETCWD=$(REPLACE_GETCWD) \
|
||||
; test -d /usr/xpg4/bin && PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'"$$PATH"; \
|
||||
PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
|
||||
; shell_or_perl_
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ fi
|
||||
require_acl_
|
||||
|
||||
# Skip this test if cp was built without ACL support:
|
||||
grep '^#define USE_ACL 0' $CONFIG_HEADER > /dev/null &&
|
||||
grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null ||
|
||||
skip_test_ "insufficient ACL support"
|
||||
|
||||
mkdir -p a b || framework_failure
|
||||
|
||||
56
tests/cp/capability
Executable file
56
tests/cp/capability
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
# Ensure cp --preserves copies capabilities
|
||||
|
||||
# Copyright (C) 2010 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
ls --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
require_root_
|
||||
working_umask_or_skip_
|
||||
|
||||
|
||||
grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \
|
||||
|| skip_test_ "configured without libcap support"
|
||||
|
||||
(setcap --help) 2>&1 |grep 'usage: setcap' > /dev/null \
|
||||
|| skip_test_ "setcap utility not found"
|
||||
(getcap --help) 2>&1 |grep 'usage: getcap' > /dev/null \
|
||||
|| skip_test_ "getcap utility not found"
|
||||
|
||||
|
||||
touch file || framework_failure
|
||||
chown $NON_ROOT_USERNAME file || framework_failure
|
||||
|
||||
setcap 'cap_net_bind_service=ep' file ||
|
||||
skip_test_ "setcap doesn't work"
|
||||
getcap file | grep cap_net_bind_service >/dev/null ||
|
||||
skip_test_ "getcap doesn't work"
|
||||
|
||||
cp --preserve=xattr file copy1 || fail=1
|
||||
|
||||
# Before coreutils 8.5 the capabilities would not be preserved,
|
||||
# as the owner was set _after_ copying xattrs, thus clearing any capabilities.
|
||||
cp --preserve=all file copy2 || fail=1
|
||||
|
||||
for file in copy1 copy2; do
|
||||
getcap $file | grep cap_net_bind_service >/dev/null || fail=1
|
||||
done
|
||||
|
||||
Exit $fail
|
||||
@@ -48,60 +48,72 @@ ls -Z f | grep $ctx || fail=1
|
||||
|
||||
# Create a file system, then mount it with the context=... option.
|
||||
dd if=/dev/zero of=blob bs=8192 count=200 > /dev/null 2>&1 \
|
||||
|| framework_failure
|
||||
mkdir mnt || framework_failure
|
||||
|| skip=1
|
||||
mkdir mnt || skip=1
|
||||
mkfs -t ext2 -F blob ||
|
||||
skip_test_ "failed to create an ext2 file system"
|
||||
|
||||
mount -oloop,context=$ctx blob mnt || framework_failure
|
||||
mount -oloop,context=$ctx blob mnt || skip=1
|
||||
test $skip = 1 \
|
||||
&& skip_test_ "insufficient mount/ext2 support"
|
||||
|
||||
cd mnt || framework_failure
|
||||
|
||||
echo > f || framework_failure
|
||||
|
||||
echo > g || framework_failure
|
||||
|
||||
|
||||
# /bin/cp from coreutils-6.7-3.fc7 would fail this test by letting cp
|
||||
# succeed (giving no diagnostics), yet leaving the destination file empty.
|
||||
cp -a f g 2>err || fail=1
|
||||
test -s g || fail=1 # The destination file must not be empty.
|
||||
test -s err && fail=1 # There must be no stderr output.
|
||||
|
||||
rm -f g err
|
||||
echo > g
|
||||
|
||||
# =====================================================
|
||||
# Here, we expect cp to fail, because it cannot set the SELinux
|
||||
# security context through NFS or a mount with fixed context.
|
||||
cp --preserve=context f g 2> out && fail=1
|
||||
|
||||
# Here, we *do* expect the destination to be empty.
|
||||
test -s g && fail=1
|
||||
|
||||
# Here, we expect cp to succeed and not warn with "Operation not supported"
|
||||
rm -f g
|
||||
echo > g
|
||||
# Check if -a option doesn't silence --preserve=context option diagnostics
|
||||
cp -a --preserve=context f g 2> out2 && fail=1
|
||||
cp --preserve=all f g 2>err || fail=1
|
||||
test -s g || fail=1
|
||||
grep "Operation not supported" err && fail=1
|
||||
|
||||
# Here, we *do* expect the destination to be empty.
|
||||
test -s g && fail=1
|
||||
# =====================================================
|
||||
# The same as above except destination does not exist
|
||||
rm -f g
|
||||
cp --preserve=all f g 2>err || fail=1
|
||||
test -s g || fail=1
|
||||
grep "Operation not supported" err && fail=1
|
||||
|
||||
# An alternative to the current approach would be to run in a confined
|
||||
# An alternative to the following approach would be to run in a confined
|
||||
# domain (maybe creating/loading it) that lacks the required permissions
|
||||
# to the file type.
|
||||
# Note: this test could also be run by a regular (non-root) user in an
|
||||
# NFS mounted directory. When doing that, I get this diagnostic:
|
||||
# cp: failed to set the security context of `g' to `system_u:object_r:nfs_t': \
|
||||
# Operation not supported
|
||||
sed "s/ .g' to .*//" out > k
|
||||
mv k out
|
||||
sed "s/ .g' to .*//" out2 > k
|
||||
mv k out2
|
||||
|
||||
cat <<\EOF > exp || fail=1
|
||||
cat <<\EOF > exp || framework_failure=1
|
||||
cp: failed to set the security context of
|
||||
EOF
|
||||
|
||||
rm -f g
|
||||
echo > g
|
||||
# =====================================================
|
||||
# Here, we expect cp to fail, because it cannot set the SELinux
|
||||
# security context through NFS or a mount with fixed context.
|
||||
cp --preserve=context f g 2> out && fail=1
|
||||
# Here, we *do* expect the destination to be empty.
|
||||
test -s g && fail=1
|
||||
sed "s/ .g' to .*//" out > k
|
||||
mv k out
|
||||
compare out exp || fail=1
|
||||
|
||||
rm -f g
|
||||
echo > g
|
||||
# Check if -a option doesn't silence --preserve=context option diagnostics
|
||||
cp -a --preserve=context f g 2> out2 && fail=1
|
||||
# Here, we *do* expect the destination to be empty.
|
||||
test -s g && fail=1
|
||||
sed "s/ .g' to .*//" out2 > k
|
||||
mv k out2
|
||||
compare out2 exp || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
@@ -28,65 +28,86 @@ fi
|
||||
require_root_
|
||||
|
||||
cwd=`pwd`
|
||||
cleanup_() { cd /; umount "$cwd/mnt"; }
|
||||
cleanup_() { cd /; umount "$cwd/noxattr"; umount "$cwd/xattr"; }
|
||||
|
||||
skip=0
|
||||
# Create a file system without user xattr support, then mount it.
|
||||
dd if=/dev/zero of=blob bs=8192 count=200 > /dev/null 2>&1 \
|
||||
|| skip=1
|
||||
mkdir mnt || skip=1
|
||||
mkfs -t ext2 -F blob ||
|
||||
skip_test_ "failed to create ext2 file system"
|
||||
|
||||
mount -oloop,nouser_xattr blob mnt || skip=1
|
||||
echo test > mnt/f || skip=1
|
||||
test -s mnt/f || skip=1
|
||||
# Mount an ext2 loopback file system at $WHERE with $OPTS
|
||||
make_fs() {
|
||||
where="$1"
|
||||
opts="$2"
|
||||
|
||||
test $skip = 1 \
|
||||
&& skip_test_ "insufficient mount/ext2 support"
|
||||
fs="$where.bin"
|
||||
|
||||
dd if=/dev/zero of="$fs" bs=8192 count=200 > /dev/null 2>&1 \
|
||||
|| skip=1
|
||||
mkdir "$where" || skip=1
|
||||
mkfs -t ext2 -F "$fs" ||
|
||||
skip_test_ "failed to create ext2 file system"
|
||||
mount -oloop,$opts "$fs" "$where" || skip=1
|
||||
echo test > "$where"/f || skip=1
|
||||
test -s "$where"/f || skip=1
|
||||
|
||||
test $skip = 1 &&
|
||||
skip_test_ "insufficient mount/ext2 support"
|
||||
}
|
||||
|
||||
make_fs noxattr nouser_xattr
|
||||
make_fs xattr user_xattr
|
||||
|
||||
# testing xattr name-value pair
|
||||
xattr_name="user.foo"
|
||||
xattr_value="bar"
|
||||
xattr_pair="$xattr_name=\"$xattr_value\""
|
||||
|
||||
echo test > a || framework_failure
|
||||
getfattr -d a >out_a || skip_test_ "failed to get xattr of file"
|
||||
echo test > xattr/a || framework_failure
|
||||
getfattr -d xattr/a >out_a || skip_test_ "failed to get xattr of file"
|
||||
grep -F "$xattr_pair" out_a >/dev/null && framework_failure
|
||||
setfattr -n "$xattr_name" -v "$xattr_value" a >out_a \
|
||||
setfattr -n "$xattr_name" -v "$xattr_value" xattr/a >out_a \
|
||||
|| skip_test_ "failed to set xattr of file"
|
||||
getfattr -d a >out_a || skip_test_ "failed to get xattr of file"
|
||||
getfattr -d xattr/a >out_a || skip_test_ "failed to get xattr of file"
|
||||
grep -F "$xattr_pair" out_a >/dev/null \
|
||||
|| skip_test_ "failed to set xattr of file"
|
||||
|
||||
|
||||
# This should pass without diagnostics
|
||||
cp -a a mnt/ 2>err || fail=1
|
||||
test -s mnt/a || fail=1 # destination file must not be empty
|
||||
cp -a xattr/a noxattr/ 2>err || fail=1
|
||||
test -s noxattr/a || fail=1 # destination file must not be empty
|
||||
test -s err && fail=1 # there must be no stderr output
|
||||
|
||||
rm -f err mnt/a
|
||||
rm -f err noxattr/a
|
||||
|
||||
# This should pass without diagnostics
|
||||
cp --preserve=all a mnt/ 2>err || fail=1
|
||||
test -s mnt/a || fail=1 # destination file must not be empty
|
||||
# This should pass without diagnostics (new file)
|
||||
cp --preserve=all xattr/a noxattr/ 2>err || fail=1
|
||||
test -s noxattr/a || fail=1 # destination file must not be empty
|
||||
test -s err && fail=1 # there must be no stderr output
|
||||
|
||||
rm -f err mnt/a
|
||||
# This should pass without diagnostics (existing file)
|
||||
cp --preserve=all xattr/a noxattr/ 2>err || fail=1
|
||||
test -s noxattr/a || fail=1 # destination file must not be empty
|
||||
test -s err && fail=1 # there must be no stderr output
|
||||
|
||||
rm -f err noxattr/a
|
||||
|
||||
# This should fail with coresponding diagnostics
|
||||
cp -a --preserve=xattr a mnt/ 2>err && fail=1
|
||||
cat <<\EOF > exp || fail=1
|
||||
cp: setting attributes for `mnt/a': Operation not supported
|
||||
cp -a --preserve=xattr xattr/a noxattr/ 2>err && fail=1
|
||||
if grep '^#define USE_XATTR 1' $CONFIG_HEADER > /dev/null; then
|
||||
cat <<\EOF > exp
|
||||
cp: setting attributes for `noxattr/a': Operation not supported
|
||||
EOF
|
||||
else
|
||||
cat <<\EOF > exp
|
||||
cp: cannot preserve extended attributes, cp is built without xattr support
|
||||
EOF
|
||||
fi
|
||||
|
||||
compare err exp || fail=1
|
||||
|
||||
rm -f err mnt/a
|
||||
rm -f err noxattr/a
|
||||
|
||||
# This should pass without diagnostics
|
||||
mv a mnt/ 2>err || fail=1
|
||||
test -s mnt/a || fail=1 # destination file must not be empty
|
||||
test -s err && fail=1 # there must be no stderr output
|
||||
mv xattr/a noxattr/ 2>err || fail=1
|
||||
test -s noxattr/a || fail=1 # destination file must not be empty
|
||||
test -s err && fail=1 # there must be no stderr output
|
||||
|
||||
Exit $fail
|
||||
|
||||
@@ -23,8 +23,8 @@ fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
|
||||
grep '^#define HAVE_UTIMENSAT' "$CONFIG_HEADER" > /dev/null ||
|
||||
grep '^#define HAVE_LUTIMES' "$CONFIG_HEADER" > /dev/null ||
|
||||
grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null ||
|
||||
grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null ||
|
||||
skip_test_ 'this system lacks the utimensat function'
|
||||
|
||||
ln -s no-such dangle || framework_failure
|
||||
|
||||
@@ -42,17 +42,17 @@ device=$(df -P --local . | tail -n1 | cut -d' ' -f1) ||
|
||||
dev_size=$(get_device_size "$device") ||
|
||||
skip_test_ "failed to determine size of $device"
|
||||
|
||||
# Don't use shell arithimetic as older version of dash use longs
|
||||
# Don't use shell arithmetic as older versions of dash use longs
|
||||
DEV_OFLOW=$(expr $dev_size + 1)
|
||||
|
||||
timeout 1 dd bs=1 skip=$DEV_OFLOW count=0 status=noxfer < "$device" 2> err
|
||||
timeout 10 dd bs=1 skip=$DEV_OFLOW count=0 status=noxfer < "$device" 2> err
|
||||
test "$?" = "1" || fail=1
|
||||
echo "dd: \`standard input': cannot skip: Invalid argument
|
||||
0+0 records in
|
||||
0+0 records out" > err_ok || framework_failure
|
||||
compare err_ok err || fail=1
|
||||
|
||||
timeout 1 dd bs=1 seek=$DEV_OFLOW count=0 status=noxfer > "$device" 2> err
|
||||
timeout 10 dd bs=1 seek=$DEV_OFLOW count=0 status=noxfer > "$device" 2> err
|
||||
test "$?" = "1" || fail=1
|
||||
echo "dd: \`standard output': cannot seek: Invalid argument
|
||||
0+0 records in
|
||||
|
||||
@@ -22,7 +22,7 @@ else
|
||||
as_unset=false
|
||||
fi
|
||||
|
||||
envvar_check_failed=0
|
||||
envvar_check_fail=0
|
||||
vars='
|
||||
_POSIX2_VERSION
|
||||
BLOCKSIZE
|
||||
@@ -31,6 +31,7 @@ vars='
|
||||
COLUMNS
|
||||
DF_BLOCK_SIZE
|
||||
DU_BLOCK_SIZE
|
||||
LANGUAGE
|
||||
LS_BLOCK_SIZE
|
||||
LS_COLORS
|
||||
POSIXLY_CORRECT
|
||||
@@ -48,7 +49,7 @@ do
|
||||
if eval test \"\${$var+set}\" = set; then
|
||||
echo "$0: the $var environment variable is set --" \
|
||||
' unset it and rerun this test' >&2
|
||||
envvar_check_failed=1
|
||||
envvar_check_fail=1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ fi
|
||||
. $srcdir/test-lib.sh
|
||||
require_root_
|
||||
|
||||
grep '^#define HAVE_CAP 1$' $CONFIG_HEADER > /dev/null \
|
||||
grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \
|
||||
|| skip_test_ "configured without libcap support"
|
||||
|
||||
(setcap --help) 2>&1 |grep 'usage: setcap' > /dev/null \
|
||||
@@ -59,7 +59,7 @@ for ex in '' ex=:; do
|
||||
dir:
|
||||
\e[${code}mcap_neg\e[0m
|
||||
cap_pos
|
||||
\e[m" > out_ok || framework_failure
|
||||
" > out_ok || framework_failure
|
||||
|
||||
compare out out_ok || fail=1
|
||||
done
|
||||
|
||||
@@ -29,7 +29,7 @@ touch $long_name || framework_failure
|
||||
e='\33'
|
||||
color_code='0;31;42'
|
||||
c_pre="$e[0m$e[${color_code}m"
|
||||
c_post="$e[0m$e[K\n$e[m"
|
||||
c_post="$e[0m$e[K\n"
|
||||
printf "$c_pre$long_name$c_post\n" > exp || framework_failure
|
||||
|
||||
env TERM=xterm COLUMNS=80 LS_COLORS="*.foo=$color_code" TIME_STYLE=+T \
|
||||
|
||||
@@ -36,7 +36,6 @@ chmod o+t sticky || framework_failure
|
||||
|
||||
ls --color=always > out || fail=1
|
||||
cat -A out > o1 || fail=1
|
||||
echo >> o1 || fail=1
|
||||
mv o1 out || fail=1
|
||||
|
||||
cat <<\EOF > exp || fail=1
|
||||
@@ -44,7 +43,6 @@ cat <<\EOF > exp || fail=1
|
||||
^[[34;42mother-writable^[[0m$
|
||||
out$
|
||||
^[[37;44msticky^[[0m$
|
||||
^[[m
|
||||
EOF
|
||||
|
||||
compare out exp || fail=1
|
||||
@@ -56,7 +54,6 @@ rm exp
|
||||
|
||||
LS_COLORS="ow=:" ls --color=always > out || fail=1
|
||||
cat -A out > o1 || fail=1
|
||||
echo >> o1 || fail=1
|
||||
mv o1 out || fail=1
|
||||
|
||||
cat <<\EOF > exp || fail=1
|
||||
@@ -64,7 +61,6 @@ cat <<\EOF > exp || fail=1
|
||||
^[[01;34mother-writable^[[0m$
|
||||
out$
|
||||
^[[37;44msticky^[[0m$
|
||||
^[[m
|
||||
EOF
|
||||
|
||||
compare out exp || fail=1
|
||||
|
||||
88
tests/ls/color-norm
Executable file
88
tests/ls/color-norm
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/bin/sh
|
||||
# Ensure "ls --color" properly colors "normal" text and files.
|
||||
# I.E. that it uses NORMAL to style non file name output and
|
||||
# file names with no associated color (unless FILE is also set).
|
||||
|
||||
# Copyright (C) 2010 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
ls --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
|
||||
# Don't let a different umask perturb the results.
|
||||
umask 22
|
||||
|
||||
# Output time as something constant
|
||||
export TIME_STYLE="+norm"
|
||||
|
||||
# helper to to strip ls columns up to "norm" time
|
||||
qls() { sed 's/-r.*norm/norm/'; }
|
||||
|
||||
touch exe || framework_failure
|
||||
chmod u+x exe || framework_failure
|
||||
touch nocolor || framework_failure
|
||||
|
||||
TCOLORS="no=7:ex=01;32"
|
||||
|
||||
# Non coloured files inherit NORMAL attributes
|
||||
LS_COLORS=$TCOLORS ls -gGU --color exe nocolor | qls >> out || fail=1
|
||||
LS_COLORS=$TCOLORS ls -xU --color exe nocolor >> out || fail=1
|
||||
LS_COLORS=$TCOLORS ls -gGU --color nocolor exe | qls >> out || fail=1
|
||||
LS_COLORS=$TCOLORS ls -xU --color nocolor exe >> out || fail=1
|
||||
|
||||
# NORMAL does not override FILE though
|
||||
LS_COLORS=$TCOLORS:fi=1 ls -gGU --color nocolor exe | qls >> out || fail=1
|
||||
|
||||
# Support uncolored ordinary files that do _not_ inherit from NORMAL.
|
||||
# Note there is a redundant RESET output before a non colored
|
||||
# file in this case which may be removed in future.
|
||||
LS_COLORS=$TCOLORS:fi= ls -gGU --color nocolor exe | qls >> out || fail=1
|
||||
LS_COLORS=$TCOLORS:fi=0 ls -gGU --color nocolor exe | qls >> out || fail=1
|
||||
|
||||
# A caveat worth noting is that commas (-m), indicator chars (-F)
|
||||
# and the "total" line, do not currently use NORMAL attributes
|
||||
LS_COLORS=$TCOLORS ls -mFU --color nocolor exe >> out || fail=1
|
||||
|
||||
# Ensure no coloring is done unless enabled
|
||||
LS_COLORS=$TCOLORS ls -gGU nocolor exe | qls >> out || fail=1
|
||||
|
||||
cat -A out > out.display || framework_failure
|
||||
mv out.display out || framework_failure
|
||||
|
||||
cat <<\EOF > exp || framework_failure
|
||||
^[[0m^[[7mnorm ^[[m^[[01;32mexe^[[0m$
|
||||
^[[7mnorm nocolor^[[0m$
|
||||
^[[0m^[[7m^[[m^[[01;32mexe^[[0m ^[[7mnocolor^[[0m$
|
||||
^[[0m^[[7mnorm nocolor^[[0m$
|
||||
^[[7mnorm ^[[m^[[01;32mexe^[[0m$
|
||||
^[[0m^[[7mnocolor^[[0m ^[[7m^[[m^[[01;32mexe^[[0m$
|
||||
^[[0m^[[7mnorm ^[[m^[[1mnocolor^[[0m$
|
||||
^[[7mnorm ^[[m^[[01;32mexe^[[0m$
|
||||
^[[0m^[[7mnorm ^[[m^[[mnocolor^[[0m$
|
||||
^[[7mnorm ^[[m^[[01;32mexe^[[0m$
|
||||
^[[0m^[[7mnorm ^[[m^[[0mnocolor^[[0m$
|
||||
^[[7mnorm ^[[m^[[01;32mexe^[[0m$
|
||||
^[[0m^[[7mnocolor^[[0m, ^[[7m^[[m^[[01;32mexe^[[0m*$
|
||||
norm nocolor$
|
||||
norm exe$
|
||||
EOF
|
||||
|
||||
compare out exp || fail=1
|
||||
|
||||
Exit $fail
|
||||
@@ -36,8 +36,7 @@ cat <<\EOF > exp-err || framework_failure
|
||||
ls: loop/sub: not listing already-listed directory
|
||||
EOF
|
||||
|
||||
|
||||
timeout 1 ls -RL loop 2>err > out
|
||||
timeout 10 ls -RL loop >out 2>err
|
||||
# Ensure that ls exits with status 2 upon detecting a cycle
|
||||
test $? = 2 || fail=1
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ code_mh='44;37'
|
||||
code_ex='01;32'
|
||||
code_png='01;35'
|
||||
c0=$(printf '\033[0m')
|
||||
c_end=$(printf '\033[m')
|
||||
c_mh=$(printf '\033[%sm' $code_mh)
|
||||
c_ex=$(printf '\033[%sm' $code_ex)
|
||||
c_png=$(printf '\033[%sm' $code_png)
|
||||
@@ -44,7 +43,7 @@ compare out out_ok || fail=1
|
||||
LS_COLORS="mh=$code_mh" ls -U1 --color=always file1 file2 > out || fail=1
|
||||
printf "$c0${c_mh}file1$c0
|
||||
${c_mh}file2$c0
|
||||
$c_end" > out_ok || framework_failure
|
||||
" > out_ok || framework_failure
|
||||
compare out out_ok || fail=1
|
||||
|
||||
# hard links and png (hard link coloring takes precedence)
|
||||
@@ -53,7 +52,7 @@ LS_COLORS="mh=$code_mh:*.png=$code_png" ls -U1 --color=always file1 file2.png \
|
||||
> out || fail=1
|
||||
printf "$c0${c_mh}file1$c0
|
||||
${c_mh}file2.png$c0
|
||||
$c_end" > out_ok || framework_failure
|
||||
" > out_ok || framework_failure
|
||||
compare out out_ok || fail=1
|
||||
|
||||
# hard links and exe (exe coloring takes precedence)
|
||||
@@ -63,7 +62,7 @@ LS_COLORS="mh=$code_mh:*.png=$code_png:ex=$code_ex" \
|
||||
chmod a-x file2.png || framework_failure
|
||||
printf "$c0${c_ex}file1$c0
|
||||
${c_ex}file2.png$c0
|
||||
$c_end" > out_ok || framework_failure
|
||||
" > out_ok || framework_failure
|
||||
compare out out_ok || fail=1
|
||||
|
||||
# hard links and png (hard link coloring disabled => png coloring enabled)
|
||||
@@ -71,7 +70,7 @@ LS_COLORS="mh=00:*.png=$code_png" ls -U1 --color=always file1 file2.png > out \
|
||||
|| fail=1
|
||||
printf "file1
|
||||
$c0${c_png}file2.png$c0
|
||||
$c_end" > out_ok || framework_failure
|
||||
" > out_ok || framework_failure
|
||||
compare out out_ok || fail=1
|
||||
|
||||
# hard links and png (hard link coloring not enabled explicitly => png coloring)
|
||||
@@ -79,7 +78,7 @@ LS_COLORS="*.png=$code_png" ls -U1 --color=always file1 file2.png > out \
|
||||
|| fail=1
|
||||
printf "file1
|
||||
$c0${c_png}file2.png$c0
|
||||
$c_end" > out_ok || framework_failure
|
||||
" > out_ok || framework_failure
|
||||
compare out out_ok || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
@@ -46,7 +46,6 @@ grep '^stat("x"' err && fail=1
|
||||
{
|
||||
printf '\033[0m\033[01;35mlink-to-x\033[0m@\n'
|
||||
printf '\033[01;32mx\033[0m*\n'
|
||||
printf '\033[m'
|
||||
} > exp || fail=1
|
||||
|
||||
compare out exp || fail=1
|
||||
|
||||
@@ -29,8 +29,6 @@ fi
|
||||
# them actually run a command, we don't need root privileges
|
||||
chroot # missing argument
|
||||
test $? = 125 || fail=1
|
||||
chroot --help --version # too many options
|
||||
test $? = 125 || fail=1
|
||||
chroot --- / true # unknown option
|
||||
test $? = 125 || fail=1
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ my @Tests =
|
||||
|
||||
|
||||
# This erroneously succeeded and output `3' before 2.0.12.
|
||||
['fail-a', '3 + -', {ERR => "$prog: non-numeric argument\n"},
|
||||
['fail-a', '3 + -', {ERR => "$prog: non-integer argument\n"},
|
||||
{EXIT => 2}],
|
||||
|
||||
# This erroneously succeeded before 5.3.1.
|
||||
|
||||
@@ -43,9 +43,35 @@ expected_failure_status_dir=2
|
||||
expected_failure_status_ls=2
|
||||
expected_failure_status_vdir=2
|
||||
|
||||
expected_failure_status_cmp=2
|
||||
expected_failure_status_zcmp=2
|
||||
expected_failure_status_sdiff=2
|
||||
expected_failure_status_diff3=2
|
||||
expected_failure_status_diff=2
|
||||
expected_failure_status_zdiff=2
|
||||
expected_failure_status_zgrep=2
|
||||
expected_failure_status_zegrep=2
|
||||
expected_failure_status_zfgrep=2
|
||||
|
||||
expected_failure_status_grep=2
|
||||
expected_failure_status_egrep=2
|
||||
expected_failure_status_fgrep=2
|
||||
|
||||
test "$built_programs" \
|
||||
|| { echo "$this_test: no programs built!?!" 1>&2; Exit 1; }
|
||||
|| fail_ "built_programs not specified!?!"
|
||||
|
||||
test "$VERSION" \
|
||||
|| fail_ "set envvar VERSION; it is required for a PATH sanity-check"
|
||||
|
||||
# Extract version from --version output of the first program
|
||||
for i in $built_programs; do
|
||||
v=$(env $i --version | sed -n '1s/.* //p;q')
|
||||
break
|
||||
done
|
||||
|
||||
# Ensure that it matches $VERSION.
|
||||
test "x$v" = "x$VERSION" \
|
||||
|| fail_ "--version-\$VERSION mismatch"
|
||||
|
||||
for lang in C fr da; do
|
||||
for i in $built_programs; do
|
||||
@@ -90,6 +116,10 @@ for lang in C fr da; do
|
||||
done
|
||||
done
|
||||
|
||||
bigZ_in=bigZ-in.Z
|
||||
zin=zin.gz
|
||||
zin2=zin2.gz
|
||||
|
||||
tmp=tmp-$$
|
||||
tmp_in=in-$$
|
||||
tmp_in2=in2-$$
|
||||
@@ -98,89 +128,111 @@ tmp_out=out-$$
|
||||
mkdir $tmp || fail=1
|
||||
cd $tmp || fail=1
|
||||
|
||||
comm_args="$tmp_in $tmp_in"
|
||||
csplit_args="$tmp_in //"
|
||||
cut_args='-f 1'
|
||||
join_args="$tmp_in $tmp_in"
|
||||
tr_args='a a'
|
||||
comm_setup () { args="$tmp_in $tmp_in"; }
|
||||
csplit_setup () { args="$tmp_in //"; }
|
||||
cut_setup () { args='-f 1'; }
|
||||
join_setup () { args="$tmp_in $tmp_in"; }
|
||||
tr_setup () { args='a a'; }
|
||||
|
||||
chmod_args="a+x $tmp_in"
|
||||
chmod_setup () { args="a+x $tmp_in"; }
|
||||
# Punt on these.
|
||||
chgrp_args=--version
|
||||
chown_args=--version
|
||||
mkfifo_args=--version
|
||||
mknod_args=--version
|
||||
chgrp_setup () { args=--version; }
|
||||
chown_setup () { args=--version; }
|
||||
mkfifo_setup () { args=--version; }
|
||||
mknod_setup () { args=--version; }
|
||||
# Punt on uptime, since it fails (e.g., failing to get boot time)
|
||||
# on some systems, and we shouldn't let that stop `make check'.
|
||||
uptime_args=--version
|
||||
uptime_setup () { args=--version; }
|
||||
|
||||
# Create a file in the current directory, not in $TMPDIR.
|
||||
mktemp_args=mktemp.XXXX
|
||||
mktemp_setup () { args=mktemp.XXXX; }
|
||||
|
||||
cmp_args="$tmp_in $tmp_in2"
|
||||
cmp_setup () { args="$tmp_in $tmp_in2"; }
|
||||
|
||||
# Tell dd not to print the line with transfer rate and total.
|
||||
# The transfer rate would vary between runs.
|
||||
dd_args=status=noxfer
|
||||
dd_setup () { args=status=noxfer; }
|
||||
|
||||
diff_args="$tmp_in $tmp_in2"
|
||||
sdiff_args="$tmp_in $tmp_in2"
|
||||
diff3_args="$tmp_in $tmp_in2 $tmp_in2"
|
||||
cp_args="$tmp_in $tmp_in2"
|
||||
ln_args="$tmp_in ln-target"
|
||||
ginstall_args="$tmp_in $tmp_in2"
|
||||
mv_args="$tmp_in $tmp_in2"
|
||||
mkdir_args=$tmp_dir/subdir
|
||||
rmdir_args=$tmp_dir
|
||||
rm_args=$tmp_in
|
||||
shred_args=$tmp_in
|
||||
touch_args=$tmp_in2
|
||||
truncate_args="--reference=$tmp_in $tmp_in2"
|
||||
zdiff_setup () { args="$zin $zin2"; }
|
||||
zcmp_setup () { args="$zin $zin2"; }
|
||||
zcat_setup () { args=$zin; }
|
||||
gunzip_setup () { args=$zin; }
|
||||
zmore_setup () { args=$zin; }
|
||||
zless_setup () { args=$zin; }
|
||||
znew_setup () { args=$bigZ_in; }
|
||||
zforce_setup () { args=$zin; }
|
||||
zgrep_setup () { args="z $zin"; }
|
||||
zegrep_setup () { args="z $zin"; }
|
||||
zfgrep_setup () { args="z $zin"; }
|
||||
gzexe_setup () { args=$tmp_in; }
|
||||
|
||||
basename_args=$tmp_in
|
||||
dirname_args=$tmp_in
|
||||
expr_args=foo
|
||||
# We know that $tmp_in contains a "0"
|
||||
grep_setup () { args="0 $tmp_in"; }
|
||||
egrep_setup () { args="0 $tmp_in"; }
|
||||
fgrep_setup () { args="0 $tmp_in"; }
|
||||
|
||||
diff_setup () { args="$tmp_in $tmp_in2"; }
|
||||
sdiff_setup () { args="$tmp_in $tmp_in2"; }
|
||||
diff3_setup () { args="$tmp_in $tmp_in2 $tmp_in2"; }
|
||||
cp_setup () { args="$tmp_in $tmp_in2"; }
|
||||
ln_setup () { args="$tmp_in ln-target"; }
|
||||
ginstall_setup () { args="$tmp_in $tmp_in2"; }
|
||||
mv_setup () { args="$tmp_in $tmp_in2"; }
|
||||
mkdir_setup () { args=$tmp_dir/subdir; }
|
||||
rmdir_setup () { args=$tmp_dir; }
|
||||
rm_setup () { args=$tmp_in; }
|
||||
shred_setup () { args=$tmp_in; }
|
||||
touch_setup () { args=$tmp_in2; }
|
||||
truncate_setup () { args="--reference=$tmp_in $tmp_in2"; }
|
||||
|
||||
basename_setup () { args=$tmp_in; }
|
||||
dirname_setup () { args=$tmp_in; }
|
||||
expr_setup () { args=foo; }
|
||||
|
||||
# Punt, in case GNU `id' hasn't been installed yet.
|
||||
groups_args=--version
|
||||
groups_setup () { args=--version; }
|
||||
|
||||
pathchk_args=$tmp_in
|
||||
yes_args=--version
|
||||
logname_args=--version
|
||||
nohup_args=--version
|
||||
printf_args=foo
|
||||
seq_args=10
|
||||
sleep_args=0
|
||||
su_args=--version
|
||||
stdbuf_args="-oL true"
|
||||
timeout_args=--version
|
||||
pathchk_setup () { args=$tmp_in; }
|
||||
yes_setup () { args=--version; }
|
||||
logname_setup () { args=--version; }
|
||||
nohup_setup () { args=--version; }
|
||||
printf_setup () { args=foo; }
|
||||
seq_setup () { args=10; }
|
||||
sleep_setup () { args=0; }
|
||||
su_setup () { args=--version; }
|
||||
stdbuf_setup () { args="-oL true"; }
|
||||
timeout_setup () { args=--version; }
|
||||
|
||||
# I'd rather not run sync, since it spins up disks that I've
|
||||
# deliberately caused to spin down (but not unmounted).
|
||||
sync_args=--version
|
||||
sync_setup () { args=--version; }
|
||||
|
||||
test_args=foo
|
||||
test_setup () { args=foo; }
|
||||
|
||||
# This is necessary in the unusual event that there is
|
||||
# no valid entry in /etc/mtab.
|
||||
df_args=/
|
||||
df_setup () { args=/; }
|
||||
|
||||
# This is necessary in the unusual event that getpwuid (getuid ()) fails.
|
||||
id_args=-u
|
||||
id_setup () { args=-u; }
|
||||
|
||||
# Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh.
|
||||
env sleep 10m &
|
||||
kill_args=$!
|
||||
kill_setup () {
|
||||
env sleep 10m &
|
||||
args=$!
|
||||
}
|
||||
|
||||
link_args="$tmp_in link-target"
|
||||
unlink_args=$tmp_in
|
||||
link_setup () { args="$tmp_in link-target"; }
|
||||
unlink_setup () { args=$tmp_in; }
|
||||
|
||||
ln -s . slink
|
||||
readlink_args=slink
|
||||
readlink_setup () {
|
||||
ln -s . slink
|
||||
args=slink;
|
||||
}
|
||||
|
||||
stat_args=$tmp_in
|
||||
unlink_args=$tmp_in
|
||||
lbracket_args=": ]"
|
||||
stat_setup () { args=$tmp_in; }
|
||||
unlink_setup () { args=$tmp_in; }
|
||||
lbracket_setup () { args=": ]"; }
|
||||
|
||||
# Ensure that each program "works" (exits successfully) when doing
|
||||
# something more than --help or --version.
|
||||
@@ -188,13 +240,25 @@ for i in $built_programs; do
|
||||
# Skip these.
|
||||
case $i in chroot|stty|tty|false|chcon|runcon) continue;; esac
|
||||
|
||||
rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out
|
||||
echo > $tmp_in
|
||||
echo > $tmp_in2
|
||||
rm -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out $bigZ_in $zin $zin2
|
||||
echo z |gzip > $zin
|
||||
cp $zin $zin2
|
||||
cp $zin $bigZ_in
|
||||
|
||||
# This is sort of kludgey: use numbers so this is valid input for factor,
|
||||
# and two tokens so it's valid input for tsort.
|
||||
echo 2147483647 0 > $tmp_in
|
||||
# Make $tmp_in2 identical. Then, using $tmp_in and $tmp_in2 as arguments
|
||||
# to the likes of cmp and diff makes them exit successfully.
|
||||
cp $tmp_in $tmp_in2
|
||||
mkdir $tmp_dir
|
||||
# echo ================== $i
|
||||
test $i = [ && prog=lbracket || prog=$i
|
||||
eval "args=\$${prog}_args"
|
||||
if type ${prog}_setup > /dev/null 2>&1; then
|
||||
${prog}_setup
|
||||
else
|
||||
args=
|
||||
fi
|
||||
if env $i $args < $tmp_in > $tmp_out; then
|
||||
: # ok
|
||||
else
|
||||
|
||||
@@ -51,6 +51,11 @@ my @tv = (
|
||||
|
||||
['3a', '-t:', ["a:1\nb:1\n", "a:2:\nb:2:\n"], "a:1:2:\nb:1:2:\n", 0],
|
||||
|
||||
# operate on whole line (as sort does by default)
|
||||
['3b', '-t ""', ["a 1\nb 1\n", "a 1\nb 2\n"], "a 1\n", 0],
|
||||
# use NUL as the field delimiter
|
||||
['3c', '-t "\\0"', ["a\0a\n", "a\0b\n"], "a\0a\0b\n", 0],
|
||||
|
||||
# Just like -a1 and -a2 when there are no pairable lines
|
||||
['4a', '-v 1', ["a 1\n", "b\n"], "a 1\n", 0],
|
||||
['4b', '-v 2', ["a 1\n", "b\n"], "b\n", 0],
|
||||
@@ -185,6 +190,34 @@ my @tv = (
|
||||
# Before 6.10.143, this would mistakenly fail with the diagnostic:
|
||||
# join: File 1 is not in sorted order
|
||||
['chkodr-7', '-12', ["2 a\n1 b\n", ""], "", 0],
|
||||
|
||||
# Test '--header' feature
|
||||
['header-1', '--header',
|
||||
[ "ID Name\n1 A\n2 B\n", "ID Color\n1 red\n"], "ID Name Color\n1 A red\n", 0],
|
||||
|
||||
# '--header' with '--check-order' : The header line is out-of-order but the
|
||||
# actual data is in order. This join should succeed.
|
||||
['header-2', '--header --check-order',
|
||||
["ID Name\n1 A\n2 B\n", "ID Color\n2 green\n"],
|
||||
"ID Name Color\n2 B green\n", 0],
|
||||
|
||||
# '--header' with '--check-order' : The header line is out-of-order AND the
|
||||
# actual data out-of-order. This join should fail.
|
||||
['header-3', '--header --check-order',
|
||||
["ID Name\n2 B\n1 A\n", "ID Color\n2 blue\n"], "ID Name Color\n", 1,
|
||||
"$prog: file 1 is not in sorted order\n"],
|
||||
|
||||
# '--header' with specific output format '-o'.
|
||||
# output header line should respect the requested format
|
||||
['header-4', '--header -o "0,1.3,2.2"',
|
||||
["ID Group Name\n1 Foo A\n2 Bar B\n", "ID Color\n2 blue\n"],
|
||||
"ID Name Color\n2 B blue\n", 0],
|
||||
|
||||
# '--header' always outputs headers from the first file
|
||||
# even if the headers from the second file don't match
|
||||
['header-5', '--header',
|
||||
[ "ID1 Name\n1 A\n2 B\n", "ID2 Color\n1 red\n"], "ID1 Name Color\n1 A red\n", 0],
|
||||
|
||||
);
|
||||
|
||||
# Convert the above old-style test vectors to the newer
|
||||
|
||||
@@ -156,10 +156,10 @@ my @Tests =
|
||||
|
||||
# Test for a bug that was fixed in coreutils-4.5.4.
|
||||
['sl-F-color', '-F --color=always d',
|
||||
{OUT => "$e\e[01;36md$e\@\n\e[m"},
|
||||
{OUT => "$e\e[01;36md$e\@\n"},
|
||||
$slink_d, $unlink_d],
|
||||
['sl-dF-color', '-dF --color=always d',
|
||||
{OUT => "$e\e[01;36md$e\@\n\e[m"},
|
||||
{OUT => "$e\e[01;36md$e\@\n"},
|
||||
$slink_d, $unlink_d],
|
||||
|
||||
# A listing with no output should have no color sequences at all.
|
||||
@@ -169,12 +169,12 @@ my @Tests =
|
||||
|
||||
# Test for a bug fixed after coreutils-6.9.
|
||||
['sl-target', '--color=always d',
|
||||
{OUT => "$e\e[01;34mX$e\n\e[m"}, $target, $target2],
|
||||
{OUT => "$e\e[01;34mX$e\n"}, $target, $target2],
|
||||
|
||||
# Test for another bug fixed after coreutils-6.9.
|
||||
# This one bites only for a system/file system with d_type support.
|
||||
['sl-dangle', '--color=always d',
|
||||
{OUT => "$e\e[40;31;01mX$e\n\e[m"},
|
||||
{OUT => "$e\e[40;31;01mX$e\n"},
|
||||
{PRE => sub {
|
||||
mkdir 'd',0755 or die "d: $!\n";
|
||||
symlink 'non-existent', 'd/X' or die "d/X: $!\n";
|
||||
@@ -197,7 +197,7 @@ my @Tests =
|
||||
],
|
||||
['sl-dangle3', '-o --color=always l',
|
||||
{OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
|
||||
{OUT => "$e\e[40ml$e -> \e[34mnowhere$e\n\e[m"},
|
||||
{OUT => "$e\e[40ml$e -> \e[34mnowhere$e\n"},
|
||||
{PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
|
||||
push_ls_colors('ln=target:or=40:mi=34:')
|
||||
}},
|
||||
@@ -206,7 +206,7 @@ my @Tests =
|
||||
],
|
||||
['sl-dangle4', '-o --color=always l',
|
||||
{OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
|
||||
{OUT => "$e\e[36ml$e -> \e[35mnowhere$e\n\e[m"},
|
||||
{OUT => "$e\e[36ml$e -> \e[35mnowhere$e\n"},
|
||||
{PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
|
||||
push_ls_colors('ln=34:mi=35:or=36:')
|
||||
}},
|
||||
@@ -215,7 +215,7 @@ my @Tests =
|
||||
],
|
||||
['sl-dangle5', '-o --color=always l',
|
||||
{OUT_SUBST => 's/.*[0-9][0-9]:[0-9][0-9] //'},
|
||||
{OUT => "$e\e[34ml$e -> \e[35mnowhere$e\n\e[m"},
|
||||
{OUT => "$e\e[34ml$e -> \e[35mnowhere$e\n"},
|
||||
{PRE => sub {symlink 'nowhere', 'l' or die "l: $!\n";
|
||||
push_ls_colors('ln=34:mi=35:')
|
||||
}},
|
||||
@@ -227,7 +227,7 @@ my @Tests =
|
||||
# To demonstrate it, the file in question (with executable bit set)
|
||||
# must not be a command line argument.
|
||||
['color-exe1', '--color=always j',
|
||||
{OUT => "$e\e[01;32md$e\n\e[m"},
|
||||
{OUT => "$e\e[01;32md$e\n"},
|
||||
$exe_in_subdir, $remove_j],
|
||||
|
||||
# From Stéphane Chazelas.
|
||||
@@ -245,7 +245,6 @@ my @Tests =
|
||||
. "\e[30;43msetgid$e\n"
|
||||
. "\e[37;41msetuid$e\n"
|
||||
. "\e[37;44msticky$e\n"
|
||||
. "\e[m"
|
||||
},
|
||||
|
||||
{POST => sub {
|
||||
|
||||
@@ -77,14 +77,14 @@ EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now test touch's -a option.
|
||||
# Ensure that touch's -a option works.
|
||||
set -- `ls --full -lu a`
|
||||
case "$*" in
|
||||
*" $u1:00.000000000 +0000 a") ;;
|
||||
*)
|
||||
# This might be what's making HPUX 11 systems fail this test.
|
||||
cat >&2 << EOF
|
||||
A basic test of touch -a has just failed, so the subsequent
|
||||
A fundamental touch -a test has just failed, so the subsequent
|
||||
tests in this file will not be run.
|
||||
|
||||
In the output below, the date of last access for \`a' should
|
||||
|
||||
@@ -28,8 +28,6 @@ fi
|
||||
# These tests verify exact status of internal failure.
|
||||
nice -n 1 # missing command
|
||||
test $? = 125 || fail=1
|
||||
nice --help --version # too many options
|
||||
test $? = 125 || fail=1
|
||||
nice --- # unknown option
|
||||
test $? = 125 || fail=1
|
||||
nice -n 1a # invalid adjustment
|
||||
|
||||
@@ -142,6 +142,12 @@ my @Tests =
|
||||
["07f", '-n -k1.3,1.1', {IN=>"a 2\nb 1\n"}, {OUT=>"a 2\nb 1\n"}],
|
||||
["07g", '-n -k2.2,1.2', {IN=>"aa 2\nbb 1\n"}, {OUT=>"aa 2\nbb 1\n"}],
|
||||
["07h", '-k1.3nb,1.3', {IN=>" a 2\n b 1\n"}, {OUT=>" a 2\n b 1\n"}],
|
||||
# ensure obsolescent key limits are handled correctly
|
||||
["07i", '-s +0 -1', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}],
|
||||
["07j", '-s +0 -1.0', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}],
|
||||
["07k", '-s +0 -1.1', {IN=>"a c\na b\n"}, {OUT=>"a c\na b\n"}],
|
||||
["07l", '-s +0 -1.2', {IN=>"a c\na b\n"}, {OUT=>"a b\na c\n"}],
|
||||
["07m", '-s +0 -1.1b', {IN=>"a c\na b\n"}, {OUT=>"a b\na c\n"}],
|
||||
#
|
||||
# report an error for `.' without following char spec
|
||||
["08a", '-k 2.,3', {EXIT=>2},
|
||||
|
||||
38
tests/misc/sort-month
Executable file
38
tests/misc/sort-month
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
# Test sorting of abbreviated months from the locale
|
||||
|
||||
# Copyright (C) 2010 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
sort --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
|
||||
locale --version >/dev/null 2>&1 ||
|
||||
skip_test_ 'The locale utility is not present'
|
||||
|
||||
# C will be used if the locale is not present
|
||||
for LOC in "$LOCALE_FR" "$LOCALE_FR_UTF8" "ja_JP.utf8"; do
|
||||
mon="$(LC_ALL="$LOC" locale abmon 2>/dev/null);"
|
||||
smon=$(LC_ALL="$LOC" locale abmon 2>/dev/null |
|
||||
tr ';' '\n' | shuf | nl | LC_ALL="$LOC" sort -b -k2,2M |
|
||||
cut -f2 | tr '\n' ';')
|
||||
test "$mon" = "$smon" || { fail=1; break; }
|
||||
done
|
||||
|
||||
Exit $fail
|
||||
@@ -23,87 +23,87 @@ fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
|
||||
cat > in <<- _EOF_
|
||||
gcc-c++-10.fc9.tar.gz
|
||||
gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2
|
||||
glibc-2-0.1.beta1.fc10.rpm
|
||||
glibc-common-5-0.2.beta2.fc9.ebuild
|
||||
glibc-common-5-0.2b.deb
|
||||
glibc-common-11b.ebuild
|
||||
glibc-common-11-0.6rc2.ebuild
|
||||
libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz
|
||||
libstdc++-4a.fc8.tar.gz
|
||||
libstdc++-4.10.4.20040204svn.rpm
|
||||
libstdc++-devel-3.fc8.ebuild
|
||||
libstdc++-devel-3a.fc9.tar.gz
|
||||
libstdc++-devel-8.fc8.deb
|
||||
libstdc++-devel-8.6.2-0.4b.fc8
|
||||
nss_ldap-1-0.2b.fc9.tar.bz2
|
||||
nss_ldap-1-0.6rc2.fc8.tar.gz
|
||||
nss_ldap-1.0-0.1a.tar.gz
|
||||
nss_ldap-10beta1.fc8.tar.gz
|
||||
nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild
|
||||
string start 5.0.0 end of str
|
||||
string start 5.1.0 end of str
|
||||
string start 5.10.0 end of str
|
||||
string start 5.2.0 end of str
|
||||
string start 5.20.0 end of str
|
||||
string start 5.3.0 end of str
|
||||
string start 5.30.0 end of str
|
||||
string start 5.4.0 end of str
|
||||
string start 5.40.0 end of str
|
||||
string start 5.5.0 end of str
|
||||
string start 5.50.0 end of str
|
||||
string start 5.6.0 end of str
|
||||
string start 5.60.0 end of str
|
||||
string start 5.7.0 end of str
|
||||
string start 5.70.0 end of str
|
||||
string start 5.8.0 end of str
|
||||
string start 5.80.0 end of str
|
||||
string start 5.9.0 end of str
|
||||
string start 5.90.0 end of str
|
||||
_EOF_
|
||||
cat > in << _EOF_
|
||||
gcc-c++-10.fc9.tar.gz
|
||||
gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2
|
||||
glibc-2-0.1.beta1.fc10.rpm
|
||||
glibc-common-5-0.2.beta2.fc9.ebuild
|
||||
glibc-common-5-0.2b.deb
|
||||
glibc-common-11b.ebuild
|
||||
glibc-common-11-0.6rc2.ebuild
|
||||
libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz
|
||||
libstdc++-4a.fc8.tar.gz
|
||||
libstdc++-4.10.4.20040204svn.rpm
|
||||
libstdc++-devel-3.fc8.ebuild
|
||||
libstdc++-devel-3a.fc9.tar.gz
|
||||
libstdc++-devel-8.fc8.deb
|
||||
libstdc++-devel-8.6.2-0.4b.fc8
|
||||
nss_ldap-1-0.2b.fc9.tar.bz2
|
||||
nss_ldap-1-0.6rc2.fc8.tar.gz
|
||||
nss_ldap-1.0-0.1a.tar.gz
|
||||
nss_ldap-10beta1.fc8.tar.gz
|
||||
nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild
|
||||
string start 5.0.0 end of str
|
||||
string start 5.1.0 end of str
|
||||
string start 5.10.0 end of str
|
||||
string start 5.2.0 end of str
|
||||
string start 5.20.0 end of str
|
||||
string start 5.3.0 end of str
|
||||
string start 5.30.0 end of str
|
||||
string start 5.4.0 end of str
|
||||
string start 5.40.0 end of str
|
||||
string start 5.5.0 end of str
|
||||
string start 5.50.0 end of str
|
||||
string start 5.6.0 end of str
|
||||
string start 5.60.0 end of str
|
||||
string start 5.7.0 end of str
|
||||
string start 5.70.0 end of str
|
||||
string start 5.8.0 end of str
|
||||
string start 5.80.0 end of str
|
||||
string start 5.9.0 end of str
|
||||
string start 5.90.0 end of str
|
||||
_EOF_
|
||||
|
||||
cat > exp <<- _EOF_
|
||||
gcc-c++-10.fc9.tar.gz
|
||||
gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2
|
||||
glibc-2-0.1.beta1.fc10.rpm
|
||||
glibc-common-5-0.2.beta2.fc9.ebuild
|
||||
glibc-common-5-0.2b.deb
|
||||
glibc-common-11b.ebuild
|
||||
glibc-common-11-0.6rc2.ebuild
|
||||
libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz
|
||||
libstdc++-4a.fc8.tar.gz
|
||||
libstdc++-4.10.4.20040204svn.rpm
|
||||
libstdc++-devel-3.fc8.ebuild
|
||||
libstdc++-devel-3a.fc9.tar.gz
|
||||
libstdc++-devel-8.fc8.deb
|
||||
libstdc++-devel-8.6.2-0.4b.fc8
|
||||
nss_ldap-1-0.2b.fc9.tar.bz2
|
||||
nss_ldap-1-0.6rc2.fc8.tar.gz
|
||||
nss_ldap-1.0-0.1a.tar.gz
|
||||
nss_ldap-10beta1.fc8.tar.gz
|
||||
nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild
|
||||
string start 5.0.0 end of str
|
||||
string start 5.1.0 end of str
|
||||
string start 5.2.0 end of str
|
||||
string start 5.3.0 end of str
|
||||
string start 5.4.0 end of str
|
||||
string start 5.5.0 end of str
|
||||
string start 5.6.0 end of str
|
||||
string start 5.7.0 end of str
|
||||
string start 5.8.0 end of str
|
||||
string start 5.9.0 end of str
|
||||
string start 5.10.0 end of str
|
||||
string start 5.20.0 end of str
|
||||
string start 5.30.0 end of str
|
||||
string start 5.40.0 end of str
|
||||
string start 5.50.0 end of str
|
||||
string start 5.60.0 end of str
|
||||
string start 5.70.0 end of str
|
||||
string start 5.80.0 end of str
|
||||
string start 5.90.0 end of str
|
||||
_EOF_
|
||||
cat > exp << _EOF_
|
||||
gcc-c++-10.fc9.tar.gz
|
||||
gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2
|
||||
glibc-2-0.1.beta1.fc10.rpm
|
||||
glibc-common-5-0.2.beta2.fc9.ebuild
|
||||
glibc-common-5-0.2b.deb
|
||||
glibc-common-11b.ebuild
|
||||
glibc-common-11-0.6rc2.ebuild
|
||||
libstdc++-0.5.8.11-0.7rc2.fc10.tar.gz
|
||||
libstdc++-4a.fc8.tar.gz
|
||||
libstdc++-4.10.4.20040204svn.rpm
|
||||
libstdc++-devel-3.fc8.ebuild
|
||||
libstdc++-devel-3a.fc9.tar.gz
|
||||
libstdc++-devel-8.fc8.deb
|
||||
libstdc++-devel-8.6.2-0.4b.fc8
|
||||
nss_ldap-1-0.2b.fc9.tar.bz2
|
||||
nss_ldap-1-0.6rc2.fc8.tar.gz
|
||||
nss_ldap-1.0-0.1a.tar.gz
|
||||
nss_ldap-10beta1.fc8.tar.gz
|
||||
nss_ldap-10.11.8.6.20040204cvs.fc10.ebuild
|
||||
string start 5.0.0 end of str
|
||||
string start 5.1.0 end of str
|
||||
string start 5.2.0 end of str
|
||||
string start 5.3.0 end of str
|
||||
string start 5.4.0 end of str
|
||||
string start 5.5.0 end of str
|
||||
string start 5.6.0 end of str
|
||||
string start 5.7.0 end of str
|
||||
string start 5.8.0 end of str
|
||||
string start 5.9.0 end of str
|
||||
string start 5.10.0 end of str
|
||||
string start 5.20.0 end of str
|
||||
string start 5.30.0 end of str
|
||||
string start 5.40.0 end of str
|
||||
string start 5.50.0 end of str
|
||||
string start 5.60.0 end of str
|
||||
string start 5.70.0 end of str
|
||||
string start 5.80.0 end of str
|
||||
string start 5.90.0 end of str
|
||||
_EOF_
|
||||
|
||||
sort --sort=version -o out in || fail=1
|
||||
compare exp out || fail=1
|
||||
|
||||
@@ -24,7 +24,7 @@ fi
|
||||
. $srcdir/test-lib.sh
|
||||
|
||||
# no timeout
|
||||
timeout 1 true || fail=1
|
||||
timeout 10 true || fail=1
|
||||
|
||||
# no timeout (suffix check)
|
||||
timeout 1d true || fail=1
|
||||
@@ -33,21 +33,26 @@ timeout 1d true || fail=1
|
||||
timeout 0 true || fail=1
|
||||
|
||||
# exit status propagation
|
||||
timeout 1 false && fail=1
|
||||
timeout 1 sh -c 'exit 2'
|
||||
timeout 10 sh -c 'exit 2'
|
||||
test $? = 2 || fail=1
|
||||
|
||||
# timeout
|
||||
timeout 1 sleep 2
|
||||
timeout 1 sleep 10
|
||||
test $? = 124 || fail=1
|
||||
|
||||
# kill delay. Note once the initial timeout triggers,
|
||||
# the exit status will be 124 even if the command
|
||||
# exits on its own accord.
|
||||
timeout -s0 -k1 1 sleep 10
|
||||
test $? = 124 && fail=1
|
||||
|
||||
# Ensure `timeout` is immune to parent's SIGCHLD handler
|
||||
# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
|
||||
(
|
||||
# ash doesn't support "trap '' CHLD"; it knows only signal numbers.
|
||||
sig=`"$abs_top_builddir/src/kill" -l CHLD 2>/dev/null` && trap '' $sig
|
||||
|
||||
exec timeout 1 true
|
||||
exec timeout 10 true
|
||||
) || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
@@ -27,14 +27,14 @@ getlimits_
|
||||
|
||||
# internal errors are 125, distinct from execution failure
|
||||
|
||||
# --help and --version must be specified alone
|
||||
timeout --help --version
|
||||
test $? = 125 || fail=1
|
||||
|
||||
# invalid timeout
|
||||
timeout invalid sleep 0
|
||||
test $? = 125 || fail=1
|
||||
|
||||
# invalid kill delay
|
||||
timeout --kill-after=invalid 1 sleep 0
|
||||
test $? = 125 || fail=1
|
||||
|
||||
# invalid timeout suffix
|
||||
timeout 42D sleep 0
|
||||
test $? = 125 || fail=1
|
||||
|
||||
@@ -66,24 +66,24 @@ cp --preserve=xattr a b || fail=1
|
||||
getfattr -d b >out_b || skip_test_ "failed to get xattr of file"
|
||||
grep -F "$xattr_pair" out_b || fail=1
|
||||
|
||||
#test if --preserve=all option works
|
||||
# test if --preserve=all option works
|
||||
cp --preserve=all a c || fail=1
|
||||
getfattr -d c >out_c || skip_test_ "failed to get xattr of file"
|
||||
grep -F "$xattr_pair" out_c || fail=1
|
||||
|
||||
#test if -a option works without any diagnostics
|
||||
# cp's -a option must produce no diagnostics.
|
||||
cp -a a d 2>err && test -s err && fail=1
|
||||
getfattr -d d >out_d || skip_test_ "failed to get xattr of file"
|
||||
grep -F "$xattr_pair" out_d || fail=1
|
||||
|
||||
#test if --preserve=xattr works even for files without write access
|
||||
# test if --preserve=xattr works even for files without write access
|
||||
chmod a-w a || framework_failure
|
||||
rm -f e
|
||||
cp --preserve=xattr a e || fail=1
|
||||
getfattr -d e >out_e || skip_test_ "failed to get xattr of file"
|
||||
grep -F "$xattr_pair" out_e || fail=1
|
||||
|
||||
#Ensure that permission bits are preserved, too.
|
||||
# Ensure that permission bits are preserved, too.
|
||||
src_perm=$(stat --format=%a a)
|
||||
dst_perm=$(stat --format=%a e)
|
||||
test "$dst_perm" = "$src_perm" || fail=1
|
||||
|
||||
@@ -28,7 +28,7 @@ fi
|
||||
require_acl_
|
||||
|
||||
# Skip this test if cp was built without ACL support:
|
||||
grep '^#define USE_ACL 0' $CONFIG_HEADER > /dev/null &&
|
||||
grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null ||
|
||||
skip_test_ "insufficient ACL support"
|
||||
|
||||
cleanup_() { rm -rf "$other_partition_tmpdir"; }
|
||||
@@ -46,7 +46,7 @@ setfacl -m user:bin:rw $t1 || skip_partition=$other_partition_tmpdir
|
||||
acl1=`getfacl file` || skip_partition=.
|
||||
|
||||
test $skip_partition != none &&
|
||||
skip_test_ "'$skip' is not on a suitable file system for this test"
|
||||
skip_test_ "'$skip_partition' is not on a suitable file system for this test"
|
||||
|
||||
# move the access acl of a file
|
||||
mv file "$other_partition_tmpdir" || fail=1
|
||||
|
||||
@@ -46,23 +46,14 @@ echo a > 1 || fail=1
|
||||
|
||||
# Wait up to 2s for the buggy tail to die,
|
||||
# or for the "tail: `1' has appeared; following end of new file" output
|
||||
dead=0
|
||||
for i in $(seq 10); do
|
||||
kill -0 $pid || { dead=1; break; }
|
||||
kill -0 $pid || break
|
||||
grep 'has appeared;' out > /dev/null && break
|
||||
sleep .2
|
||||
done
|
||||
|
||||
# Fixed tail will not have aborted. Kill it.
|
||||
test $dead = 0 && kill -HUP $pid
|
||||
|
||||
wait $pid
|
||||
st=$?
|
||||
|
||||
case $st in
|
||||
129) ;;
|
||||
*) echo tail died via unexpected signal: $st; fail=1;;
|
||||
esac
|
||||
# Kill the working tail, or fail if it has already aborted
|
||||
kill $pid || fail=1
|
||||
|
||||
cat out
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ touch f || framework_failure
|
||||
|
||||
debug='---disable-inotify -s .001'
|
||||
debug=
|
||||
timeout 10 tail $debug -F f & pid=$!
|
||||
tail $debug -F f & pid=$!
|
||||
cleanup_() { kill $pid; }
|
||||
|
||||
for i in $(seq 200); do
|
||||
kill -0 $pid || break;
|
||||
@@ -36,15 +37,7 @@ for i in $(seq 200); do
|
||||
touch f
|
||||
done
|
||||
|
||||
# Fixed tail will not have aborted. Kill it.
|
||||
kill -HUP $pid
|
||||
|
||||
wait $pid
|
||||
st=$?
|
||||
|
||||
case $st in
|
||||
129) ;;
|
||||
*) echo tail died via unexpected signal: $st; fail=1;;
|
||||
esac
|
||||
# Kill the working tail, or fail if it has already aborted
|
||||
kill $pid || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
@@ -42,13 +42,13 @@ for inotify in ---disable-inotify ''; do
|
||||
|
||||
# Ensure that tail --pid=PID exits with success status when PID is dead.
|
||||
# Use an unlikely-to-be-live PID
|
||||
timeout 3 tail -f -s.1 --pid=$PID_T_MAX $inotify empty
|
||||
timeout 10 tail -f -s.1 --pid=$PID_T_MAX $inotify empty
|
||||
ret=$?
|
||||
test $ret = 124 && skip_test_ "pid $PID_T_MAX present or tail too slow"
|
||||
test $ret = 0 || fail=1
|
||||
|
||||
# Ensure tail doesn't wait for data when PID is dead
|
||||
timeout 3 tail -f -s10 --pid=$PID_T_MAX $inotify empty
|
||||
timeout 10 tail -f -s10 --pid=$PID_T_MAX $inotify empty
|
||||
test $? = 124 && fail=1
|
||||
done
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
|
||||
echo foo | timeout 2 tail -f -c3 > out || fail=1
|
||||
echo foo | timeout 10 tail -f -c3 > out || fail=1
|
||||
echo oo > exp || fail=1
|
||||
|
||||
compare out exp || fail=1
|
||||
|
||||
@@ -30,11 +30,11 @@ touch k || framework_failure
|
||||
|
||||
|
||||
for inotify in ---disable-inotify ''; do
|
||||
timeout 1 tail -s0.1 -f $inotify not_here
|
||||
timeout 10 tail -s0.1 -f $inotify not_here
|
||||
test $? = 124 && fail=1
|
||||
|
||||
if test ! -r unreadable; then # can't test this when root
|
||||
timeout 1 tail -s0.1 -f $inotify unreadable
|
||||
timeout 10 tail -s0.1 -f $inotify unreadable
|
||||
test $? = 124 && fail=1
|
||||
fi
|
||||
|
||||
|
||||
@@ -408,7 +408,10 @@ remove_tmp_()
|
||||
# Run each test from within a temporary sub-directory named after the
|
||||
# test itself, and arrange to remove it upon exception or normal exit.
|
||||
trap remove_tmp_ 0
|
||||
trap 'Exit $?' 1 2 13 15
|
||||
trap 'Exit 129' 1
|
||||
trap 'Exit 130' 2
|
||||
trap 'Exit 141' 13
|
||||
trap 'Exit 143' 15
|
||||
|
||||
cd "$t_" || error_ "failed to cd to $t_"
|
||||
|
||||
|
||||
@@ -43,13 +43,22 @@ touch -h -r dangling file || fail=1
|
||||
test -f nowhere && fail=1
|
||||
|
||||
# The remaining tests of -h require kernel support for changing symlink times.
|
||||
grep '^#define HAVE_UTIMENSAT' "$CONFIG_HEADER" > /dev/null ||
|
||||
grep '^#define HAVE_LUTIMES' "$CONFIG_HEADER" > /dev/null ||
|
||||
grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null ||
|
||||
grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null ||
|
||||
skip_test_ 'this system lacks the utimensat function'
|
||||
|
||||
# Changing time of dangling symlink is okay.
|
||||
touch -h dangling || fail=1
|
||||
test -f nowhere && fail=1
|
||||
# Skip the test if this fails, but the error text corresponds to
|
||||
# ENOSYS (possible with old kernel but new glibc).
|
||||
touch -h dangling 2> err
|
||||
case $? in
|
||||
0) test -f nowhere && fail=1
|
||||
test -s err && fail=1;;
|
||||
1) grep 'Function not implemented' err \
|
||||
&& skip_test_ 'this system lacks the utimensat function'
|
||||
fail=1;;
|
||||
*) fail=1;;
|
||||
esac
|
||||
|
||||
# Change the mtime of a symlink.
|
||||
touch -m -h -d 2009-10-10 link || fail=1
|
||||
|
||||
Reference in New Issue
Block a user