]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
10 years agobuild: update to latest gnulib
Pádraig Brady [Thu, 25 Jun 2015 11:18:03 +0000 (12:18 +0100)] 
build: update to latest gnulib

Mainly for -fsanitize=address and -fsanitize=undefined fixes

10 years agobuild: allow build to complete with -fsanitize=address
Pádraig Brady [Thu, 25 Jun 2015 01:43:02 +0000 (02:43 +0100)] 
build: allow build to complete with -fsanitize=address

* src/make-prime-list.c (main): When building with
the above option, avoid this build stopping error:
"LeakSanitizer: detected memory leaks"

10 years agomaint: avoid undefined behavior in qsort call
Pádraig Brady [Wed, 24 Jun 2015 18:14:47 +0000 (19:14 +0100)] 
maint: avoid undefined behavior in qsort call

GCC 5.1.1 -fsanitize=undefined with glibc 2.21 is returning:
"runtime error: null pointer passed as argument 1,
 which is declared to never be null"
* src/ptx.c (sort_found_occurs): Avoid the call with no entries.

10 years agofactor: avoid interspersed lines for parallel runs
Pádraig Brady [Wed, 15 Oct 2014 01:18:35 +0000 (02:18 +0100)] 
factor: avoid interspersed lines for parallel runs

* src/factor.c (n_out): A new global variable to track
how much data has been written to stdout.
(print_factors_single): Use n_out to determine whether
to flush the current (and previous) lines.
* tests/misc/factor-parallel.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.

10 years agoseq: handle exponents more consistently
Pádraig Brady [Tue, 23 Jun 2015 21:51:24 +0000 (22:51 +0100)] 
seq: handle exponents more consistently

src/seq.c (scan_arg): Set precision and width _after_ exponentiation.
For example, this will make '1.1e1 12' and '11 1.2e1' equivalent.
One can still set the precision by specifying extra precision on
the start value, or more naturally with a precision on a step value.
* tests/misc/seq-precision.sh: Add new cases.

10 years agoseq: use consistent output format with hex integers
Pádraig Brady [Tue, 23 Jun 2015 21:48:25 +0000 (22:48 +0100)] 
seq: use consistent output format with hex integers

* src/seq.c (scan_arg): Set precision to 0 for hex constants
(while avoiding hex floats).  This will use then use the
fast path for these arguments.  Note we also set the precision
of inf to 0 here, which ensures we use consistent precision
on output where possible.
* tests/misc/seq-precision.sh: Add corresponding test cases.

10 years agoseq: support inf last item more generally/efficiently
Pádraig Brady [Sat, 11 Oct 2014 09:06:48 +0000 (10:06 +0100)] 
seq: support inf last item more generally/efficiently

* src/seq.c (main): Call seq_fast for infinite last value.
This implicitly avoids format conversion on the
999999 -> 1000000 transition.
* src/seq.c (seq_fast): Generalize the buffer handling,
and adjust to handle the "inf" last value specifics.
* tests/misc/seq-precision.sh: A new test.
* tests/local.mk: Reference the new test.

10 years agodoc: list numfmt in the main menu with "Numeric operations"
Pádraig Brady [Mon, 22 Jun 2015 16:54:52 +0000 (17:54 +0100)] 
doc: list numfmt in the main menu with "Numeric operations"

* doc/coreutils.texi (main menu): Add numfmt.

10 years agonumfmt: don't hardcode floating point limits
Pádraig Brady [Mon, 22 Jun 2015 03:19:48 +0000 (04:19 +0100)] 
numfmt: don't hardcode floating point limits

* src/numfmt.c (MAX_UNSCALED_DIGITS): Set this to LDBL_DIG
rather than hardcoding at 18 for better portability.
* tests/misc/numfmt.pl: Restrict limit tests to supported platforms.

10 years agonumfmt: handle leading zeros correctly
Pádraig Brady [Mon, 22 Jun 2015 01:12:32 +0000 (02:12 +0100)] 
numfmt: handle leading zeros correctly

* src/numfmt.c (simple_strtod_int): Don't count leading zeros
as significant digits.  Also have leading zeros as optional
for floating point numbers.
* tests/misc/numfmt.pl: Add test cases.
* NEWS: Mention the fix.

10 years agonumfmt: avoid integer overflow when rounding
Pádraig Brady [Sun, 21 Jun 2015 03:04:29 +0000 (04:04 +0100)] 
numfmt: avoid integer overflow when rounding

Due to existing limits this is usually triggered
with an increased precision.  We also add further
restrictions to the output of increased precision numbers.

* src/numfmt.c (simple_round): Avoid intmax_t overflow.
(simple_strtod_int): Count digits consistently
for precision loss and overflow detection.
(prepare_padded_number): Include the precision
when excluding numbers to output, since the precision
determines the ultimate values used in the rounding scheme
in double_to_human().
* tests/misc/numfmt.pl: Add previously failing test cases.
* NEWS: Mention the fix.

10 years agonumfmt: support user specified output precision
Pádraig Brady [Fri, 19 Jun 2015 18:18:21 +0000 (19:18 +0100)] 
numfmt: support user specified output precision

* src/numfmt.c (usage): Update the --format description
to indicate precision is allowed.
(parse_format_string): Parse a precision specification
like the standard printf does.
(double_to_human): Honor the precision in --to mode.
* tests/misc/numfmt.pl: New tests.
* doc/coreutils.texi (numfmt invocation): Mention the new feature.
* NEWS: Likewise.

10 years agonumfmt: implement support for field ranges
Dylan Cali [Fri, 5 Sep 2014 09:42:02 +0000 (04:42 -0500)] 
numfmt: implement support for field ranges

* src/numfmt.c: Replace field handling code with logic that understands
field range specifiers.  Instead of processing a single field and
printing line prefix/suffix around it, process each field in the line
checking whether it has been included for conversion.  If so convert and
print, otherwise just print the unaltered field.
(extract_fields): Removed.
(skip_fields): Removed.
(process_line): Gutted and heavily reworked.
(process_suffixed_number): FIELD is now passed as an arg instead of
using a global.
(parse_field_arg): New function that parses field range specifiers.
(next_field): New function that returns pointers to the next field in
a line.
(process_field): New function that wraps the field conversion logic
(include_field): New function that checks whether a field should be
converted
(compare_field): New function used for field value comparisons in a
gl_list.
(free_field): New function used for freeing field values in a gl_list.
Global variable FIELD removed.
New global variable all_fields indicates whether all fields should be
processed.
New global variable all_fields_after stores the first field of a N-
style range.
New global variable all_fields_before stores the last field of a -M
style range.
New global variable field_list stores explicitly specified fields to
process (N N,M or N-M style specifiers).
(usage): Document newly supported field range specifiers.
* bootstrap.conf: Include xlist and linked-list modules.  numfmt now
uses the gl_linked_list implementation to store the field ranges.
* tests/misc/numfmt.pl: Add tests for 'cut style' field ranges.
Adjust existing tests as partial output can occur before an error
Remove test for the 'invalid' field -5.. this is now a valid range.
* gnulib: update to avoid compiler warnings in linked-list.
* NEWS: Mention the new feature.

10 years agodoc: use correct units in df | numfmt example
Pádraig Brady [Thu, 18 Jun 2015 08:48:04 +0000 (09:48 +0100)] 
doc: use correct units in df | numfmt example

* src/numfmt.c (usage): Don't scale output from df
so that numfmt outputs the correct values.

10 years agonumfmt: handle suffixes consistently with --{from,to}-unit
Pádraig Brady [Mon, 15 Jun 2015 02:55:46 +0000 (03:55 +0100)] 
numfmt: handle suffixes consistently with --{from,to}-unit

