]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
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.

10 years agomaint: sort THANKS using our own gear
Bernhard Voelker [Thu, 12 Feb 2015 01:35:07 +0000 (02:35 +0100)] 
maint: sort THANKS using our own gear

At least 'sort' on openSUSE/Fedora have a bug in the case-folding code
of their I18N downstream patch which leads to wrong sort results,
e.g. "Dániel" coming after "Dylan".

* Makefile.am (THANKS): Sort the final contributor list using our
own sort implementation - as others may result in a different order;
add a FIXME comment to remove this again once common platforms have
a functional 'sort -f'.  Add '-k1,1' for a better sort order.
While at it, save a grep and perl call to prepare the list from
'THANKS.in' by doing all in the first perl call.

10 years agomaint: remove redundant diff filtering from sc_long_lines
Pádraig Brady [Wed, 11 Feb 2015 13:26:38 +0000 (13:26 +0000)] 
maint: remove redundant diff filtering from sc_long_lines

* cfg.mk (sc_long_lines): diff files are now completely excluded,
so no need to filter portions of them.
Reported by Bernhard Voelker.

10 years agobuild: update to latest gnulib
Pádraig Brady [Wed, 11 Feb 2015 02:09:06 +0000 (02:09 +0000)] 
build: update to latest gnulib

This includes a change to require --with-libmount
to be used with configure, due to the many libmount dependencies.

* bootstrap: Sync with gnulib to exit early on gnulib-tool error.
* gl/lib/tempname.c.diff: Adjust for gnulib changes.
* gl/lib/tempname.h.diff: Likewise.
* gl/modules/tempname: Likewise.
* doc/.gitignore: Add new gendocs_template_min gnulib script.

10 years agomaint: exclude diff files from long lines check
Pádraig Brady [Wed, 11 Feb 2015 03:31:27 +0000 (03:31 +0000)] 
maint: exclude diff files from long lines check

* cfg.mk: Add .diff files to the exclusion expression
for sc_long_lines, since the gnulib code might be >= 80 chars.
Note 80 char lines trigger due to the added +/- diff marks.
Also normalize the $$ used in the other sc_long_lines exclusion
expressions.

10 years agomaint: avoid arbitrary memory access with buggy localtime()
Pádraig Brady [Mon, 9 Feb 2015 15:48:40 +0000 (15:48 +0000)] 
maint: avoid arbitrary memory access with buggy localtime()

* src/ls.c (align_nstrftime): Be defensive and validate the tm_mon
index before using to access the abmon array.  This was _not_ seen
to be an issue any system.  See https://bugzilla.redhat.com/1190454

10 years agodoc: give an example of using a seed for random operations
Pádraig Brady [Mon, 9 Feb 2015 20:58:47 +0000 (20:58 +0000)] 
doc: give an example of using a seed for random operations

* doc/coreutils.texi (Random sources):  Give an example using openssl,
generating a reproducible arbitrary amount of randomly distributed
data, given a seed value.

10 years agomaint: make sc_dd_O_FLAGS more robust
Bernhard Voelker [Mon, 9 Feb 2015 07:19:01 +0000 (08:19 +0100)] 
maint: make sc_dd_O_FLAGS more robust

The construct "diff ... || diff=1 || diff=" does not set the variable
in all cases.  This could be triggered with:

  $ env make diff=1 make sc_dd_O_FLAGS
  dd_O_FLAGS
  maint.mk: ./src/dd.c has inconsistent O_ flag lists
  cfg.mk:59: recipe for target 'sc_dd_O_FLAGS' failed
  make: *** [sc_dd_O_FLAGS] Error 1

* cfg.mk (sc_dd_O_FLAGS): Remember $? of the diff command directly
and check its value later rather than using the  above mentioned
mapping.

10 years agomaint: make sc_THANKS_in_duplicates more robust
Bernhard Voelker [Mon, 9 Feb 2015 07:18:15 +0000 (08:18 +0100)] 
maint: make sc_THANKS_in_duplicates more robust

