Compare commits

...

118 Commits
v8.3 ... v8.5

Author SHA1 Message Date
Jim Meyering
1d10eb8b1e version 8.5
* NEWS: Record release date.
2010-04-23 17:18:16 +02:00
Dmitry V. Levin
c0a121c9bc tests: fix exit status of signal handlers in shell scripts
The value of `$?' on entrance to signal handlers in shell scripts
cannot be relied upon, so set the exit code explicitly.

* cfg.mk (sc_always_defined_macros, sc_system_h_headers): Set
the exit code in signal handler explicitly to 128 + SIG<SIGNAL>.
* src/Makefile.am (sc_tight_scope): Likewise.
* tests/test-lib.sh: Likewise.
2010-04-23 15:44:19 +02:00
Eric Blake
c9e4ea6ee2 base64: always treat input in binary mode
Necessary for cygwin.  Technically, this patch is not correct,
in that it clobbers O_APPEND, but it is no different than any
other use of xfreopen to force binary mode, so all such uses
should be fixed at once in a later patch.

* src/base64.c (main): Open input in binary mode.
* THANKS: Update.
Reported by Yutaka Amanai.
2010-04-22 08:42:54 -06:00
Jim Meyering
819265b8be build: update gnulib submodule to latest 2010-04-21 20:05:52 +02:00
Eric Blake
a9b904a282 docs: document transformation of obsolete sort syntax
* doc/coreutils.texi (sort invocation): Mention the conversion.
2010-04-21 07:59:03 -06:00
Pádraig Brady
7dc398a30f maint: update a couple of NEWS items for the pending release
* NEWS: Mention that cp and mv from the previous release did
not support preserving extended attributes (fixed in e489fd04).
Improve the grammar for the "cp capabilities" item.
2010-04-21 07:55:38 +01:00
Pádraig Brady
8fc12909f6 sort: fix parsing of end field in obsolescent key formats
This regression was introduced in commit 224a69b5, 2009-02-24,
"sort: Fix two bugs with determining the end of field".
The specific regression being that we include 1 field too many when
an end field is specified using obsolescent key syntax (+POS -POS).

* src/sort.c (struct keyfield): Clarify the description of the eword
member, as suggested by Alan Curry.
(main): When processing obsolescent format key specifications,
normalize eword to a zero based count when no specific end char is given
for an end field. This matches what's done when keys are specified with -k.
* tests/misc/sort: Add a few more tests for the obsolescent key formats,
with test 07i being the particular failure addressed by this change.
* THANKS: Add Alan Curry who precisely identified the issue.
* NEWS: Mention the fix.
Reported by Santiago Rodríguez
2010-04-20 22:37:18 +01:00
Pádraig Brady
1777d0dfe3 cp: preserve "capabilities" when also preserving file ownership
* src/copy.c (copy_reg): Copy xattrs _after_ setting file ownership
so that capabilities are not cleared when setting ownership.
* tests/cp/capability: A new root test.
* tests/Makefile.am (root_tests): Reference the new test.
* NEWS: Mention the fix.
2010-04-16 23:02:02 +01:00
Jim Meyering
56fce1aed7 * HACKING (Add tests): Change example name, "newtest" to "new-test".
Not that anyone would confuse with something newt-related, but just
because it is more readable that way.

doc: tweak HACKING
2010-04-16 08:42:47 +02:00
Jim Meyering
36cc6ac787 doc: tweak HACKING
* HACKING (Curly braces): Tweak a sentence.  Filter a few
paragraphs through "fmt".
2010-04-16 08:21:32 +02:00
Pádraig Brady
62dd4b63c5 maint: fix build on platforms that replace strsignal
* src/Makefile.am (kill_LDADD): Add $(LIBTHREAD) so that
we link with the appropriate libraries to provide Thread Local Storage
on platforms that replace strsignal (like AIX for example).

Tested-by: Daniel Richard G. <danielg@teragram.com>
2010-04-16 00:55:43 +01:00
Pádraig Brady
3a1595a3fb tests: avoid spurious failure of ls/color-norm test
* tests/ls/color-norm: Use the "time" output by `ls -l`
to check normal style.  Previously we used the size from `ls -s`,
but the size of "empty" files can vary depending on whether
SELinux is enabled for example.
2010-04-16 00:26:21 +01:00
Jim Meyering
f8291d0ec4 doc: document our code formatting policy regarding curly braces
* HACKING (Curly braces: use judiciously): New section.
2010-04-15 18:52:41 +02:00
Jim Meyering
05bee6f116 tests: avoid spurious failure of root-only ls/capability test
* tests/ls/capability: Adjust this test not to expect the no-op escape
sequence that was removed from all other tests by 2010-01-30 commit
5d43617e, "ls --color: don't emit a final no-op escape sequence".
2010-04-14 15:48:31 +02:00
Pádraig Brady
584e38d8b3 cp: treat selinux warnings consistently
* src/copy.c (copy_reg): Suppress SELinux ENOTSUP warnings consistently
between the destination being present or not.  Previously we did
not suppress ENOTSUP messages when the destination was present.
(copy_internal): Use the same ENOTSUP supression method as
copy_reg() even though the issue was not seen in this case.
* tests/cp/cp-a-selinux: Add a test case for the issue and
group the other test cases in the file more coherently.
* tests/cp/cp-mv-enotsup-xattr: Do the same check for xattr
warnings, even though they did not have the issue.
2010-04-13 13:09:50 +01:00
Pádraig Brady
c420cfef77 doc: clarify when cp and mv output xattr warnings
The 2010-03-26 commit, 4c38625e, "doc: fix info on cp --preserve..."
was not entirely correct as cp --preserve=all does produce some
xattr warnings.

* src/copy.h: Update and clarify the comments for reduce_diagnostics
and require_preserve_{xattr,context}.
* doc/coreutils.texi (cp invocation): Update the -a and
--preserve=xattr,context options to say when and which
xattr warnings are output.
(mv invocation): Mention that some warnings are output
when preserving xattrs.
2010-04-12 10:06:11 +01:00
Pádraig Brady
be9a42e7ac doc: mention that "capabilities" are preserved by cp/mv
* doc/coreutils.texi (cp invocation): Mention that
"capabilities" are preserved when implemented using
extended attributes.
(mv invocation): Mention ACLs etc. are maintained
due to xattrs being copied.
2010-04-11 16:37:40 +01:00
Jie Liu
20a5a60c61 build: tell ./bootstrap to check for xz up-front
* bootstrap.conf (buildreq): Add xz to the list.
2010-04-11 17:09:35 +02:00
Jim Meyering
0ba945b050 tests: more syntax-checks
* gnulib: update to latest
* cfg.mk (sc_prohibit_empty_lines_at_EOF): Remove, now that it's
in gnulib's maint.mk.
(_hv_file): Override the default.
2010-04-11 11:29:00 +02:00
Jim Meyering
8c4b6ba09b maint: new syntax-check rule: prohibit empty lines at EOF
* cfg.mk (detect_empty_lines_at_EOF_): Define.
(sc_prohibit_empty_lines_at_EOF): New rule.
* .x-sc_prohibit_empty_lines_at_EOF: New file.  Exempt pr test inputs.
* Makefile.am (syntax_check_exceptions): Add it.
Pádraig Brady suggested to parse the output of tail -n1.
2010-04-10 20:26:39 +02:00
Mike Frysinger
ac6feeb9f2 dircolors: add rxvt-256color and rxvt-unicode256
* src/dircolors.hin: Add them.
2010-04-09 16:28:46 +02:00
Jim Meyering
ef5758c328 maint: ftruncate is always available, even without gnulib
Now that even MinGW provides ftruncate, we know that all
reasonable portability targets provide this function.
Remove the workaround code.  We nearly removed the gnulib
module three years ago:
  http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/9203
and it is now officially "obsolete".
* bootstrap.conf (gnulib_modules): Remove ftruncate.
* src/copy.c (copy_reg): Remove use of HAVE_FTRUNCATE and its
no-longer-used workaround code.
* src/truncate.c: Remove a comment about handling missing ftruncate.
2010-04-09 10:50:43 +02:00
James Youngman
0a9302e7f7 doc: make wc --help say how it defines a 'word'
* src/wc.c (usage): Add wc's definition of "word".
2010-04-08 23:53:12 +02:00
Jim Meyering
9e66806e28 doc: adjust a header in announcement email template
* README-release: Use Mail-Followup-To: rather than Reply-To:.
The former works more reliably, at least with Gnus.
2010-04-08 08:45:23 +02:00
Jim Meyering
f6b2f46714 tests: add a PATH-sanity-check to help-version
* tests/misc/help-version: Sync from gzip's version.
* tests/check.mk (TESTS_ENVIRONMENT): Export VERSION, as required
for new help-version test.
2010-04-07 11:47:28 +02:00
Jim Meyering
f267926f2d maint: fix a masked syntax-check violation
* m4/jm-macros.m4 (ARGMATCH_DIE): Use usage(EXIT_FAILURE), not usage(1).
* .x-sc_prohibit_magic_number_exit: Remove *.m4 exemption that was
masking the above.
2010-04-06 16:02:27 +02:00
Jim Meyering
6f6f599867 build: update gnulib submodule to latest 2010-04-06 16:02:19 +02:00
Jim Meyering
2dc09bf809 build: update gnulib submodule to latest 2010-04-05 09:03:23 +02:00
Marc Kleine-Budde
98dacf492e tail: include sys/vfs.h (if possible) when sys/statfs.h is absent
* src/tail.c [HAVE_INOTIFY && !HAVE_SYS_STATFS_H]: Include <sys/vfs.h>.
2010-04-04 09:15:07 +02:00
Jim Meyering
b48a444e35 build: update gnulib submodule to latest
* cfg.mk: Update to use new _sc_search_regexp interface.  Run this:
perl -pi -e 's/\b_prohibit_regexp\b/_sc_search_regexp/;'
  -e 's/\bmsg=/halt=/; s/\bre=/prohibit=/;' cfg.mk
and then adjust backslashes so they still line up.
2010-04-02 20:31:14 +02:00
Jim Meyering
6416762b73 doc: synchronize parts of README-release from grep's version
* README-release (FIXME): Add Reply-To, use coreutils@gnu.org
for announcements.  Update savannah-verbatim-announcement procedure.
2010-03-31 08:58:40 +02:00
Jim Meyering
a8fc4edca5 build: update gnulib submodule to latest 2010-03-29 08:28:51 +02:00
Jim Meyering
3f7091359a tests: disable new texinfo-acronym syntax-check from gnulib
* cfg.mk (local-checks-to-skip): Add new sc_texinfo_acronym, to skip it.
2010-03-29 08:28:51 +02:00
Bruno Haible
0f5dc96354 build: update after change in gnulib's lib-ignore module
* src/Makefile.am (AM_LDFLAGS): Define.  Use gnulib's new
$(IGNORE_UNUSED_LIBRARIES_CFLAGS).
2010-03-29 08:28:51 +02:00
Jim Meyering
5ef03d6c5b tests: avoid spurious sc_prohibit_test_minus_ao syntax-check failures
* tests/misc/ls-time: Change comments and diagnostics.
* tests/misc/xattr: Likewise.
2010-03-29 08:28:51 +02:00
Jim Meyering
8915368ee3 tests: fix typos in envvar-check script
* tests/envvar-check: Fix variable name typos.
Probably harmless, since no selected shell would fail to unset.
2010-03-26 16:49:48 +01:00
Pádraig Brady
b4f9559537 nice,chroot: use more standard option parsing
Related to the 2010-03-25 commit, 88d4b346,
"timeout: use more standard option parsing".
* src/nice.c (main): Don't use parse_long_options()
which is a helper for commands that don't have any
long options specific to them.
* src/chroot.c (main): Likewise.
* tests/misc/nice-fail: Remove a case that now
passes due to us accepting multiple instances of the
--help and --version options.
* tests/misc/chroot-fail: Likewise.
2010-03-26 14:31:16 +00:00
Kim Hansen
88d4b3461e timeout: use more standard option parsing
* src/timeout.c (main): Don't use parse_long_options()
which is a helper for commands that don't have any
long options specific to them.
* tests/misc/timeout-parameters: Remove a case that now
passes due to us accepting multiple instances of the
--help and --version options.
* THANKS: Add the author.

Signed-off-by: Pádraig Brady <P@draigBrady.com>
2010-03-26 14:27:54 +00:00
Pádraig Brady
4c38625ef3 doc: fix info on cp --preserve=all, which does _not_ give xattr warnings
The info docs have been inaccurate since 2009-04-17, commit 941bd482,
"mv: ignore xattr-preservation failure when not supported by filesystem"
* doc/coreutils.texi (cp invocation): Say that cp --preserve=all
does _not_ output errors when failing to copy xattrs.
2010-03-26 14:19:37 +00:00
Jim Meyering
946359f101 cfg.mk: remove comments with sed rather than cpp -fpreprocessed
* cfg.mk (_sed_remove_comments): Define, starting with gettext's
moopp sed code, but factoring it to be more understandable.
(sc_space_before_open_paren): Adapt.
Prompted by Bruno Haible's suggestion to use gettext's moopp code.
2010-03-21 12:23:16 +01:00
Jim Meyering
9f793def3c cfg.mk: fix copy-paste-o in a diagnostic
* cfg.mk (sc_space_before_open_paren): Mention cpp -fpreprocessed,
not cppi, when cpp -fpreprocessed doesn't work.
Spotted by Eric Blake.
2010-03-20 13:45:56 +01:00
Jim Meyering
628a5e16dd maint: enforce one small aspect of formatting style: space-before-"("
* cfg.mk (sc_space_before_open_paren): New rule.
2010-03-20 12:14:46 +01:00
Jim Meyering
773d15a702 maint: code formatting nit
* src/system.h (ST_NBLOCKS): Add space before paren.
2010-03-20 12:11:50 +01:00
Pádraig Brady
c872a1d8a5 maint: mbsalign: fix an edge case where we truncate too much
* gl/lib/mbsalign.c (mbsalign): Ensure the temporary destination buffer
is big enough, as it may need to be bigger than the source buffer
in the presence of single byte non printable chars.
* gl/tests/test-mbsalign.c (main): Add a test to trigger the issue.
2010-03-19 21:40:05 +00:00
Pádraig Brady
dfe0d336a0 maint: update the mbsalign module
* gl/lib/mbsalign.c (mbsalign):  Support the MBA_UNIBYTE_FALLBACK
flag which reverts to unibyte mode if one can't allocate memory
or if there are invalid multibyte characters present.
Note memory is no longer dynamically allocated in unibyte mode so
one can assume that mbsalign() will not return an error if this
flag is present.  Don't calculate twice, the number of spaces,
when centering.  Suppress a signed/unsigned comparison warning.
(ambsalign): A new wrapper function to dynamically allocate
the minimum memory required to hold the aligned string.
* gl/lib/mbsalign.h: Add the MBA_UNIBYTE_FALLBACK flag and
also document others that may be implemented in future.
(ambsalign): A prototype for the new wrapper.
* gl/tests/test-mbsalign.c (main): New test program.
* gl/modules/mbsalign-tests: A new index to reference the tests.
* .x-sc_program_name: Exclude test-mbsalign.c from this check.
2010-03-19 19:23:45 +00:00
Paolo Bonzini
3dcbcf98f4 tests: change help-version to per-program functions
* help-version: Change each *_args variable to a *_setup function.
2010-03-19 13:13:08 +01:00
Jim Meyering
dd9df4ab02 doc: tweak README-prereq again
* README-prereq: Change one more: s/coreutils/This package/
2010-03-19 11:34:15 +01:00
Jim Meyering
54158a45fa doc: make README-prereq more generic
* README-prereq: Adjust wording and reduce number of mentions of
"coreutils", so it's easier to reuse in another package: grep.
2010-03-19 10:14:46 +01:00
Eric Blake
da2f637888 rm: tweak wording about loss of data warning
* src/rm.c (usage): Update wording to make two points more
apparent: undelete is not trivial, and partial recovery should be
a consideration factor in deciding whether rm is secure enough.
Initially suggested by Reuben Thomas.
2010-03-18 15:41:59 -06:00
Ralf Wildenhues
cab29edcf1 revert "maint: mark makefile "dist-hook" target as PHONY"
* src/Makefile.am (dist-hook): Do not mark this target
as PHONY, explicitly.  Automake does it for us.
2010-03-18 21:08:07 +01:00
Eric Blake
b44d4b6b0e doc: improve ls --help's description of --escape (-b)
* src/ls.c (usage): Be more precise about how --escape (-b) works:
say "C-style escapes", not "octal escapes".  Reported by Jacky Fong.
2010-03-18 17:41:12 +01:00
Jim Meyering
d75820e516 maint: mark makefile "dist-hook" target as PHONY
* src/Makefile.am (dist-hook): Mark target as PHONY.
2010-03-18 08:32:26 +01:00
Jim Meyering
46e0137277 maint: add a space before open-paren, where lacking
* src/copy.c (copy_reg): Likewise.
* src/cut.c (main): Likewise.
* src/dd.c (main): Likewise.
* src/getlimits.c (print_int): Likewise.
* src/join.c (join): Likewise.
* src/pwd.c (logical_getcwd): Likewise.
* src/sort.c (specify_nmerge, mergefps, avoid_trashing_input): Likewise.
(merge): Likewise.
* src/uptime.c (usage): Likewise.
2010-03-17 18:28:28 +01:00
Pádraig Brady
c403c31e88 timeout: add the --kill-after option
Based on a report from Kim Hansen who wanted to
send a KILL signal to the monitored command
when `timeout` itself received a termination signal.
Rather than changing such a signal into a KILL,
we provide the more general mechanism of sending
the KILL after the specified grace period.

* src/timeout.c (cleanup): If a non zero kill delay
is specified, (re)set the alarm to that delay, after
which a KILL signal will be sent to the process group.
(usage): Mention the new option.  Separate the description
of DURATION since it's now specified in 2 places.
Clarify that the duration is an integer.
(parse_duration): A new function refactored from main(),
since this logic is now called for two parameters.
(main): Parse the -k option.
* doc/coreutils.texi (timeout invocation): Describe the
new --kill-after option and use @display rather than
@table to show the duration suffixes.  Clarify that
a duration of 0 disables the associated timeout.
* tests/misc/timeout-parameters: Check invalid --kill-after.
* tests/misc/timeout: Check a valid --kill-after works.
* NEWS: Mention the new feature.
2010-03-16 23:10:15 +00:00
Jim Meyering
4edb86215d build: update gnulib submodule to latest
The latest from gnulib once again passes all tests.
2010-03-13 14:21:16 +01:00
Jim Meyering
64bc4f20e8 revert to previous working version of gnulib
This reverts commit 0c31cdc2d1.
2010-03-13 10:31:15 +01:00
Thien-Thi Nguyen
141645d9c6 doc: use mktemp, not tempfile, in a shred usage example
* doc/coreutils.texi (shred invocation):
Use mktemp(1) instead of Debian-specific tempfile(1).
2010-03-13 08:37:01 +01:00
Jim Meyering
0c31cdc2d1 build: update gnulib submodule to latest 2010-03-12 08:39:11 +01:00
Eric Blake
4323ed2bde maint: drop *.lzma suport
* .gitignore: Remove *.lzma lines.
2010-03-11 11:55:45 -07:00
Eric Blake
c971ed9377 maint: ignore *.xz files
* .gitignore: Ignore *.xz created by 'make dist', now that we
no longer produce *.lzma.
2010-03-10 16:29:44 -07:00
Jim Meyering
998fe29301 remove: without -f, avoid unnecessary-expense/issues with euidaccess
* src/remove.c (write_protected_non_symlink): If faccessat fails,
return 1 or -1 directly, rather than falling back on euidaccess*.
2010-03-10 11:05:18 +01:00
Pádraig Brady
612c2c95c3 doc: Add an example for cutting fields separated by runs of blanks
* doc/coreutils.texi (cut invocation): Show how tr can be used
to process the input for cut in this case.
Suggestion from Dan Jacobson.
2010-03-09 00:32:07 +00:00
Pádraig Brady
a7b4fa01dd maint: rename the si_present variable in sort to iec_present
* src/sort.c: The units containing 'i' are actually IEC not SI.
2010-03-04 10:54:21 +00:00
Joey Degges
dae35bac98 sort: inform the system about our input access pattern
Tell the system that we'll access input sequentially,
so that we more efficiently process uncached files in a few cases:

Reading from faster flash devices. E.g. 21 MB/s key:
  NORMAL     31.6s (26.8 user)
  SEQUENTIAL 27.7s
  WILLNEED   27.7s

Processing in parallel with readahead when using a small 1M buffer:
  NORMAL     24.7s (21.1 user)
  SEQUENTIAL 22.7s
  WILLNEED   25.6s

A small benefit when merging:
  NORMAL     25.0s (16.9 user)
  SEQUENTIAL 24.6s (16.6 user)
  WILLNEED   38.4s (13.1 user)

Note WILLNEED is presented above for comparison to show it
has some unwanted characteristics due to its synchronous
prepopulation of the cache. It has a good benefit on a
mechanical disk @ 80MB/s and a multicore system with
competing processes:
  NORMAL     14.73s
  SEQUENTIAL 10.95s
  WILLNEED   05.22s
However the scheduling differences causing this result
are probably best explicitly managed using `nice` etc.

* m4/jm-macros.m4 (coreutils_MACROS): check for posix_fadvise().
* src/sort.c (fadvise_input): A new function to apply
the POSIX_FADV_SEQUENTIAL hint to an input stream.
(stream_open): Call the above function for all input streams.
2010-03-04 10:42:00 +00:00
Jim Meyering
168a6b6a0f tests: don't let the LANGUAGE envvar perturb tests
* tests/envvar-check (vars): Add LANGUAGE to the list of envvars
to unset.  At least in glibc (as an extension to POSIX), its value
actually trumps LC_ALL:

  $ LC_ALL=es_ES LANGUAGE=fr_FR.UTF-8 /bin/cat no-such
  /bin/cat: no-such: Aucun fichier ou dossier de ce type

but only when the default locale is not C:

  $ LC_ALL=C LANGUAGE=fr_FR.UTF-8 /bin/cat no-such
  /bin/cat: no-such: No such file or directory

Prompted by a report from Mads Kiilerich.
2010-03-04 10:46:11 +01:00
Pádraig Brady
59e2e55d0f sort: fix issues with month sorting in some locales
* src/sort.c (char fold_toupper[]): Change to unsigned
so as the correct comparisons are made in getmonth().
This fixes unibyte locales where abbreviated months
have characters that are > 0x7F, but it also works for
multibyte locales with the caveat that multibyte characters
are matched case sensitively.
With this change, the following example sorts correctly:
  $ echo -e "1 márta\n2 Feabhra" | LANG=ga_IE.utf8 sort -k2,2M
  2 Feabhra
  1 márta
* src/sort.c (inittables): Since we ignore blanks around months
in the input, don't include them when they're present in the locale.
With this change, the following example sorts correctly:
  $ echo -e "1 2月\n2 1月" | LANG=ja_JP.utf8 sort -k2,2M
  2 1月
  1 2月
* tests/misc/sort-month: A new test to exercise the above cases.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the fix.
2010-03-01 10:58:02 +00:00
Eric Blake
2590389aab bootstrap: resynchronize from gnulib
* gnulib: Update to latest.
* bootstrap: Copy from gnulib/build-aux/bootstrap.
* README-hacking: Describe how to use GNULIB_SRCDIR.
2010-02-25 09:29:46 -07:00
Eric Blake
9a6c97eb29 expr: clarify error message
* src/expr.c (eval4, eval3): Clarify that expr expects integers,
and not the broader category of numbers.
* tests/misc/expr: Update test accordingly.
Suggested by Dan Jacobson.
2010-02-25 08:54:49 -07:00
Pádraig Brady
0b5bd805bd maint: clean up the output from syntax-check rules
* cfg.mk (sc_tight_scope): Pass the -s (silent) flag to `make`
so that it doesn't report about calling sub makes.
(sc_check-AUTHORS): Likewise.
(sc_strftime_check): Don't display stderr from `info`.
* src/Makefile.am (sc_tight_scope): Don't annotate with "GEN".
(sc_check-AUTHORS): Likewise.
2010-02-19 11:41:19 +00:00
Moritz Orbach
f5268e2749 ls: fix a regression by honoring NORMAL attributes again
Output the NORMAL attribute before non file name text.
This attribute will continue into file names that would
not otherwise be colored unless FILE is also set.
The regression was introduced with commit 483297d5, 28-02-2009,
"ls --color no longer outputs unnecessary escape sequences".

* src/ls.c (set_normal_color): A new function to output the
NORMAL attribute sequence if it's enabled.
(print_current_files): Output NORMAL before printing long format info.
(print_file_name_and_frills): Output NORMAL before printing file name.
(print_color_indicator): Reset the attributes before a file name with
attributes so that NORMAL attributes will not combine with them.
(print_name_with_quoting): Ensure attributes are reset after printing
the file name if NORMAL attributes were output.
* tests/ls/color-norm: A new test for NORMAL and FILE combinations.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the fix.
Reported in https://savannah.gnu.org/bugs/?26512
2010-02-17 23:25:12 +00:00
Pádraig Brady
cba49d57da maint: fix the man page correlation tests
These checks were not being run as distcheck-hook targets
are only supported in the top-level Makefile.  Instead
these tests are now run during a syntax-check.

* cfg.mk (sc_man_file_correlation):  A new syntax check to
call the 2 existing tests to check the correlation between
the programs and man/*.[1x].
* man/Makefile.am (sc_man_file_correlation): Call the 2 existing
man page correlation tests.
(check-x-vs-1): Remove the "GEN" annotation as it's a bit verbose.
(check-programs-vs-x): Likewise.
* src/Makefile.am (all_programs.list): Exclude libstdbuf.so
from the list of programs.  This issue was not noticed as
the checks were not actually being run.
2010-02-16 15:19:40 +00:00
Pádraig Brady
a2f81776ad tests: fix an unlikely race in tail-2/inotify-hash-abuse2
* tests/tail-2/inotify-hash-abuse2: Explicitly kill the process
by using cleanup_() rather than using a timeout which may trigger
a failure on very slow systems (< 20 iterations of the loop per second).
2010-02-16 00:51:38 +00:00
Pádraig Brady
11d84c10ce doc: fix inconsistent capitalization in --help output
* src/base64.c (usage): Don't capitalize the first character
in an --option description.
* src/stdbuf.c (usage): Likewise.
* src/truncate.c (usage): Likewise.
* cfg.mk (sc_option_desc_uppercase): A new syntax check to
stop this happening in future.
* man/Makefile.am (sc_option_desc_uppercase): Ensure all
man pages are generated, then search for erroneous uppercase chars.
* src/Makefile.am (all_programs): Ensure all
commands are built so that all man pages can be generated.
2010-02-15 23:42:49 +00:00
Jim Meyering
58c98f2342 remove.c: remove three unnecessary #include directives
* src/remove.c: Don't include hash.h, hash-pjw.h or obstack.h.
They have been unused since the fts rewrite.
2010-02-15 19:26:30 +01:00
Eric Blake
7ae60bf26f build: ignore another gnulib artifact
* .gitignore: Add lib/warn-on-use.h.
2010-02-15 06:56:11 -07:00
Eric Blake
d4de2dc83a dirname: improve man page description
* doc/coreutils.texi (dirname invocation): Properly cover behavior
on directory.
* man/dirname.x: Likewise.
* THANKS: Update.
Reported by Emmanuel Lacour.
2010-02-15 06:56:07 -07:00
Pádraig Brady
45b46f4951 doc: remove extraneous periods from --help output
* src/join.c (usage): Mention "fields" rather than repeating "line"
so that it's more obvious that the fields are still parsed, and
thus -o is still honored for headers.  Also remove an extraneous
'.' reported by Stéphane Raimbault.
* src/base64.c (usage): Remove extraneous blank line and order
the options alphabetically.  Also remove an extraneous '.'
* src/chown.c (usage): Remove extraneous '.'
* src/cp.c (usage): Likewise.
* src/mktemp.c (usage): Likewise.
* src/pr.c (usage): Likewise.
* src/stat.c (usage): Likewise.
* src/uniq.c (usage): Likewise.
2010-02-11 08:01:15 +00:00
Jim Meyering
9f650d0870 doc: add a TODO item
* TODO: Consider adding a col implementation.
2010-02-10 07:25:58 +01:00
Jim Meyering
ed509250a2 copy.c: improve a comment
* src/copy.c (copy_reg): The comment about POSIXLY_CORRECT refers
only to cp, not to any other application that uses copy.c.
2010-02-07 21:02:18 +01:00
James R. Van Zandt
543696a9af doc: add a cross reference from tac's man page to "rev"
* man/tac.x: See also "rev".
2010-02-07 17:18:34 +01:00
Jim Meyering
86573d33a7 tests: include help-version test settings used by gzip and grep
* tests/misc/help-version: ...the better to keep this file in sync.
2010-02-07 17:18:02 +01:00
Jim Meyering
cea6d15720 doc: rewrite part of README-release
* README-release (Pre-release testing): Reorganize.
2010-02-07 09:10:53 +01:00
Jim Meyering
69cc8d5cb7 sync with gnulib
* gl/lib/regcomp.c.diff: Update to apply to changed version in gnulib.
* gnulib: Update submodule to latest.
2010-02-05 10:30:31 +01:00
Pádraig Brady
dd2253f49d tests: fix various timeout races
Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/277485

* tests/misc/timeout: Set all expected timeouts to 1s and all
unexpected timeouts to 10s. In this way, tests normally proceed
quickly but may delay up to 10s before reporting failures.
* tests/ls/infloop: Likewise.
* tests/tail-2/pid: Likewise.
* tests/tail-2/pipe-f: Likewise.
* tests/tail-2/wait: Likewise.
* tests/dd/skip-seek-past-dev: Likewise.
2010-02-02 15:16:40 +00:00
Ondřej Vašík
f53a0e1062 tests: cp-a-selinux: skip the test if mounting a loop device fails
* tests/cp/cp-a-selinux: Skip the test (instead of fail) if we
fail to mount a loop device (e.g., none available).
2010-02-01 16:46:34 +01:00
Pádraig Brady
628b1d5e7e maint: fix a typo in NEWS
* NEWS: s/contains/contain/
2010-02-01 15:40:44 +00:00
Pádraig Brady
f86bb6967d join: make -t '' operate on the whole line
Previously passing an empty parameter to -t would
raise an error, but now it means to treat each line
as a single field for matching.  This matches the
default operation of `sort` which is usually used
in conjunction with join.

* src/join.c (main): Set the field delimiter to '\n' if
an empty parameter is passed to -t.
(usage): Mention the operation of -t ''.
* tests/misc/join: Add 2 new tests, for the existing -t '\0'
and the new -t '' functionality.
* doc/coreutils.texi (join invocation): Mention that
join -t '' always operates on the whole line, while
join -t '\0' usually does.
* NEWS: Mention the change in behavior.
2010-02-01 15:36:56 +00:00
Assaf Gordon
819aa9eba7 join: add --header option to always output the first line
This essentially allows one to use --check-order with headings.
Note join without --check-order will already handle the common case
where headings do match in each file, however using --check-order will fail
often when the header sorts after the first line of data.

Note also that this will join header lines from each file even if
they don't match, with headings from the first file being used.

* NEWS: Mention the new option.
* doc/coreutils.texi (join invocation): Describe the new option.
* src/join.c (usage): Likewise.
(join): Join the header lines unconditionally.
* tests/misc/join: Add 5 new tests.
2010-02-01 13:57:42 +00:00
Pádraig Brady
86914603b5 maint: fix an inconsequential memory leak in join
* src/join.c (join): Refactor the code that checks for misorder
at the tail of the files.  The most significant change here is
that freeline() is called thus silencing a valgrind warning about
a definite but inconsequential memory leak.
(freeline): Make more general by doing nothing when passed NULL,
and setting freed pointers to NULL.
2010-02-01 13:52:58 +00:00
Pádraig Brady
6e8f368e07 maint: use $(CONFIG_INCLUDE) rather than the hardcoding lib/config.h
* tests/check.mk (TESTS_ENVIRONMENT): Use the generated CONFIG_INCLUDE
variable.  Note $(abs_builddir)/$(CONFIG_HEADER) also currently works,
but $(CONFIG_HEADER) is deprecated and may not be generated in future.
$(CONFIG_INCLUDE) was made available by gnulib in commit, 22970f8a,
"syntax-check: detect incorrect boolean macro values in config.h"
2010-02-01 13:32:46 +00:00
Jim Meyering
5d43617e8a ls --color: don't emit a final no-op escape sequence
* src/ls.c (main): With --color, avoid emitting the final color-
resetting escape sequence when it would be a no-op.
* tests/ls/color-clear-to-eol: Adjust expected output accordingly.
* tests/ls/color-dtype-dir: Likewise.
* tests/ls/multihardlink: Likewise.
* tests/ls/stat-free-symlinks: Likewise.
* tests/misc/ls-misc: Likewise.
* NEWS (Changes in behavior): Mention it.
C de-Avillez rebased and adapted four of the new sl-dangle*
tests in tests/misc/ls-misc.
Reported by Jim Avera in
http://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/494663
2010-02-01 08:26:12 +01:00
Jim Meyering
5d4952059f maint: move vulnerable-Makefile.in-check to gnulib
* cfg.mk (sc_vulnerable_makefile_CVE-2009-4029): Move rule to...
* gnulib: Update to latest, to get updated "maint.mk".
2010-01-28 09:38:31 +01:00
Jim Meyering
c7ecdb0fcb maint: add a syntax-check rule to check for vulnerable Makefile.in
* cfg.mk (sc_vulnerable_makefile_CVE-2009-4029): New rule.
2010-01-27 22:41:33 +01:00
Kamil Dudka
aad0bde0b5 who --mesg (-T) can use a more accurate test for TTY writability
Enabled when coreutils is configured with --with-tty-group.
Based on a patch written by Piotr Gackiewicz.  Details at
http://bugzilla.redhat.com/454261

* src/who.c (is_tty_writable): A new function returning true if a TTY
device is writable by the group.  Additionally it checks the group to be
the same as TTY_GROUP_NAME when compiled with --with-tty-group.
* m4/jm-macros.m4: Introduce a new configure option --with-tty-group.
* NEWS: Mention the change.
2010-01-25 11:43:49 +01:00
Jim Meyering
0caead1ea0 tests: fix a syntax-check rule to pass in non-srcdir build
* cfg.mk (sc_x_sc_dist_check): This coreutils-specific syntax-check
rule would fail in a non-srcdir build, since in that case, each name
from $(VC_LIST) starts with "$(srcdir)/".  Fix that.
* gnulib: Update to latest, to pull in a required maint.mk change.
2010-01-24 14:51:31 +01:00
Pádraig Brady
9c566ad04a tests: make cp-mv-enotsup-xattr independent of the host file system
* tests/cp-mv-enotsup-xattr: Create a file system from which to copy
the xattrs so that the test is not skipped if the host file system
does not have user_xattr support.  Also don't erroneously fail when
built without xattr support.
2010-01-23 23:44:51 +00:00
Pádraig Brady
3e8586bc54 doc: add nproc to the texinfo overview menu
* doc/coreutils.texi: Add nproc to the System context
command list in the overview menu.
2010-01-23 23:06:59 +00:00
Pádraig Brady
014fead953 maint: ensure test independence from config macro format
* tests/cp/acl: Support USE_ACL not being defined.
* tests/mv/acl: Likewise. Also fix typo in skip message.
* tests/cp/preserve-slink-time: Support HAVE_UTIMENSAT being 0.
* tests/touch/no-dereference: Likewise.
* tests/ls/capability: Normalize so 1 is not required to be last char.
2010-01-23 22:53:52 +00:00
Eric Blake
e489fd04d6 build: fix failure from bogus USE_XATTR definition
* m4/xattr.m4 (gl_FUNC_ADDR): Fix regression introduced in commit
6beca4248.
* THANKS: Update.
Reported by Adam Sampson.
2010-01-19 06:41:57 -07:00
Jim Meyering
31423c76e8 libstdbuf: plug a very unlikely leak
* src/libstdbuf.c (apply_mode): Don't leak "buf" upon setvbuf failure.
2010-01-18 12:03:18 +01:00
Jim Meyering
cd349fdca2 pr: avoid two over-allocations
* src/pr.c (init_store_cols): Allocate N*sizeof(*VAR) bytes,
not N*sizeof(int*).  The latter would mistakenly allocate double
the required space on a system with 8-byte pointers.
2010-01-18 12:03:06 +01:00
Jim Meyering
eccf54368f maint: add missing "post-release push" step to release procedure
* README-release: Push the automated release and post-release
NEWS-updating commits.
Pádraig Brady reported that I'd pushed the tag without also
pushing the followup commit.
2010-01-14 06:39:11 -07:00
Jim Meyering
7ba0e90c55 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2010-01-13 22:14:16 +01:00
Jim Meyering
954ef23ed9 version 8.4
* NEWS: Record release date.
2010-01-13 21:57:54 +01:00
Pádraig Brady
e55d882811 tests: avoid spurious failures on older shells
* tests/tail-2/inotify-hash-abuse: Use kill rather than wait
to determine if the tail process is still running.
* tests/tail-2/inotify-hash-abuse2: Ditto.
2010-01-13 13:42:49 +01:00
Jim Meyering
f28c7d959b tests: work around spurious test failure with OpenBSD4.5's /bin/sh
* tests/ls/infloop: OpenBSD4.5's /bin/sh would mistakenly include
"set -x"-output in an application's stderr stream when stderr is
redirected before stdout.  This was causing one spurious test failure.
The work-around: redirect stdout first.
Reported by Nelson Beebe.
2010-01-13 10:55:55 +01:00
Jim Meyering
3b498ba141 tests: don't silently skip the sort-version tests
* tests/misc/sort-version: Don't use <<- and indented here-doc contents.
s/<<-/<</ and unindent the here-document contents.  Otherwise,
bash would ignore the indented delimiter and use EOF, thus silently
skipping this test.  OpenBSD5.4's shell reported the failure:
  $ printf 'cat<<-x\n foo\n x\n'|sh
  sh: <stdin>[4]: here document `x' unclosed
  [Exit 1]