* src/numfmt.c (unit_to_umax): Support SI (power of 10) suffixes
with the --from-unit and --to-unit options.  Treat suffixes like
is done with --from=auto, which for example will change the meaning
of --to-unit=G to that of --to-unit=Gi.  The suffix support was
previously undocumented and it's better to avoid the traditional
coreutils suffix handling in numfmt by default.
* doc/coreutils.texi: Document the new behavior.  Also fix a typo
mentioning {from,to}=units=.
* tests/misc/numfmt.pl: Adjust accordingly.
* NEWS: Mention the change in behavior.

10 years agomaint: remove stale online manual items at release
Pádraig Brady [Wed, 17 Jun 2015 11:58:53 +0000 (12:58 +0100)] 
maint: remove stale online manual items at release

* gnulib: Update to get the new gnu-web-doc-update with --mirror option.
* README-release: Use the --mirror option in the instructions.
Also clarify and update various release steps.

10 years agotail: display consistent diagnostics upon file replacement
Pádraig Brady [Tue, 9 Jun 2015 10:33:44 +0000 (11:33 +0100)] 
tail: display consistent diagnostics upon file replacement

* src/tail.c (recheck): Display diagnostices for replaced files
even with reused inodes which is a common case.
* tests/tail-2/F-vs-missing.sh: Use correct diagnostic in comment.
* tests/tail-2/F-vs-rename.sh: Likewise.

10 years agotail: display file headers correctly with inotify
Pádraig Brady [Mon, 8 Jun 2015 23:53:35 +0000 (00:53 +0100)] 
tail: display file headers correctly with inotify

* src/tail.c (tail_forever_inotify): Use the fspec pointer to
distinguish previously output files, rather than a descriptor
from the inotify event.  That event descriptor was that of
the parent directory when files were created or renamed etc.
(check_fspec): Adjust for the new comparison.  Also show the
header when the file is truncated, since we show data
in this case also.
* tests/tail-2/F-headers.sh: A new test case.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.

10 years agomaint: sync .gitignore items with gnulib entries
Pádraig Brady [Sun, 7 Jun 2015 16:18:39 +0000 (17:18 +0100)] 
maint: sync .gitignore items with gnulib entries

* .gitignore: Add entries for potentially generated headers.
Also remove a couple of items already present in lib/.gitignore.
* cfg.mk (sc_gitignore_missing): A new syntax check rule to
identify missing .gitignore entries.
(sc_gitignore_redundant): A new syntax check rule to
identify redundant .gitignore entries.
Reported by Tomas Nordin.

10 years agotests: fix false failure in recent test adjustment
Pádraig Brady [Sat, 6 Jun 2015 13:17:14 +0000 (14:17 +0100)] 
tests: fix false failure in recent test adjustment

* configure.ac: Comment on why we link rather than run the test,
and remove the moot __ELF__ check since we never ran it anyway,
and the new CFLAGS and LDFLAGS are a more direct test of support.
* tests/misc/wc-parallel.sh: Fix a syntax error in the previous change.
* tests/misc/md5sum-parallel.sh: Use better error checking, consistent
with that used in wc-parallel.sh.

10 years agobuild: port to AIX
Paul Eggert [Sat, 6 Jun 2015 00:33:54 +0000 (17:33 -0700)] 
build: port to AIX

Problems reported by Michael Felt, and and part of this fix taken
from code suggested by Pádraig Brady in:
http://bugs.gnu.org/20733#112
* configure.ac (stdbuf_supported): Check for warnings, and
for -fPIC and -shared, for AIX.
* src/stat.c (STRUCT_STATVFS): Define to struct statvfs64 if
STATFS is statvfs64.
* src/sync.c (sync_arg) [_AIX]: Open in write mode,
since AIX fsync doesn't work on read-only file descriptors.
* tests/misc/wc-parallel.sh: Skip test if xargs -P does not work.

10 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 5 Jun 2015 15:23:18 +0000 (08:23 -0700)] 
build: update gnulib submodule to latest

10 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 5 Jun 2015 14:53:46 +0000 (07:53 -0700)] 
build: update gnulib submodule to latest

10 years agobuild: port single_binary_prog to POSIX shell
Paul Eggert [Thu, 4 Jun 2015 19:15:35 +0000 (12:15 -0700)] 
build: port single_binary_prog to POSIX shell

Problem reported privately by Michael Felt.
* Makefile.am (install-exec-hook):
* src/local.mk (src/coreutils_symlinks, src/coreutils_shebangs)
(clean-local):
Port to POSIX shell, which doesn't allow 'for i in ; do ...'.

10 years agobuild: add a dependency on the gnulib tempname module
Pádraig Brady [Wed, 3 Jun 2015 03:29:45 +0000 (04:29 +0100)] 
build: add a dependency on the gnulib tempname module

* bootstrap.conf: Add "tempname" which is needed by mktemp(1).
The explicit dependency supports running gnulib-tool with
the --conditional-dependencies option, used to minimize built
modules.  Note on a Fedora 22 system, that results in avoiding
redundant builds of: areadlinkat.o asnprintf.o fd-hook.o
fseterr.o printf-args.o printf-parse.o sockets.o vasnprintf.o.
However --conditional-dependencies is not enabled, since it
currently precludes the inclusion of gnulib tests.

10 years agobuild: update to latest gnulib
Pádraig Brady [Tue, 2 Jun 2015 00:25:05 +0000 (01:25 +0100)] 
build: update to latest gnulib

Mainly with build fixes for Mac OS X.

10 years agotests: fix race in tail test without inotify
Pádraig Brady [Mon, 1 Jun 2015 15:46:33 +0000 (16:46 +0100)] 
tests: fix race in tail test without inotify

* tests/tail-2/wait.sh: Without inotify, skip a portion of the test
that checks that -F never outputs from a tailed descriptor
after the followed name is recreated, because tail_forever()
doesn't guarantee that.
Noticed at http://hydra.nixos.org/build/22766288

10 years agotests: fix false failure on loaded systems
Pádraig Brady [Mon, 1 Jun 2015 14:38:23 +0000 (15:38 +0100)] 
tests: fix false failure on loaded systems

* tests/misc/uniq-perf.sh: Use our standard 10s timeout,
which is sufficient to trigger the failure and also
avoids a false failure on slow/loaded systems.
Noticed at http://hydra.nixos.org/build/22766288

10 years agomaint: avoid new coverity warnings
Pádraig Brady [Fri, 29 May 2015 14:33:59 +0000 (15:33 +0100)] 
maint: avoid new coverity warnings

* src/sync.c (sync_arg): Initialise variable to avoid
unitialized access if assert is disabled.
* src/head.c (elide_tail_bytes_file): Support this function
with ---presume-input-pipe and larger files,
which regressed with commit v8.23-47-g2662702.
(elide_tail_lines_file): Likewise.
* src/dd.c (dd_copy): Explicitly don't try to ftruncate()
upon failure to lseek() (the existing check against
st_size was already protecting that).
* src/factor.c (factor_using_squfof): Assert (only when
linting due to performance) to avoid the implication of
divide by zero.
* src/od.c (read_block): Remove dead code.
* src/tac.c (tac_seekable): Likewise.
* src/ls.c (gobble_file): Likewise.

10 years agobuild: remove workarounds for unsupported gettext versions
Pádraig Brady [Thu, 28 May 2015 01:25:29 +0000 (02:25 +0100)] 
build: remove workarounds for unsupported gettext versions

Now that we depend on gettext >= 0.19.2 remove the workaround
for issues in autopoint 0.18.3.  Note the scheme currently used in
newer gettext (autopoint) to avoid these issues requires
autoconf >= 2.69, therefore we update this requirement also.

Note the gettext version dependence from gnulib comes from
gnulib using gettext macros, and coreutils indirectly depends on
the gettext module due to:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=41dca647
bootstrap will then update m4/po.m4 and thus require a
supportng gettext version.