The previous commit v8.23-124-g7b1ca5f made the above syntax-check rule
fail, because that took the whole content of THANKS.in for comparison.

* cfg.mk (sc_THANKS_in_duplicates): Strip off the header (all before the
first empty line) and the footer (all past the next empty line) from
'THANKS.in' for the check.

10 years agomaint: sort contributors in THANKS.in
Bernhard Voelker [Mon, 9 Feb 2015 01:42:40 +0000 (02:42 +0100)] 
maint: sort contributors in THANKS.in

* THANKS.in: Document the preferred sort order as a comment
at the top of the file.  Change "Марк Коренберг" to latin1
("Mark Korenberg").  Sort all entries.
* cfg.mk (sc_THANKS_in_sorted): Add rule to ensure that
'THANKS.in' remains sorted.

10 years agomaint: document a caveat in the tail inotify implementation
Pádraig Brady [Thu, 5 Feb 2015 13:59:12 +0000 (13:59 +0000)] 
maint: document a caveat in the tail inotify implementation

* src/tail.c (main): Document another caveat with the
inotify implementation wrt multiple hardlinked files.

10 years agotail: return inotify resources where possible
Pádraig Brady [Thu, 5 Feb 2015 13:10:49 +0000 (13:10 +0000)] 
tail: return inotify resources where possible

Each user has a maximum number of inotify watches,
so handle the cases where we exhaust these resources.

* src/tail.c (tail_forever_inotify): Ensure we inotify_rm_watch()
the watch for an inode, when replacing with a new watch for a name.
Return all used inotify resources when reverting to polling.
Revert to polling upon first indication of inotify resource exhaustion.
Revert to polling on any inotify resource exhaustion.
Diagnose resource exhaustion correctly in all cases.
Avoid redundant reinsertion in the hash for unchanged watches
(where only attributes of the file are changed).
* tests/tail-2/retry.sh: Avoid false failure when reverting to polling.
* tests/tail-2/inotify-rotate.sh: Likewise.
* tests/tail-2/symlink.sh: Likewise.
* tests/tail-2/inotify-rotate-resources.sh: New test to check
that we're calling inotify_rm_watch() for replaced files.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
* THANKS.in: Thanks for reporting and problem identification.

10 years agotests: fix recent regression in tail inotify test
Pádraig Brady [Thu, 5 Feb 2015 16:32:49 +0000 (16:32 +0000)] 
tests: fix recent regression in tail inotify test

* tests/tail-2/inotify-rotate.sh (cleanup_fail_): Set fail=1
so that failures are identified.  Regression in v8.23-63-g111a2b9
Also use print_ver_ rather than open coding --verbose support.
Also check for more than a single 'b' which seems brittle.

10 years agobuild: ensure make-prime-list doesn't access out of bounds memory
Yury Usishchev [Thu, 5 Feb 2015 23:04:29 +0000 (23:04 +0000)] 
build: ensure make-prime-list doesn't access out of bounds memory

The -fsanitize=address run associated with v8.22-75-gf940fec
failed to check make-prime-list, as src/primes.h is not
regenerated with `make clean`.  Running with -fsanitize=address
indicates a read 1 byte beyond the allocated buffer.

  $ rm src/make-prime-list.o
  $ make AM_CFLAGS=-fsanitize=address src/make-prime-list
  $ src/make-prime-list 5000

=================================================================
==13913==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61e00000fa43 at pc 0x4016f5 bp 0x7fff9d9840e0 sp 0x7fff9d9840d0
READ of size 1 at 0x61e00000fa43 thread T0
    #0 0x4016f4 in main src/make-prime-list.c:214
    #1 0x7f98892c5fdf in __libc_start_main (/lib64/libc.so.6+0x1ffdf)
    #2 0x401774 (src/make-prime-list+0x401774)