by contrast, bash warns but still exits successfully:
  $ printf 'cat<<-x\n foo\n x\n'|bash && echo you lose
  bash: line 3: warning: here-document at line 1 delimited by \
    end-of-file (wanted `x')
   foo
   x
  you lose
2010-01-13 10:21:02 +01:00
Eric Blake
39243f0ea8 tests: avoid spurious failure on old kernel
* tests/touch/no-dereference: Skip test if utimensat doesn't
support symlinks.
Reported by Bernhard Voelker.
2010-01-12 06:00:05 -07:00
Pádraig Brady
a4da48c4f5 maint: update info about getting the prerequisite automake
* README-prereq: Now that we require automake-1.11.1
update the instructions from getting it from the git repo
2010-01-12 10:32:08 +00:00
Pádraig Brady
d89755469b maint: remove an already handled item from TODO
* TODO: The question regarding printf octal escapes is answered in
commit 4bcefa62, 2003-04-21, "Fix printf POSIX compatibility bug ..."
2010-01-12 10:29:36 +00:00
Pádraig Brady
b81cdbf31e maint: fix tests on solaris by using /usr/xpg4/bin
* tests/check.mk: Prepend /usr/xpg4/bin to the $PATH if present.
Using the more standard utilities allows tests such as misc/printenv,
which uses the -E option to grep, to complete.
2010-01-12 10:26:27 +00:00
Jim Meyering
0a6bbb5947 build: update gnulib, to get fixed getlogin-related tests 2010-01-12 09:56:07 +01:00
Jim Meyering
6beca4248f build: fix build failure due to missing libxattr
Configure is supposed to detect insufficient XATTR support.
However, if a system has the required headers, but no library,
the configure script would mistakenly enable USE_XATTR.
* m4/xattr.m4 (gl_FUNC_XATTR): If the attr_copy_file function
is not found, don't set USE_XATTR.
Nelson Beebe reported a link failure on RHEL 5.3.
Also, do not let the combination of --disable-xattr and
a stray LIB_XATTR environment setting perturb the build.
* NEWS (Build-related): Mention it.
2010-01-12 08:06:47 +01:00
Jim Meyering
37b8bfda56 doc: mention the wchar.h vs. glibc build problem
* NEWS (Build-related): Mention the wchar.h issue.
2010-01-12 06:52:14 +01:00
Pádraig Brady
21a6a7f64c nproc: return a possibly more accurate total CPU count
* gnulib: Update, for num_processors() improvement.
* NEWS: Mention the fix.
2010-01-12 06:46:51 +01:00
Kamil Dudka
6454dd0f2f ls: reorder includes to work around broken <sys/capability.h>
* src/ls.c: Include <sys/capability.h> later, to avoid build
failure with a header from libcap-2.16-1 or earlier.
See http://bugzilla.redhat.com/483548 for details.
2010-01-12 06:31:20 +01:00
Eric Blake
d0f18197fc maint: move coreutils specific rule into cfg.mk
* gnulib: Update, for maint.mk improvement.
* cfg.mk (_makefile_at_at_check_excpetions): New rule, needed
for latest change to maint.mk.
2010-01-08 12:00:51 -07:00
Jim Meyering
21f4da0fb9 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2010-01-07 18:25:36 +01:00
97 changed files with 1772 additions and 692 deletions

5
.gitignore vendored
View File

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

View File

@@ -1 +1 @@
8.2
8.4

View File

@@ -1,2 +1,3 @@
gl/lib/randint.c
lib/euidaccess-stat.c
gl/tests/test-mbsalign.c

View File

@@ -0,0 +1 @@
^tests/pr/

View File

@@ -1,3 +1,2 @@
configure.ac
*.m4
ChangeLog*

105
HACKING
View File

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

View File

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

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

View File

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

View File

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

View File

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

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

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

Submodule gnulib updated: cb361c968d...6d126a8f1b

View File

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

View File

@@ -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.])
])

View File

@@ -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 || : ; \

View File

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

View File

@@ -2,3 +2,5 @@
tac \- concatenate and print files in reverse
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
\fBrev\fP(1).

View File

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

View File

@@ -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);
}

View File

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

View File

@@ -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);
}

View File

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

View File

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

View File

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

View File

@@ -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]);

View File

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

View File

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

View File

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

View File

@@ -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); \

View File

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

View File

@@ -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);
}
}

View File

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

View File

@@ -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 (_("\

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 ();
}

View File

@@ -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"));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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