* bootstrap: Remove moot warning (resyncing with gnulib).
* configure.ac (AC_PREREQ): Change to 2.69 (now 3 years old).

10 years agotests: ln/hard-to-sym FAIL rather than ERROR when ln fails
Pádraig Brady [Fri, 31 Oct 2014 02:25:02 +0000 (02:25 +0000)] 
tests: ln/hard-to-sym FAIL rather than ERROR when ln fails

* tests/ln/hard-to-sym.sh: Only call framework_failure_ when ln
returns success.

10 years agocopy: prefer our hardlink to symlink emulation on OS X 10.10
Pádraig Brady [Thu, 28 May 2015 00:26:08 +0000 (01:26 +0100)] 
copy: prefer our hardlink to symlink emulation on OS X 10.10

* src/copy.c (CAN_HARDLINK_SYMLINKS): Don't enable use of linkat()
on Darwin 14, as the gnulib fallback emulation there doesn't
preserve ownership and timestamps etc.  This fixes a test failure
in tests/cp/link-symlink.sh
* tests/cp/link-deref.sh: Adjust accordingly.

10 years agomaint: remove sys/types.h include order check
Pádraig Brady [Mon, 18 May 2015 11:25:22 +0000 (12:25 +0100)] 
maint: remove sys/types.h include order check

* src/system.h: This was inadvertently ineffective due to
a typo in commit v8.9-10-ge1aaf89 (Jan 2011), but has
not caused any issues, so remove.

10 years agomkdir: fix -pZ with existing parent directories
Pádraig Brady [Thu, 21 May 2015 10:38:13 +0000 (11:38 +0100)] 
mkdir: fix -pZ with existing parent directories

When the parent directory exists and has a different
default context to the final directory, the context
was incorrectly left as that of the parent directory.

* src/mkdir.c (process_dir): Because defaultcon() is called for
existing ancestors (as it must be to avoid races), then we must
unconditionally call restorecon() on the last component due to
the already documented caveat with make_dir_parents().
Alternatively you could temp disable o->set_security_context
around make_dir_parents(), but that would be subject to races.
* tests (tests/mkdir/restorecon.sh): Add a TODO for improvement.
Reference mknod and mkfifo with print_ver_.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/20616

10 years agotests: df-output: accept multiple spaces in header
Assaf Gordon [Fri, 22 May 2015 18:09:27 +0000 (14:09 -0400)] 
tests: df-output: accept multiple spaces in header

* tests/df/df-output.sh: Allow for multiple spaces in the header line
of 'df', resulting from alignment with disk sizes >= 10TB.

10 years agotests: fix non POSIX constructs causing failures with dash
Pádraig Brady [Tue, 19 May 2015 11:36:29 +0000 (12:36 +0100)] 
tests: fix non POSIX constructs causing failures with dash

* tests/cp/no-ctx.sh: Scope of `var=val func` is inconsistent
across shells, so avoid that construct with functions.
* tests/df/no-mtab-status.sh: Likewise.
* tests/tail-2/inotify-race.sh: `read` needs an argument.
* tests/tail-2/inotify-race2.sh: Likewise.

10 years agobuild: fix 'dist' and 'syntax-check' targets in VPATH build
Pádraig Brady [Sun, 17 May 2015 14:52:00 +0000 (15:52 +0100)] 
build: fix 'dist' and 'syntax-check' targets in VPATH build

* cfg.mk: Various syntax-check adjustments so that it's
not assumed the $builddir is the base distribution directory.
* Makefile.am: Likewise for the 'dist' target.

10 years agobuild: avoid issues with case insensitive file systems
Pádraig Brady [Sun, 17 May 2015 09:51:15 +0000 (10:51 +0100)] 
build: avoid issues with case insensitive file systems

* cfg.mk (sc_case_insensitive_file_names): A new syntax-check rule.
* tests/tail-2/descriptor-vs-rename.sh: Rename from
tests/tail-2/f-vs-rename.sh
* tests/local.mk: Reference the renamed test.
Reported by Jim Meyering.

10 years agotests: fix check for local file system in inotify-rotate-resources.sh
Bernhard Voelker [Thu, 14 May 2015 19:31:10 +0000 (21:31 +0200)] 
tests: fix check for local file system in inotify-rotate-resources.sh

* tests/tail-2/inotify-rotate-resources.sh: s/(is_local_dir)/\1_/

10 years agotests: fix async allocation race on BTRFS
Pádraig Brady [Thu, 14 May 2015 10:43:54 +0000 (11:43 +0100)] 
tests: fix async allocation race on BTRFS

* tests/dd/sparse.sh: Sync files before checking allocations,
which may be done asynchronously on NFS and BTRFS at least.
Also mark this test as very expensive on remote file systems.
* tests/du/2g.sh: Likewise, also use fallocate if available
to efficiently allocate the large file, otherwise skip
on remote file systems.
* tests/tail-2/inotify-rotate-resources.sh: Use the more
standard is_local_dir_() to check remoteness.
* tests/cp/fiemap-empty.sh: Comment on the sync issue
for this currerntly unused test.
Fixes http://bugs.gnu.org/20570

10 years agotimeout: with --foreground don't send SIGCONT
Pádraig Brady [Wed, 13 May 2015 12:41:42 +0000 (13:41 +0100)] 
timeout: with --foreground don't send SIGCONT

* src/timeout.c (cleanup): Don't send SIGCONT to the monitored program
when --foreground is specified, as it's generally not needed for
foreground programs, and can cause intermittent signal delivery
issues with monitors like GDB for example.
* doc/coreutils.texi (timeout invocation): Mention that SIGCONT
is not sent with --foreground.
* NEWS: Mention the behavior change.

10 years agosplit: auto set suffix len for --numeric-suffixes=<N --number=N
Pádraig Brady [Wed, 6 May 2015 00:48:40 +0000 (01:48 +0100)] 
split: auto set suffix len for --numeric-suffixes=<N --number=N

Supporting `split --numeric-suffixes=1 -n100` for example.

* doc/coreutils.texi (split invocation): Mention the two
use cases for the FROM parameter, and the consequences on
the suffix length determination.
* src/split.c (set_suffix_length): Use the --numeric-suffixes
FROM parameter in the suffix width calculation, when it's
less than the number of files specified in --number.
* tests/split/suffix-auto-length.sh: Add test cases.
Fixes http://bugs.gnu.org/20511

10 years agodoc: clarify the operation of wc -L
Assaf Gordon [Wed, 13 May 2015 01:46:29 +0000 (02:46 +0100)] 
doc: clarify the operation of wc -L

* src/wc.c (usage): State that it calculates display width.
* doc/coreutils.texi (wc invocation): Detail the distinct
items used to determine the display width.

10 years agotail: consistently output all data for truncated files
Pádraig Brady [Mon, 11 May 2015 13:25:19 +0000 (14:25 +0100)] 
tail: consistently output all data for truncated files

Generally if logs are truncated, they're truncated to 0 length,
so output all existing data when our heuristic determines truncation.
Note with inotify, truncate() and write() are often determined
independently and so all data would be written if that was the case.

* src/tail.c (check_fspec): Reset file offset to 0 upon truncation.
(tail_forever): Likewise.
(recheck): Add a FIXME for the related issue where tail may lose
data due to tail discounting older log files too early.
* tests/tail-2/truncate.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.

10 years agotail: fix inotify startup races
Pádraig Brady [Tue, 5 May 2015 21:11:24 +0000 (22:11 +0100)] 
tail: fix inotify startup races

The previous fixes to races in the various tail tests,
identified actual races in the tail inotify implementation.
With --follow=descriptor, if the tailed file was replaced before
the inotify watch was added, then any subsequent changes were ignored.
Similarly in --follow=name mode, all changes to a new name were
effectively ignored if that name was created after the original open()
but before the inotify_add_watch().