0x61e00000fa43 is located 0 bytes to the right of 2499-byte
region [0x61e00000f080,0x61e00000fa43) allocated by thread T0 here:
    #0 0x7f98896ba7b7 in malloc (/lib64/libasan.so.1+0x577b7)
    #1 0x400f3f in xalloc src/make-prime-list.c:163
    #2 0x400f3f in main src/make-prime-list.c:198

SUMMARY: AddressSanitizer: heap-buffer-overflow
src/make-prime-list.c:214 main
Shadow bytes around the buggy address:
  0x0c3c7fff9ef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c3c7fff9f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c3c7fff9f10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c3c7fff9f20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c3c7fff9f30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c3c7fff9f40: 00 00 00 00 00 00 00 00[03]fa fa fa fa fa fa fa
  0x0c3c7fff9f50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c3c7fff9f60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c3c7fff9f70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c3c7fff9f80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c3c7fff9f90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:     fa
  ...
==13913==ABORTING

* src/make-prime-list.c (main): Bounds check the incremented index,
before using to access the buffer.
Fixes http://bugs.gnu.org/19784

10 years agobuild: fix invalid gnulib patch
Pádraig Brady [Tue, 3 Feb 2015 03:15:10 +0000 (03:15 +0000)] 
build: fix invalid gnulib patch

* gl/lib/tempname.c.diff: Fix recent breakage so it applies again.
Invalid patch was noticed at http://hydra.nixos.org/eval/1172233
* cfg.mk: Exempt diff files from these "id_est" syntax checks.
(sc_ensure_gl_diffs_apply): A new syntax check, to ensure all
patches under gl/ apply cleanly.  Note we use --fuzz=0 to check
patches apply cleanly for safety, due to the patch(1) issue detailed
in commit v8.21-117-g46f7e05
* gl/lib/regcomp.c.diff: Rediffed.
* gl/lib/regex_internal.c.diff: Likewise.
* gl/lib/regex_internal.h.diff: Likewise.
* gl/lib/regexec.c.diff: Likewise.
* gl/lib/tempname.h.diff: Likewise.

10 years agotests: avoid a FP on aarch64 when comparing env/printenv output
Bernhard Voelker [Tue, 3 Feb 2015 00:52:04 +0000 (01:52 +0100)] 
tests: avoid a FP on aarch64 when comparing env/printenv output

The following test fails on aarch64 on openSUSE's OpenBuildService
due to glibc's execvp reversing the pointers of 'environ', i.e.,
the output of "env|tac" equals "env env" on that platform.

* tests/misc/printenv.sh: Use 'env env' to work around the behavior
on that platform.
While at it, fix the grep pattern which suppressed all environment
variables starting with an underscore "_" instead of "$_" (and
"$LD_PRELOAD") only.

10 years agodircolors: sync with Xiph file extensions
Pádraig Brady [Mon, 2 Feb 2015 15:55:28 +0000 (15:55 +0000)] 
dircolors: sync with Xiph file extensions

* src/dircolors.hin: Remove deprecated anx, axa, axv.  Add opus.
Suggested by Scott Teal.

10 years agodoc,maint: fix use of "i.e." in documentation and comments
Bernhard Voelker [Sat, 31 Jan 2015 16:39:04 +0000 (17:39 +0100)] 
doc,maint: fix use of "i.e." in documentation and comments

To align with all other places (and correct grammar), change all
upper-case "I.E." to "I.e.".  Furthermore, ensure that "i.e." is
followed by a comma.  Finally, ensure to use a double-space before
"I.e.," at the beginning of a sentence.

The following was used to change all offending uses (apart from
old ChangeLog files):

  $ git grep -liF 'i.e.' \
      | xargs sed -i \
            -e 's/I\.E\./I.e./g' \
            -e 's/\. \(I\.e\.\)/.  \1/g' \
            -e 's/\([Ii]\.e\.\)\( \)/\1,\2/g' \
            -e 's/\([Ii]\.e\.\)$/\1,/g'

* cfg.mk (sc_prohibit_uppercase_id_est): Add new rule.
(sc_ensure_double_space_after_dot_before_id_est): Likewise.
(sc_ensure_comma_after_id_est): Likewise.
(old_NEWS_hash): Refresh hash via "make update-NEWS-hash".
* NEWS: Change use of "id est" abbreviation via the above command.
* README: Likewise.
* README-prereq: Likewise.
* doc/coreutils.texi: Likewise.
* gl/lib/rand-isaac.c: Likewise.
* gl/lib/tempname.c.diff: Likewise.
* man/stdbuf.x: Likewise.
* src/cat.c: Likewise.
* src/copy.c: Likewise.
* src/copy.h: Likewise.
* src/cp.c: Likewise.
* src/cut.c: Likewise.
* src/dd.c: Likewise.
* src/df.c: Likewise.
* src/fiemap.h: Likewise.
* src/longlong.h: Likewise.
* src/ls.c: Likewise.
* src/numfmt.c: Likewise.
* src/pr.c: Likewise.
* src/shred.c: Likewise.
* src/shuf.c: Likewise.
* src/split.c: Likewise.
* tests/Coreutils.pm: Likewise.
* tests/df/df-symlink.sh: Likewise.
* tests/df/skip-rootfs.sh: Likewise.
* tests/init.sh: Likewise.
* tests/ls/color-norm.sh: Likewise.
* tests/misc/basename.pl: Likewise.
* tests/misc/ls-misc.pl: Likewise.
* tests/misc/md5sum-bsd.sh: Likewise.
* tests/misc/shred-exact.sh: Likewise.
* tests/misc/sort.pl: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/tac-continue.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/tail-2/symlink.sh: Likewise.

10 years agodoc: clarify the output format for the *sum utilities
Pádraig Brady [Thu, 29 Jan 2015 18:44:41 +0000 (18:44 +0000)] 
doc: clarify the output format for the *sum utilities

* src/md5sum.c (usage): Detail the reasons for the default
double space between checksum and file name.
* doc/coreutils.texi (md5sum invocation): Likewise.
Explicitly mention the 3 formats that --check supports.

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

10 years agosync: support syncing specified arguments
Giuseppe Scrivano [Sun, 25 Jan 2015 00:33:45 +0000 (01:33 +0100)] 
sync: support syncing specified arguments

* m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs().
* man/sync.x: Add references to syncfs, fsync and fdatasync.
* doc/coreutils.texi (sync invocation): Document the new feature.
* src/sync.c: Include "quote.h".
(AUTHORS): Include myself.
(MODE_FILE, MODE_DATA, MODE_FILE_SYSTEM, MODE_SYNC): New enum values.
(long_options): Define.
(sync_arg): New function.
(usage): Describe that arguments are now accepted.
(main): Add arguments parsing and add support for fsync(2),
fdatasync(2) and syncfs(2).
* tests/misc/sync.sh: New (and only) test for sync.
* tests/local.mk: Reference the new test.
* AUTHORS: Add myself to sync's authors.
* NEWS: Mention the new feature.

10 years agoscripts: autotools-install: update
Jim Meyering [Tue, 6 Jan 2015 15:51:01 +0000 (07:51 -0800)] 
scripts: autotools-install: update

* scripts/autotools-install: Increase automake's version number
to 1.15 and add Stefano Lattarini's new GPG key ID.
Increase gettext's version to 0.19.4 and add Daiki Ueno's GPG key ID.
Also move VERSION definition "up" so that it is once again
automatically updated via the emacs hook snippet at the end
of the file.

10 years agostty: only print supported options for combined options
Pádraig Brady [Fri, 23 Jan 2015 03:09:16 +0000 (03:09 +0000)] 
stty: only print supported options for combined options

* src/stty.c (usage): Don't reference unsupported options,
in the combined options descriptions.
* doc/coreutils.texi (stty invocation): Adjust for the
new order of the 'sane' and 'raw' combined options.
Also add -iutf8 to the 'sane' list.