* src/tail.c (tail_forever_inotify): Fix 3 cases.
1. With -f, don't stop tailing when file removed before watch.
2. With -f, watch right file when file replaced before watch.
3. With -F, inspect correct file when replaced before watch.
Existing tests identify these when tail compiled with TAIL_TEST_SLEEP.
* tests/tail-2/inotify-rotate-resources.sh:
This test also identifies the issue with --follow=name
when TAIL_TEST_SLEEP is used.  Adjust so the test is immune
to such races, and also fail quicker on remote file systems.
* tests/tail-2/inotify-race2.sh: A new test using GDB,
based on inotify-race.sh, which tests the -F race
without needed recompilation with sleeps.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug.

10 years agotests: cleanup background processes upon interruption
Pádraig Brady [Fri, 1 May 2015 04:26:38 +0000 (05:26 +0100)] 
tests: cleanup background processes upon interruption

Reap background processes so that:
- Stray processes aren't left on the system
- Files aren't held open causing deletion issues on NFS
- Partitions used to run the tests from can be unmounted

* tests/tail-2/F-vs-missing.sh: Add the `kill && wait` of the
background $pid(s) to cleanup_().
* tests/tail-2/F-vs-rename.sh: Likewise.
* tests/tail-2/f-vs-rename.sh: Likewise.
* tests/tail-2/append-only.sh: Likewise.
* tests/tail-2/assert-2.sh: Likewise.
* tests/tail-2/assert.sh: Likewise.
* tests/tail-2/flush-initial.sh: Likewise.
* tests/tail-2/inotify-hash-abuse.sh: Likewise.
* tests/tail-2/inotify-hash-abuse2.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/tail-2/inotify-rotate-resources.sh: Likewise.
* tests/tail-2/inotify-rotate.sh: Likewise.
* tests/tail-2/pid.sh: Likewise.
* tests/tail-2/pipe-f2.sh: Likewise.
* tests/tail-2/retry.sh: Likewise.
* tests/tail-2/symlink.sh: Likewise.
* tests/tail-2/tail-n0f.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.
* tests/cp/existing-perm-race.sh: Likewise.
* tests/cp/file-perm-race.sh: Likewise.
* tests/cp/parent-perm-race.sh: Likewise.
* tests/cp/sparse-to-pipe.sh: Likewise.
* tests/dd/stats.sh: Likewise.
* tests/du/move-dir-while-traversing.sh: Likewise.
* tests/misc/cat-buf.sh: Likewise.
* tests/misc/help-version.sh: Likewise.
* tests/misc/printf-surprise.sh: Likewise.
* tests/misc/sort-compress-proc.sh: Likewise.
* tests/misc/sort-spinlock-abuse.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/tac-continue.sh: Likewise.
* tests/misc/timeout-group.sh: Likewise.
* tests/mv/i-3.sh: Likewise.
* tests/rm/dangling-symlink.sh: Likewise.
* tests/rm/isatty.sh: Likewise.
* cfg.mk (sc_prohibit_test_background_without_cleanup_):
A new syntax-check to ensure cleanup_() is defined
when background tasks are created in a test.

10 years agotests: avoid hung processes due to gdb SIGCONT handling
Pádraig Brady [Fri, 1 May 2015 17:03:37 +0000 (18:03 +0100)] 
tests: avoid hung processes due to gdb SIGCONT handling

* tests/tail-2/inotify-race.sh: Add a `wait` to ensure that
we reap all background gdb and tail processes.  That resulted
in the test hanging intermittently and upon investigation was
due to gdb intermittently failing to terminate the child process
due to receiving a SIGCONT signal.  Therefore we avoid using
timeout(1) which sends that signal, and instead rely on tail's
inbuilt --pid monitoring on a background sleep process.
Given this new implementation, the VERY_EXPENSIVE guard was removed.
Related issues with this test hanging were previously discussed at:
https://lists.gnu.org/archive/html/bug-coreutils/2009-12/msg00025.html

10 years agotests: fix races in and standardize the tail tests
Pádraig Brady [Sat, 2 May 2015 09:52:37 +0000 (10:52 +0100)] 
tests: fix races in and standardize the tail tests

* tests/tail-2/F-vs-missing.sh: Use standard "fastpoll" options
(-s.1 --max-unchanged-stats=1) to speedup the non-inotify case.
Add the non-inotify case to the test. `wait` on the background
tail process to terminate which should avoid the need for the
non standard `retry_delay_ cleanup ...` on NFS.
* tests/tail-2/F-vs-rename.sh: Remove 'out' at the start of the loop,
to avoid a race in checking its contents.  Also ensure 'a' & 'b'
files are present before the tail process starts.  Use the standard
"fastpoll" options as above.
* tests/tail-2/f-vs-rename.sh: Likewise.
* tests/tail-2/append-only.sh: Use more standard variable names.
* tests/tail-2/flush-initial.sh: Use "fastpoll" options for
non-inotify platforms.  Also `wait` on the background tail to avoid
stray processes and file cleanup issues on NFS.
* tests/tail-2/inotify-hash-abuse.sh: Always run non-inotify case.
Use "fastpoll" options.  Use a more standard retry_delay_ instead
of a hardcoded sleep loop.  Add a `wait` on the background tail.
* tests/tail-2/inotify-hash-abuse2.sh: Likewise.
* tests/tail-2/inotify-rotate-resources.sh: Wait just on the
specific tail $pid needed.
* tests/tail-2/inotify-rotate.sh: Use "fastpoll" options.
* tests/tail-2/pid.sh: Use standard variable names.
Add a `wait` on the background tails.
* tests/tail-2/pipe-f2.sh: Likewise.
* tests/tail-2/tail-n0f.sh: Likewise.
* tests/tail-2/retry.sh: Use "fastpoll" options.
* tests/tail-2/symlink.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.  Speedup by using sub second
parameters to timeout(1).  Improve the part ensuring that
-F never follows a renamed file.
* tests/tail-2/infloop-1.sh: Remove invalid test.  tail(1) was not
being passed the --pid=$yes_pid option, retry_delay_ wasn't used
to avoid races, and yes could write huge files before being killed.
* tests/local.mk: Remove the invalid test reference.
* tests/tail-2/assert-2.sh: Rewrite using retry_delay_().  Since
no longer hardcoding large delays, remove the VERY_EXPENSIVE tag.
* tests/tail-2/assert.sh: Likewise.

10 years agobuild: rewrite is_ENOTSUP without an #if directive
Paul Eggert [Sun, 10 May 2015 15:31:14 +0000 (08:31 -0700)] 
build: rewrite is_ENOTSUP without an #if directive

* src/system.h (is_ENOTSUP): Avoid in-function #if directive.

10 years agobuild: avoid a warning form gcc's new -Wlogical-op
Jim Meyering [Sat, 9 May 2015 17:57:54 +0000 (10:57 -0700)] 
build: avoid a warning form gcc's new -Wlogical-op

Without this change, very recent gcc (e.g., version 6.0.0 20150509)
would print the following when configured with --enable-gcc-warnings:

  src/copy.c:165:30: error: logical 'or' of equal expressions \
    [-Werror=logical-op]
    && (errno == EOPNOTSUPP || errno == ENOTSUP || errno == ENOSYS))
                           ^
* src/system.h (is_ENOTSUP): New function.
* src/copy.c (punch_hole): Use it.
* src/ls.c (errno_unsupported, gobble_file): Use it.

10 years agodoc: standardize messages about the '-' stdin FILE
Pádraig Brady [Thu, 30 Apr 2015 13:02:46 +0000 (14:02 +0100)] 
doc: standardize messages about the '-' stdin FILE