10 years agostty: document the 'status' character where supported
Pádraig Brady [Fri, 23 Jan 2015 01:26:29 +0000 (01:26 +0000)] 
stty: document the 'status' character where supported

* src/stty.c (usage): On systems that support this setting (BSD),
display 'status' in the list of adjustable special characters.
* doc/coreutils.texi (stty invocation): Mention the option, and that
it's not currently supported on Linux.

10 years agostty: document the 'discard' character setting
Pádraig Brady [Fri, 23 Jan 2015 00:43:58 +0000 (00:43 +0000)] 
stty: document the 'discard' character setting

The equivalent of this is 'flush', but that was never documented
as an option (though was output with stty -a).  Therefore use
the more descriptive name, also generally used on BSD systems.
Note even though this setting seems ineffective on Linux, supporting
the setting is useful to allow terminal programs to receive
the default ^O character code.

* doc/coreutils.texi (stty invocation): Document the 'discard' option.
* src/stty.c (struct control_info): Add 'discard'; same as 'flush'.
(display_all): Show 'discard' rather than 'flush' char.
(display_changed): Likewise.
(usage): Document the 'discard' option.

10 years agostty: add support for extproc/LINEMODE
Pádraig Brady [Wed, 21 Jan 2015 18:11:06 +0000 (18:11 +0000)] 
stty: add support for extproc/LINEMODE

Add support for the "extproc" option which is well described at:
http://lists.gnu.org/archive/html/bug-readline/2011-01/msg00004.html

* src/stty.c (usage): Describe the extproc option if either the
Linux EXTPROC local option is defined, or the equivalent
BSD TIOCEXT ioctl is defined.
(main): Make the separate ioctl call for extproc on BSD.
* doc/coreutils.texi (stty invocation): Describe the option,
and reference the related RFC 1116.
* NEWS: Mention the new feature.

10 years agotests: use returns_ function for new split test
Bernhard Voelker [Tue, 20 Jan 2015 00:54:55 +0000 (01:54 +0100)] 
tests: use returns_ function for new split test

* tests/split/record-sep.sh: Use the recently added returns_ function
to simplify the shell syntax in this test.  Also remove the redirection
of stdout/stderr to /dev/null as this eases analyzing errors.

10 years agosplit: new -t option to select record separator
Assaf Gordon [Wed, 7 Jan 2015 23:30:28 +0000 (18:30 -0500)] 
split: new -t option to select record separator

* src/split.c (eolchar): A new variable to hold
the separator character (unibyte for now).
This is reference throughout rather than hardcoding '\n'.
(usage): Describe the new --separator option, and
mention records along with lines so there is no ambiguity
that all options treat lines and records equivalently.
(main): Have -t update eolchar, or default to '\n'.
* tests/split/record-sep.sh: New test case.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (split invocation): Document the new option.
Adjust --lines, --line-bytes, --number=[lr]/... to mention
they pertain to records if --separator is specified.
* NEWS: Mention the new feature.

10 years agomaint: fix typo in THANKS.in in previous commit
Pádraig Brady [Mon, 19 Jan 2015 23:17:29 +0000 (23:17 +0000)] 
maint: fix typo in THANKS.in in previous commit

* THANKS.in: s/Stehpen/Stephen/

10 years agodoc: clarify that du operands are interdependent
Pádraig Brady [Mon, 19 Jan 2015 10:52:54 +0000 (10:52 +0000)] 
doc: clarify that du operands are interdependent

Following on from http://bugs.gnu.org/17546
make it more obvious that du may elide specified operands
to avoid double counting in the set.

* src/du.c (usage): Specify that du operates on the set of
operands, rather than each independently.
* doc/coreutils.texi (du invocation): Likewise.  Also state
that the number of entries printed may change due to the
order specified.  Currently, deeper items specified earlier
will result in them being displayed, but don't mention that
implementation detail in the documentation.
* THANKS.in: Add reporter.
Reported by Stephen Shirley

10 years agotests: use compare-vs-/dev/null instead of 'test -s'
Bernhard Voelker [Wed, 14 Jan 2015 16:38:12 +0000 (17:38 +0100)] 
tests: use compare-vs-/dev/null instead of 'test -s'

When some program produces unexpected output, that use of
compare-vs-/dev/null will ensure that the surprising output is
printed in the test's output.  With "test -s err" only, one
would have to instrument and rerun in order to see the offending
output.

* cfg.mk (sc_prohibit_and_fail_1): Exempt 'compare' from this check.
* tests/dd/misc.sh: Change "tests -s ... || fail=1" to
"compare /dev/null ... && fail=1".
* tests/misc/nice.sh: Likewise.
* tests/rm/read-only.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/touch/no-dereference.sh: Likewise.

Suggested by Jim Meyering in
http://lists.gnu.org/archive/html/coreutils/2015-01/msg00042.html

10 years agotests: add extra protection against unexpected exits
Pádraig Brady [Tue, 13 Jan 2015 03:30:33 +0000 (03:30 +0000)] 
tests: add extra protection against unexpected exits

Many tests use `program ... && fail=1` to ensure expected
error situations are indicated.  However that would mask
an unexpected exit (like a crash).  Therefore explicitly
check the expected exit code.
Note where error messages are also verified, the extra
protection is not added.

* tests/init.sh (returns_): A new helper function to
check the return code of a command, and used
throughout the tests.
* cfg.mk (sc_prohibit_and_fail_1): Add a syntax check
to avoid new instances of this issue.

10 years agotests: avoid skipping some df tests with libmount
Pádraig Brady [Mon, 12 Jan 2015 01:14:11 +0000 (01:14 +0000)] 
tests: avoid skipping some df tests with libmount

* tests/df/no-mtab-status.sh: Provide libmount placeholders,
to avoid skipping the test when libmount is in use.
* tests/df/skip-duplicates.sh: Likewise.
* tests/df/skip-rootfs.sh: Comment that the test is moot
when libmount (/proc/self/mountinfo) is being used.

10 years agomaint: clean up some test issues identified with shellcheck
Pádraig Brady [Sat, 10 Jan 2015 21:12:38 +0000 (21:12 +0000)] 
maint: clean up some test issues identified with shellcheck

* tests/cp/cp-a-selinux.sh: Comment why unused variables are assigned.
Fix misspellings noticed while adjusting.
* tests/cp/fiemap-perf.sh: Fix quoting.
* tests/misc/shuf.sh: Avoid useless use of cat.
* tests/misc/printf-surprise.sh: Likewise.

10 years agomaint: adjustments related to previous shuf crash fix
Daiki Ueno [Tue, 6 Jan 2015 03:36:57 +0000 (03:36 +0000)] 
maint: adjustments related to previous shuf crash fix

* tests/misc/shuf.sh: Improve the test so it detects
crashes in more cases.
* NEWS: Mention the previous fix.

10 years agomaint: skip long-lines syntax-check if unsupported
Assaf Gordon [Thu, 8 Jan 2015 06:20:06 +0000 (01:20 -0500)] 
maint: skip long-lines syntax-check if unsupported

* cfg.mk(sc_long_lines): Skip if required wc and sed options
are not supported, which is currently the case on OS X.

10 years agoshuf: do not mishandle 'shuf -i0-0 1'
Paul Eggert [Tue, 6 Jan 2015 03:40:03 +0000 (19:40 -0800)] 
shuf: do not mishandle 'shuf -i0-0 1'

Problem reported by Daiki Ueno in: http://bugs.gnu.org/19520
* src/shuf.c (main): Avoid core dump if !input_range.
* tests/misc/shuf.sh: Test for this bug.

10 years agomaint: update further copyright year number ranges
Bernhard Voelker [Thu, 1 Jan 2015 18:56:25 +0000 (19:56 +0100)] 
maint: update further copyright year number ranges