* src/system.h (emit_stdin_note): A new function, refactoring
the usage note about the '-' FILE implying stdin.
* src/base64.c (usage): Use the new function to emit the
note in a standard location and with standard separation.
* src/cat.c (usage): Likewise.
* src/csplit.c (usage): Likewise.
* src/cut.c (usage): Likewise.
* src/expand.c (usage): Likewise.
* src/fmt.c (usage): Likewise.
* src/head.c (usage): Likewise.
* src/md5sum.c (usage): Likewise.
* src/nl.c (usage): Likewise.
* src/od.c (usage): Likewise.
* src/paste.c (usage): Likewise.
* src/pr.c (usage): Likewise.
* src/ptx.c (usage): Likewise.
* src/shred.c (usage): Likewise.
* src/shuf.c (usage): Likewise.
* src/sort.c (usage): Likewise.
* src/sum.c (usage): Likewise.
* src/tac.c (usage): Likewise.
* src/tail.c (usage): Likewise.
* src/tsort.c (usage): Likewise.
* src/unexpand.c (usage): Likewise.
* src/wc.c (usage): Likewise.
* src/join.c (usage): Adjust the separation used for
the message referring to FILE1 or FILE2 as stdin.
* src/comm.c (usage): Add a message using the same
wording (translation) as used in join.
* src/split.c (usage): Reword to using FILE rather than
INPUT, allowing use of emit_stdin_note().  Also remove
the mention of "fixed-size" pieces as this isn't now
always the case.
Fixes http://pad.lv/1450179

10 years agotests: don't skip df tests with /proc/self/mountinfo
Pádraig Brady [Thu, 30 Apr 2015 10:33:38 +0000 (11:33 +0100)] 
tests: don't skip df tests with /proc/self/mountinfo

* tests/df/no-mtab-status.sh: getmntent is no longer called
when /proc/self/mountinfo is present, thus causing the test
to be skipped.  Therefore wrap fopen() to ignore mountinfo,
and use the test genmntent table instead.
* tests/df/skip-duplicates.sh: Likewise.

10 years agobuild: fix SINGLE_BINARY build when printf is a macro
Yunlian Jiang [Tue, 28 Apr 2015 22:47:20 +0000 (23:47 +0100)] 
build: fix SINGLE_BINARY build when printf is a macro

* src/coreutils.c (usage): include coreutils.h outside
the printf call, because if it's a macro you will get the error:
embedding a #include directive within macro arguments is not supported

10 years agomaint: avoid a new -Werror=return-type warning in yes.c
Pádraig Brady [Tue, 28 Apr 2015 22:07:13 +0000 (23:07 +0100)] 
maint: avoid a new -Werror=return-type warning in yes.c

* src/yes.c (main): Simplify the logic so that the
compiler can see this function always returns a value.
This was seen with GCC 5.0 in SINGLE_BINARY mode.

10 years agotests: run ls capability coloring test irrespective of $LS_COLORS
Pádraig Brady [Tue, 28 Apr 2015 20:24:57 +0000 (21:24 +0100)] 
tests: run ls capability coloring test irrespective of $LS_COLORS

* tests/ls/no-cap.sh: Ensure the test isn't skipped even if
capability coloring is disabled in the current $LS_COLORS.
Also just enable/disable capability coloring to avoid the
dircolors(1) overhead.

10 years agomaint: use gnulib styling with the online manual
Pádraig Brady [Mon, 27 Apr 2015 10:07:33 +0000 (11:07 +0100)] 
maint: use gnulib styling with the online manual

The equivalent styling added in v8.23-155-g3b98ee7,
is now applied to gnulib using projects by default.

10 years agobuild: rely on gnulib to determine printf routines are safe
Pádraig Brady [Mon, 27 Apr 2015 10:00:07 +0000 (11:00 +0100)] 
build: rely on gnulib to determine printf routines are safe

gnulib now only checks that the printf routines never crash,
which is all coreutils currrently requires, and so we revert
commit v8.23-81-gf57bfbb to let gnulib decide whether to replace
the system printf routines.

10 years agomaint: fix printf format for signed integers
Pádraig Brady [Mon, 27 Apr 2015 09:44:25 +0000 (10:44 +0100)] 
maint: fix printf format for signed integers

With GCC 5 and the newly added warnings from gnulib, ensure the
correct signed integer is passed for the printf format,
to avoid -Werror=format= failures.

10 years agobuild: update gnulib submodule to latest
Pádraig Brady [Mon, 27 Apr 2015 09:27:16 +0000 (10:27 +0100)] 
build: update gnulib submodule to latest

Fix file-has-acl build failure on RHEL/Centos 6.
Fix GCC 5 warnings with printf and in fts.c.

10 years agobuild: reduce gettext dependency to 0.19.2
Pádraig Brady [Mon, 27 Apr 2015 09:14:14 +0000 (10:14 +0100)] 
build: reduce gettext dependency to 0.19.2

* bootstrap.conf: 0.19.2 is available on openSUSE-13.2,
Debian-8.0, and Ubuntu-14.10.  Given there were issues
with earlier 0.19 gettext releases, set this as the new minimum.
* configure.ac (AM_GNU_GETTEXT_VERSION): Likewise.
Reported by Bernhard Voelker

10 years agols: on GNU/Linux, remove dependency on libacl
Paul Eggert [Mon, 27 Apr 2015 05:09:30 +0000 (22:09 -0700)] 
ls: on GNU/Linux, remove dependency on libacl

* src/local.mk (src_ls_LDADD): Change from LIB_ACL to LIB_HAS_ACL.

10 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 26 Apr 2015 22:46:18 +0000 (15:46 -0700)] 
build: update gnulib submodule to latest

* bootstrap.conf (gnulib_modules): Add file-has-acl.
(buildreq): Bump autopoint and gettext to 0.19.4.
* configure.ac (AM_GNU_GETTEXT_VERSION):
Bump to 0.19.4.
* gl/lib/tempname.c.diff, gl/lib/tempname.h.diff:
Merge recent gnulib changes.

10 years agodoc: fix grammar issue in truncate info
Michael Witten [Wed, 22 Apr 2015 15:07:02 +0000 (15:07 +0000)] 
doc: fix grammar issue in truncate info

* doc/coreutils.texi (truncate invocation): The word 'their' is
incorrect; 'each file' is the antecedent, and is singular,
so 'its' is the correct pronoun.

10 years agobuild: fix potential factor build failure on arm and mips
Pádraig Brady [Wed, 22 Apr 2015 01:20:47 +0000 (02:20 +0100)] 
build: fix potential factor build failure on arm and mips

* src/longlong.h: Sync with the latest longlong.h from libgmp to:
- Use __builtin_c[lt]zl on arm64.
- Fix sparc64 vis3 build failure due to missing __clz_tab.
- Avoid a clang build issue on mips.
- Support thumb2 arm 32 bit system.
* src/cfg.mk (sc_ensure_comma_after_id_est): Exclude longlong.h
to ease merges.

10 years agomaint: avoid -Werror=strict-overflow warnings with GCC 5
Pádraig Brady [Wed, 22 Apr 2015 00:07:01 +0000 (01:07 +0100)] 
maint: avoid -Werror=strict-overflow warnings with GCC 5

All warnings were of the form: "assuming signed overflow does not occur
when simplifying conditional to constant [-Werror=strict-overflow]"

* src/dd.c (cache_round): Use an appropriately sized unsigned type,
to avoid possibility of undefined signed overflow.
* src/mknod.c (main): Likewise.
* src/pr.c (pad_down): Likewise.
* src/wc.c (main): Likewise.
* src/tail.c (main): Assert that argc >= 0 thus allowing the
compiler to assume without implication that argc - optind
is positive.

10 years agodircolors: add 'MISSING' to the default database
Pádraig Brady [Fri, 17 Apr 2015 22:47:58 +0000 (23:47 +0100)] 
dircolors: add 'MISSING' to the default database

* src/dircolors.hin: Add the MISSING entry, to indicate
this as a possibility in new templates output from dircolors,
and also to ease comparison with existing databases that
generally do define a MISSING entry.

10 years agodoc: clarify how cp behaves with default ACLs
Andreas Gruenbacher [Sun, 12 Apr 2015 23:41:50 +0000 (01:41 +0200)] 
doc: clarify how cp behaves with default ACLs

* doc/coreutils.texi (cp invocation): Mention that when copying files
without preserving permissions, the umask or a default ACL affect
the mode of new files.
* THANKS.in: Remove committer.
Related to http://bugs.gnu.org/8527

10 years agodf: fix --local hanging with inaccessible remote mounts
Pádraig Brady [Sun, 5 Apr 2015 17:21:38 +0000 (18:21 +0100)] 
df: fix --local hanging with inaccessible remote mounts

* src/df.c (filter_mount_list): With -l, avoid stating remote mounts.
* init.cfg: Avoid test hangs with inaccessible remote mounts.
* tests/df/no-mtab-status.sh: Skip with inaccessible remote mounts.
* tests/df/skip-rootfs.sh: Likewise.
* tests/df/total-verify.sh: Likewise.
* NEWS: Mention the bug fix.
Reported at http://bugzilla.redhat.com/1199679

10 years agodoc: correct pluralization for mkfifo and mknod
Mitchel Humpherys [Thu, 9 Apr 2015 06:00:17 +0000 (23:00 -0700)] 
doc: correct pluralization for mkfifo and mknod

* doc/coreutils.texi: `mkfifo' and `mknod' use the optContext macro
which adds a description for the SELinux security context in addition to
the single option already described in each case.  The result in both
cases is two options being introduced as `option' (singular).  Fix this
by introducing them as `options' (plural).

10 years agodf: fix use of uninitialized variable reported by valgrind
Pádraig Brady [Thu, 2 Apr 2015 04:34:07 +0000 (05:34 +0100)] 
df: fix use of uninitialized variable reported by valgrind

 Conditional jump or move depends on uninitialised value(s)
    at 0x40380C: get_field_values (df.c:840)
    by 0x403E16: get_dev (df.c:994)
    by 0x404D65: get_all_entries (df.c:1364)
    by 0x405926: main (df.c:1714)

* src/df.c (get_dev): Initialize the fsu.fsu_bavail_top_bit_set
member, when adding placeholder entries.
(main): Avoid a "definitely lost" memory leak warning from valgrind,
reported by Bernhard Voelker.

10 years agodoc: clarify that ls --sort=time is newest first
Pádraig Brady [Wed, 1 Apr 2015 00:56:52 +0000 (01:56 +0100)] 
doc: clarify that ls --sort=time is newest first

* src/ls.c (usage): Add punctuation to avoid ambiguity in the
description of the --time option.  Mention that both the -u
and --sort=time default order is newest first.

10 years agotail: fix -f to follow changes after a rename
Stephane Chazelas [Tue, 3 Feb 2015 21:22:06 +0000 (21:22 +0000)] 
tail: fix -f to follow changes after a rename

* src/tail.c (tail_forever_inotify): Only monitor write()s and
truncate()s to files in --follow=descriptor mode, thus avoiding
the bug where we removed the watch on renamed files.
Also adjust the inotify event processing code that is
now significant only in --follow=name mode.
* tests/tail-2/F-vs-rename.sh: Improve this existing test by running
in both polling and inotify modes.
* tests/tail-2/f-vs-rename.sh: A new test based on the existing one.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug.
Fixes http://bugs.gnu.org/19760

10 years agodoc: move numfmt info to the 'Numeric operations' section
Pádraig Brady [Sat, 28 Mar 2015 16:53:15 +0000 (16:53 +0000)] 
doc: move numfmt info to the 'Numeric operations' section

* doc/coreutils.texi: Move numfmt info to this section,
as numfmt functionality aligns more with seq and factor,
than fmt and pr etc.

10 years agonohup: clarify stdin redirection
Paul Eggert [Fri, 27 Mar 2015 22:01:35 +0000 (15:01 -0700)] 
nohup: clarify stdin redirection

Problem reported by Isaac Schwabacher in:
http://bugs.gnu.org/20214
* doc/coreutils.texi (nohup invocation): Clarify that when nohup's
stdin gets redirected, it's unreadable.
* doc/coreutils.texi (nohup invocation):
* src/nohup.c (usage): Don't promise /dev/null.

10 years agotests: fix false test failure with df on Debian/kFreeBSD
Assaf Gordon [Fri, 27 Mar 2015 09:38:48 +0000 (09:38 +0000)] 
tests: fix false test failure with df on Debian/kFreeBSD

* tests/fs/skip-duplicates.sh: On this platform .mnt_opts is significant
so define to empty to avoid a NULL deref in read_file_system_list().
Fixes http://bugs.gnu.org/20210

10 years agodoc: disambiguate the ls --color description
Christoph Anton Mitterer [Thu, 26 Mar 2015 09:49:59 +0000 (09:49 +0000)] 
doc: disambiguate the ls --color description

* src/ls.c (usage): Avoid the implication that the
default ls behavior is to --color=always.
Reported in http://bugs.debian.org/781208

10 years agodoc: clarify the date standard output formats
Pádraig Brady [Thu, 26 Mar 2015 00:47:28 +0000 (00:47 +0000)] 
doc: clarify the date standard output formats

* src/date.c (usage): Use FMT rather than TIMESPEC as the parameter,
since it's simpler to understand and can be better aligned.
Give an example for the --iso-8601 output format.
Adjust the example used for the 3 standard formats to be unambiguous
with respect to day/mon ordering and use of leading zeros in the time.
Reorder the options descriptions slightly, so that the
3 standards options are together.
Indent the multi-line descriptions so that grouping is obvious.
Remove a redundant description of the --rfc-3339 format,
which is obvious in the existing example.
Separate these 3 standards options to their own translatable string
to simplify translation.
Change 'date and time' to 'date/time' in the --iso-8601 description
to be consistent with --rfc-3339 and to help avoid the implication
that the time is always output or even output by default.
Fixes http://bugs.gnu.org/20203

10 years agomaint: apply basic styling to online manual
Pádraig Brady [Mon, 23 Mar 2015 17:47:23 +0000 (17:47 +0000)] 
maint: apply basic styling to online manual

* README-release: Reference http://www.gnu.org/s/coreutils/manual.css
to apply basic styling to the online coreutils manual, consistent
with the Emacs documentation.

10 years agodoc: clarify the uniq -D man page description
Pádraig Brady [Mon, 23 Mar 2015 22:00:30 +0000 (22:00 +0000)] 
doc: clarify the uniq -D man page description

* src/uniq.c (usage): The description was very confusing in the man page
due to the stripped newlines.  Add punctuation for clarification.

10 years agowc: use a more adaptive wc -l implementation
Pádraig Brady [Mon, 23 Mar 2015 11:54:19 +0000 (11:54 +0000)] 
wc: use a more adaptive wc -l implementation

* src/wc.c (wc): Allow any block to select the count implementation,
rather than just using the first 10 lines.  This also simplifies
the code from 3 loops to 2.

10 years agodoc: clarify default order for ls --sort=size
Dan Jacobson [Mon, 23 Mar 2015 08:59:18 +0000 (08:59 +0000)] 
doc: clarify default order for ls --sort=size

* src/ls.c (usage): Mention that default order is largest first.
Fixes http://bugs.gnu.org/20172

10 years agomaint: really fix wildcard quoting in sc_tests_executable
Pádraig Brady [Fri, 20 Mar 2015 12:03:56 +0000 (12:03 +0000)] 
maint: really fix wildcard quoting in sc_tests_executable