* bootstrap: Update copyright year manually (missing in previous
gnulib update).
* tests/init.sh: Likewise.

The entries in the exemption list are processed by
"grep -vEf ./.x-update-copyright", and therefore evaluated as an
extended regular expression (ERE).  Thus, the "bootstrap" entry
also matched for bootstrap.conf which we want to be updated.

* .x-update-copyright: Change all entries to EREs, i.e. including
the caret ^ and dollar sign $ meta-characters matching the beginning
and the end of a line.
* bootstrap.conf: Update copyright year by "make update-copyright".

Finally, the only one showing up with the following command should
be the COPYING file:
  $ git grep 'Copyright .* Free Software' | grep -v '2015 Free Software'

10 years agodoc: fix man page formatting for split CHUNKS options
Pádraig Brady [Thu, 1 Jan 2015 18:05:10 +0000 (18:05 +0000)] 
doc: fix man page formatting for split CHUNKS options

* src/split.c (usage): Indent the info on CHUNKS so that
help2man can match it and align appropriately in its own section.
Fixes http://bugs.gnu.org/19228

10 years agobuild: update to latest gnulib
Pádraig Brady [Thu, 1 Jan 2015 05:02:29 +0000 (05:02 +0000)] 
build: update to latest gnulib

Pick up an errno adjustment in xstrtol() that fixes
a spurious test failure on Darwin 14.0.0.
Also update copyright year to 2015 avoiding a syntax-check failure.

10 years agomaint: update all copyright year number ranges
Pádraig Brady [Thu, 1 Jan 2015 04:49:02 +0000 (04:49 +0000)] 
maint: update all copyright year number ranges

Run "make update-copyright" and then...

* tests/sample-test: Adjust to use the single most recent year.
* tests/du/bind-mount-dir-cycle-v2.sh: Fix case in copyright message,
so that year is updated automatically in future.

10 years agotests: fix possible 8 minute running time of inotify-rotate.sh
Pádraig Brady [Tue, 30 Dec 2014 01:25:17 +0000 (01:25 +0000)] 
tests: fix possible 8 minute running time of inotify-rotate.sh

Commit v8.23-63-g111a2b9 removed the expensive tag on this test,
as it runs quickly on systems with inotify.  However without that
it would take about 8 minutes for the test to complete all iterations.

* tests/tail-2/inotify-rotate.sh: Tag as expensive without inotify.
Also adjust the polling parameters used on systems without inotify
so that the test completes within about 15 seconds.

10 years agobuild: update to latest gnulib
Pádraig Brady [Mon, 29 Dec 2014 22:33:25 +0000 (22:33 +0000)] 
build: update to latest gnulib

Included in this are gnulib changes 3ea43e02 2768ceb7
which make the device IDs from /proc/self/mountinfo
available to df.  This can be leveraged by a subsequent
change to df to present a more accurate list of file systems.

* bootstrap: Merge from gnulib.
* src/ls.c (dev_ino_pop): s/obstack_blank/obstack_blank_fast/
as this API/ABI has changed, giving memory exhausted errors
if negative (large positive) numbers are passed to obstack_blank().
* tests/df/skip-duplicates.sh: Adjust as the new gnulib code
requires a non NULL mnt_opts even when mnt_type is not "none".

10 years agomaint: remove duplicate names from THANKS
Pádraig Brady [Mon, 29 Dec 2014 23:17:22 +0000 (23:17 +0000)] 
maint: remove duplicate names from THANKS

* .mailmap: Adjust so that there is only a single
entry per name in the generated THANKS.

10 years agodoc: update the URL referencing SI prefixes
Pádraig Brady [Fri, 26 Dec 2014 14:37:15 +0000 (14:37 +0000)] 
doc: update the URL referencing SI prefixes

Identified at https://www.gnu.org/software/gnun/linc/linc.html

* doc/coreutils.texi (Block size): Fix the stale link.