* cfg.mk (sc_tests_executable): The previous commit avoided
the globbing, but also passed on the quoted wildcards to find(1).
We could use eval to handle the quoting, though that's a bit
awkward and dangerous, so instead explicitly disable globbing
for the whole make target subshell.  Note noglob is not available
on solaris, where we fall back to set -f.  Note also that zsh
uses set -F for this, but that's moot here.  Also correct the
find(1) expression to include the -o between each wildcard.

10 years agomaint: fix wildcard quoting in sc_tests_executable
Pádraig Brady [Fri, 20 Mar 2015 01:13:17 +0000 (01:13 +0000)] 
maint: fix wildcard quoting in sc_tests_executable

* cfg.mk (sc_tests_executable): If there are files with
$TEST_EXTENSIONS in the current directory, then the
lack of quoting of the $test_extensions_rx contents
could result in globbing and an inconsequential run.
find(1) produces warnings only with more than one expansion.

10 years agowc: speedup counting of short lines
Kristoffer Brånemyr [Wed, 18 Mar 2015 15:32:19 +0000 (15:32 +0000)] 
wc: speedup counting of short lines

Using a test file generated with:
  yes | head -n100M > 2x100M.txt

before> time wc -l 2x100M.txt
  real 0.842s
  user 0.810s
  sys  0.033s

after> time wc -l 2x100M.txt
  real 0.142s
  user 0.111s
  sys  0.031s

* src/wc.c (wc): Split the loop that deals with -l into 3.
The first is used at the start of the input to determine if
the average line length is < 15, and if so the second loop is
used to look for '\n' internally to wc.  For longer lines,
memchr is used as before to take advantage of system specific
optimizations which any outweigh function call overhead.
Note the first 2 loops could be combined, though in testing,
GCC 4.9.2 at least, wasn't sophisticated enough to separate
the loops based on the "check_len" invariant.
Note also __builtin_memchr() isn't significant here as
GCC currently only applies constant folding with that.
* NEWS: Mention the improvement.

10 years agoyes: improve efficiency when all args aren't buffered
Giuseppe Scrivano [Tue, 10 Mar 2015 12:25:48 +0000 (12:25 +0000)] 
yes: improve efficiency when all args aren't buffered

* src/yes.c (main): Even when the internal buffer isn't large enough,
output what we've buffered already, and interate over the rest.
This improves the performance in the edge case where there are
many small arguments that overflow the buffer.
* tests/misc/yes.sh: Add a test case for the many small arguments case.

10 years agoyes: output data more efficiently
Pádraig Brady [Mon, 9 Mar 2015 19:27:32 +0000 (19:27 +0000)] 
yes: output data more efficiently

yes(1) may be used to generate repeating patterns of text
for test inputs etc., so adjust to be more efficient.

Profiling the case where yes(1) is outputting small items
through stdio (which was the default case), shows the overhead
of continuously processing small items in main() and in stdio:

    $ yes >/dev/null & perf top -p $!
    31.02%  yes           [.] main
    27.36%  libc-2.20.so  [.] _IO_file_xsputn@@GLIBC_2.2.5
    14.51%  libc-2.20.so  [.] fputs_unlocked
    13.50%  libc-2.20.so  [.] strlen
    10.66%  libc-2.20.so  [.] __GI___mempcpy
     1.98%  yes           [.] fputs_unlocked@plta

Sending more data per stdio call improves the situation,
but still, there is significant stdio overhead due to memory copies,
and the repeated string length checking:

    $ yes "`echo {1..1000}`" >/dev/null & perf top -p $!
    42.26%  libc-2.20.so  [.] __GI___mempcpy
    17.38%  libc-2.20.so  [.] strlen
     5.21%  [kernel]      [k] __srcu_read_lock
     4.58%  [kernel]      [k] __srcu_read_unlock
     4.27%  libc-2.20.so  [.] _IO_file_xsputn@@GLIBC_2.2.5
     2.50%  libc-2.20.so  [.] __GI___libc_write
     2.45%  [kernel]      [k] system_call
     2.40%  [kernel]      [k] system_call_after_swapgs
     2.27%  [kernel]      [k] vfs_write
     2.09%  libc-2.20.so  [.] _IO_do_write@@GLIBC_2.2.5
     2.01%  [kernel]      [k] fsnotify
     1.95%  libc-2.20.so  [.] _IO_file_write@@GLIBC_2.2.5
     1.44%  yes           [.] main

We can avoid all stdio overhead by building up the buffer
_once_ and outputting that, and the profile below shows
the bottleneck moved to the kernel:

    $ src/yes >/dev/null & perf top -p $!
    15.42%  [kernel]      [k] __srcu_read_lock
    12.98%  [kernel]      [k] __srcu_read_unlock
     9.41%  libc-2.20.so  [.] __GI___libc_write
     9.11%  [kernel]      [k] vfs_write
     8.35%  [kernel]      [k] fsnotify
     8.02%  [kernel]      [k] system_call
     5.84%  [kernel]      [k] system_call_after_swapgs
     4.54%  [kernel]      [k] __fget_light
     3.98%  [kernel]      [k] sys_write
     3.65%  [kernel]      [k] selinux_file_permission
     3.44%  [kernel]      [k] rw_verify_area
     2.94%  [kernel]      [k] __fsnotify_parent
     2.76%  [kernel]      [k] security_file_permission
     2.39%  yes           [.] main
     2.17%  [kernel]      [k] __fdget_pos
     2.13%  [kernel]      [k] sysret_check
     0.81%  [kernel]      [k] write_null
     0.36%  yes           [.] write@plt

Note this change also ensures that yes(1) will only write
complete lines for lines shorter than BUFSIZ.

* src/yes.c (main): Build up a BUFSIZ buffer of lines,
and output that, rather than having stdio process each item.
* tests/misc/yes.sh: Add a new test for various buffer sizes.
* tests/local.mk: Reference the new test.
Fixes http://bugs.gnu.org/20029

10 years agobuild: fix make dependencies for test.1
Pádraig Brady [Sat, 7 Mar 2015 01:59:02 +0000 (01:59 +0000)] 
build: fix make dependencies for test.1

In certain parallel build situations this would give the error:
  help2man: can't get `--help' info from man/test.td/[
  Makefile:14189: recipe for target 'man/test.1' failed

* man/local.mk (test.1): Depend on `[` rather than `test`,
as `test --help` outputs nothing.  Also move dir.1 and vdir.1
back to the main list, as they're no more exceptions than
sha1sum etc.

10 years agomaint: be less strict about executable permissions of tests
Bernhard Voelker [Wed, 4 Mar 2015 22:25:57 +0000 (23:25 +0100)] 
maint: be less strict about executable permissions of tests

With "umask 0027" or even "umask 0077", the git clone of coreutils
does not have the executable bit set for 'other' (or 'group).
Therefore, "make syntax-check" would fail.

* cfg.mk (sc_tests_executable): Change the -perm argument of find(1)
to only print the names of the files which are not executable by the
user, rather than insisting on ugo+x (octal 111).

10 years agodoc: mention persistence caveats in sync man page
Stéphane Aulery [Thu, 5 Mar 2015 12:15:52 +0000 (12:15 +0000)] 
doc: mention persistence caveats in sync man page

* man/sync.x ([BUGS]): Mention the caveats and reference
the system call man pages for more details.
Fixes http://bugs.gnu.org/19995

Debian bug #507085 reported by jidanni@jidanni.org

10 years agotee: generalize the --write-error option to --output-error
Pádraig Brady [Mon, 2 Mar 2015 20:06:17 +0000 (20:06 +0000)] 
tee: generalize the --write-error option to --output-error

Adjust commit v8.23-140-gfdd6ebf to add the --output-error option
instead of --write-error, and treat open() errors like write() errors.

* doc/coreutils.texi (tee invocation): s/write-error/output-error/.
* src/tee.c (main): Exit on open() error if appropriate.
* tests/misc/tee.sh: Add a case to test open() errors.
* NEWS: Adjust for the more general output error behavior.

Suggested by Bernhard Voelker.

10 years agomaint: update stale comment about ls color sequences
Jarosław Gruca [Wed, 4 Mar 2015 11:44:58 +0000 (11:44 +0000)] 
maint: update stale comment about ls color sequences

* src/ls.c (color_indicator[C_END]): Comment with the correct
sequence, which was used since commit v6.10-61-g483297d
Fixes http://bugs.gnu.org/19992

10 years agotail,stat: improve support for the IBRIX file system
Shane M Seymour [Fri, 27 Feb 2015 17:52:51 +0000 (18:52 +0100)] 
tail,stat: improve support for the IBRIX file system

Note that IBRIX used to have a different magic number 0x013111A7
instead of the current 0x013111A8.  However, the former is no longer
used and the version of IBRIX it was used in is really ancient, so
it's extremely unlikely anyone is still using it.  Therefore, just
add the newer magic number.
Mark IBRIX as a 'remote' file system type as inotify support had
never been officially tested with it.

* src/stat.c (human_fstype): Add file system ID definition.
* NEWS: Mention the improvement.

Fixes http://bugs.gnu.org/19951

10 years agotee: add --write-error to control handling of closed pipes
Pádraig Brady [Mon, 16 Feb 2015 12:55:40 +0000 (12:55 +0000)] 
tee: add --write-error to control handling of closed pipes

tee is very often used with pipes and this gives better control
when writing to them.  There are 3 classes of file descriptors
that tee can write to: files(1), pipes(2), and early close pipes(3).
Handling write errors to 1 & 2 is supported at present with the caveat
that failure writing to any pipe will terminate tee immediately.
Handling write errors to type 3 is not currently supported.
To improve the supported combinations we add these options:

 --write-error=warn
   Warn if error writing any output including pipes.
   Allows continued writing to still open files/pipes.
   Exit status is failure if any output had error.
 --write-error=warn-nopipe, -p
   Warn if error writing any output except pipes.
   Allows continued writing to still open files/pipes.
   Exit status is failure if any non pipe output had error.
 --write-error=exit
   Exit if error writing any output including pipes.
 --write-error=exit-nopipe
   Exit if error writing any output except pipes.

Use the "nopipe" variants when files are of types 1 and 3, otherwise
use the standard variants with types 1 and 2.  A caveat with the above
scheme is that a combination of pipe types (2 & 3) is not supported
robustly.  I.e. if you use the "nopipe" variants when using both type
2 and 3 pipes, then any "real" errors on type 2 pipes will not be
diagnosed.
  Note also a general issue with type 3 pipes that are not on tee's
stdout, is that shell constructs don't allow to distinguish early
close from real failures.  For example `tee >(head -n1) | grep -m1 ..`
can't distinguish between an error or an early close in "head" pipe,
while the fail on the grep part of the pipe is distinguished
independently from the resulting pipe errors.  This is a general
issue with the >() construct, rather than with tee itself.

* NEWS: Mention the new feature.
* doc/coreutils.texi (tee invocation): Describe the new option.
* src/tee.c (usage): Likewise.
(main): With --write-error ignore SIGPIPE, and handle
the various exit, diagnostics combinations.
* tests/misc/tee.sh: Tess all the new options.
Fixes http://bugs.gnu.org/11540

10 years agotee: close "-" file
Bernhard Voelker [Mon, 23 Feb 2015 00:57:37 +0000 (01:57 +0100)] 
tee: close "-" file

This is a cleanup to the previous commit v8.23-138-g7ceaf1d.

* src/tee.c (tee_files): Do not exempt the "-" file from being closed,
as this is no longer stdout but a normal file.

10 years agotee: treat '-' operand as file name as mandated by POSIX
Bernhard Voelker [Fri, 20 Feb 2015 07:10:51 +0000 (08:10 +0100)] 
tee: treat '-' operand as file name as mandated by POSIX

Since v5.2.1-1247-g8dafbe5, tee(1) treated '-' as stdout while POSIX
explicitly requires to treat this as a file name.  Revert this change,
as the interleaved output - due to sending another copy of input to
stdout - is not considered to be useful.  Discussed in
http://lists.gnu.org/archive/html/coreutils/2015-02/msg00085.html

* src/tee.c (tee_files): Remove the special handling for "-" operands.
(usage): Remove the corresponding sentence.
* doc/coreutils.texi (common options): Remove the "tee -" example.
(tee invocation): Document that tee(1) now treats "-" as a file name.
* tests/misc/tee.sh: Add a test case for "tee -".
While at it, re-indent the above multi-argument processing case and
extend that to 13 operands, as POSIX mandates that, too.
* tests/misc/tee-dash.sh: Remove now-obsolete test.
* tests/local.mk (all_tests): Remove the above test.
* NEWS (Changes in behavior): Mention the change.

10 years agotee: exit early if no more writable outputs
Pádraig Brady [Mon, 16 Feb 2015 13:19:20 +0000 (13:19 +0000)] 
tee: exit early if no more writable outputs

* src/tee.c (main): Don't continue reading if we can't
output anywhere.
* tests/misc/tee.sh: Ensure we exit when no more outputs.
* NEWS: Mention the change in behavior.

10 years agotests: support stderr verification with returns_()
Pádraig Brady [Mon, 16 Feb 2015 17:20:39 +0000 (17:20 +0000)] 
tests: support stderr verification with returns_()

* tests/init.sh (returns_): Disable tracing for this wrapper
function, so that stderr of the wrapped command is unchanged,
allowing for verification of the contents.

10 years agomaint: prefer STREQ_LEN and STRPREFIX over strncmp in all cases
Bernhard Voelker [Tue, 17 Feb 2015 07:46:56 +0000 (08:46 +0100)] 
maint: prefer STREQ_LEN and STRPREFIX over strncmp in all cases

* cfg.mk (sc_prohibit_strncmp): Improve the search pattern: use
_sc_search_regexp to find all invocations of strncmp except when
used on a macro definition line; just match the function name with
an opening parenthesis.  Before, the expression missed places where
the comparison against 0 was in a subsequent line.
* src/system.h (STRNCMP_LIT): Shorten 'literal' to 'lit' to move
the whole definition of the macro into one line - thus making
sc_prohibit_strncmp pass.
(STRPREFIX): Add space before parenthesis.
* src/du.c (main): Prefer STREQ_LEN over strncmp.
* src/pinky.c (scan_entries): Likewise.
* src/tac.c (tac_seekable): Likewise.
* src/who.c (scan_entries): Likewise.

10 years agostty: fix setting of 'extproc' on BSD
Pádraig Brady [Thu, 12 Feb 2015 03:11:36 +0000 (03:11 +0000)] 
stty: fix setting of 'extproc' on BSD

This setting is unusual on BSD as it's read normally in the local
flags returned by tcgetattr(), but can only be set with an ioctl.
Setting with tcsetattr() is ignored.

* src/stty.c (NO_SETATTR): A new flag to indicate the setting
is read and displayed like a normal termios flag, but is set
in some other manner.
(main): Skip tcsetattr() for this setting when this flag is set.
Also fixup the exiting 'extproc' processing to handle the
'-extproc' case correctly.
(sane_mode): Skip setting '-extproc' for 'sane' to avoid the error.
This isn't ideal but matches the operation of the BSD native stty.

10 years agomaint: enhance '.mailmap' mappings for THANKS generation
Bernhard Voelker [Thu, 12 Feb 2015 13:21:40 +0000 (14:21 +0100)] 
maint: enhance '.mailmap' mappings for THANKS generation

* .mailmap (jeff.liu@oracle.com): There are 3 different names in the
'git log' output for this email address; choose "Jeff Liu" as canonical
form.
(Алексей Шилин): Convert name to latin1 ("Aleksej Shilin")
to improve the sort order of the generated 'THANKS' file.