]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
6 years agoshred,sort,split: add NEWS item
Paul Eggert [Sat, 15 Dec 2018 20:42:18 +0000 (12:42 -0800)] 
shred,sort,split: add NEWS item

6 years agoshred,sort,split: fix ftruncate error reporting
Paul Eggert [Sat, 15 Dec 2018 20:13:58 +0000 (12:13 -0800)] 
shred,sort,split: fix ftruncate error reporting

Problem reported for split by Scott Worley (Bug#33761):
* src/shred.c (do_wipefd):
Also report an error if ftruncate fails on a shared memory object.
* src/sort.c (get_outstatus): New function.
(stream_open, avoid_trashing_input): Use it.
* src/sort.c (stream_open):
* src/split.c (create):
If ftruncate fails, do not report an error
unless it is a regular file or a shared memory object.

6 years agosync: add NEWS and test for the fix in the previous commit
Bernhard Voelker [Tue, 6 Nov 2018 23:26:01 +0000 (00:26 +0100)] 
sync: add NEWS and test for the fix in the previous commit

* NEWS (Bug fixes): Mention the fix in commit 94d364f157f0.
While at it, remove duplicate "Changes in behavior" heading.
* tests/misc/sync.sh: Add a test with a write-only file for the fix.

6 years agosync: fix open fallback bug
Paul Eggert [Tue, 6 Nov 2018 18:35:16 +0000 (10:35 -0800)] 
sync: fix open fallback bug

Problem caught by Coverity Analysis
and reported by Kamil Dudka (Bug#33287).
* src/sync.c (sync_arg): Fix typo in fallback code.

6 years agoln: use linkat and symlinkat
Paul Eggert [Sun, 28 Oct 2018 08:45:17 +0000 (01:45 -0700)] 
ln: use linkat and symlinkat

Open a target directory and use its file descriptor in linkat,
symlinkat, etc. syscalls, instead of constructing long file names
by concatenating the target directory name to a basename.
This avoids O(N²) behavior with ‘ln F1 F2 ... Fn DIR’ when DIR is
a long file name with many slashes.  It also avoids some races if
DIR is renamed while ln is running.
* bootstrap.conf (gnulib_modules): Add openat-safer.
* src/ln.c: Include fcntl-safer.h.
(O_PATHSEARCH): New constant.
(errno_nonexisting, target_directory_operand): Remove; no longer used.
(atomic_link, do_link): New arg DESTDIR_FD.  All uses changed.
(do_link): New arg DEST_BASE.  All uses changed.
(main): Open target directory and use its file descriptor
as DESTDIR_FD.

6 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 28 Oct 2018 08:13:57 +0000 (01:13 -0700)] 
build: update gnulib submodule to latest

* src/copy.c (copy_internal):
* src/cp.c (do_copy):
* src/ln.c (do_link):
Adjust to Gnulib API change.

6 years agotests: provide 100% coverage for echo
Bernhard Voelker [Mon, 24 Sep 2018 21:47:39 +0000 (23:47 +0200)] 
tests: provide 100% coverage for echo

*  src/echo.c (usage): Assert that STATUS is always EXIT_SUCCESS.
* tests/misc/echo.sh: Add further tests for all hex and escape and
escape characters.

To get coverage statistics, run:
  make coverage -j 4 TESTS=tests/misc/echo.sh SUBDIRS=.
  xdg-open doc/coverage/src/echo.c.gcov.frameset.html

6 years agoecho: always process escapes when POSIXLY_CORRECT is set
Pádraig Brady [Mon, 24 Sep 2018 02:35:24 +0000 (19:35 -0700)] 
echo: always process escapes when POSIXLY_CORRECT is set

* src/echo.c (main): Always enable backslash processing if
POSIXLY_CORRECT is set.
* tests/misc/echo.sh: Add (the first) test for the echo command.
* tests/local.mk: Reference the new test.
* tests/misc/printf.sh: Update a stale comment.
* doc/coreutils.texi (echo invocation). Mention that POSIXLY_CORRECT
now always enables backslash processing.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/32703
Issue identified by Eric Blake.

6 years agotest: add -N unary operator
Bernhard Voelker [Sun, 21 Oct 2018 22:54:51 +0000 (00:54 +0200)] 
test: add -N unary operator

Bash knows 'test -N FILE'.  Add it to GNU 'test' as well.

* src/test.c (unary_operator): Add a case for 'N'.
(usage): Document it.
* doc/coreutils.texi (node File characteristic tests): Likewise.
* NEWS (New features): Likewise.
* tests/misc/test-N.sh: Add a test.
* tests/local.mk (all_tests): Reference it.

6 years agotest: simplify redundant code
Bernhard Voelker [Sun, 21 Oct 2018 19:56:43 +0000 (21:56 +0200)] 
test: simplify redundant code

Remove the function 'test_unop', as the cases therein are redundant to
those handled by 'unary_operator'; exception: the cases 'o' and 'N':
they had been present in test_unop and handling the commands
  test -N STR
  test -o STR
and
  test x = x -a -N STR
  test x = x -a -o STR
which ran into an error later on anyway.
With this commit, the error diagnostic will change from ...
  $ /usr/bin/test -N STR
  /usr/bin/test: extra argument '-N'
  $ /usr/bin/test -o STR
  /usr/bin/test: extra argument '-o'
... to ...
  $ src/test -N STR
  src/test: '-N': unary operator expected
  $ src/test -o STR
  src/test: '-o': unary operator expected

* src/test.c (test_unop): Remove.
(unary_operator): Fail with test_syntax_error in the default case.
(term): Directly call unary_operator.
(two_arguments): Likewise.
* tests/misc/test-diag.pl: Adjust error diagnostic.

6 years agotest: remove support for the ambigous -a unary operator
Bernhard Voelker [Sun, 21 Oct 2018 19:17:31 +0000 (21:17 +0200)] 
test: remove support for the ambigous -a unary operator

* src/test.c (unary_operator): Remove case 'a'.
(test_unop): Likewise.
* NEWS (Changes in behavior): Document the change.

Discussed at https://bugs.gnu.org/33097

6 years agotest: avoid FP in chroot-credentials.sh for different group list order
Bernhard Voelker [Sat, 20 Oct 2018 00:00:11 +0000 (02:00 +0200)] 
test: avoid FP in chroot-credentials.sh for different group list order

On my openSUSE:Tumbleweed system, I get a false positive test failure
in the above 'check-root' test because the group lists inside and
outside the chroot have a different order:

  ++ chroot --userspec=berny / id -G
  ++ id -G berny
  + test '100 454 457 480 492' = '100 480 492 457 454'
  + fail=1

* tests/misc/chroot-credentials.sh (num_sort): Add function to sort
group lists, and use it in the test cases which test multiple groups.

6 years agodoc: tidy up setuid commentary
Paul Eggert [Sat, 20 Oct 2018 17:45:35 +0000 (10:45 -0700)] 
doc: tidy up setuid commentary

* doc/perm.texi (Mode Structure): Improve wording.
(Numeric Modes): Don’t say “on execution” (Bug#9594).

6 years agoln: avoid directory hard-link races
Paul Eggert [Fri, 19 Oct 2018 19:19:43 +0000 (12:19 -0700)] 
ln: avoid directory hard-link races

Previously, 'ln A B' did 'stat("B"), lstat("A"), link("A","B")'
where the stat and lstat were necessary to avoid hard-linking
directories on systems that can hard-link directories.
Now, in situations that prohibit hard links to directories,
'ln A B' merely does 'link("A","B")'.  The new behavior
avoids some races and should be more efficient.
This patch was inspired by Bug#10020, which was about 'ln'.
* bootstrap.conf (gnulib_modules): Add unlinkdir.
* src/force-link.c (force_linkat, force_symlinkat): New arg for
error number of previous try.  Return error number, 0, or -1 if
error, success, or success after removal.  All callers changed.
* src/ln.c: Include priv-set.h, unlinkdir.h.
(beware_hard_dir_link): New static var.
(errnoize, atomic_link): New functions.
(target_directory_operand): Use errnoize for simplicity.
(do_link): New arg for error number of previous try.  All callers
changed.  Do each link atomically if possible.
(main): Do -r check earlier.  Remove linkdir privileges so we can
use a single linkat/symlinkat instead of a racy substitute for the
common case of 'ln A B' and 'ln -s A B'.  Set beware_hard_dir_link
to disable this optimization.

6 years agocp: 'cp -il A B' no longer fails if user OKs it
Paul Eggert [Fri, 19 Oct 2018 19:19:43 +0000 (12:19 -0700)] 
cp: 'cp -il A B' no longer fails if user OKs it

* NEWS: Mention the change.
* src/copy.c (copy_internal): Replace the link if the
user has okayed it.

6 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 19 Oct 2018 19:19:43 +0000 (12:19 -0700)] 
build: update gnulib submodule to latest

* gl/modules/tempname.diff: Update to match Gnulib.

6 years agodoc: add chmod examples
Paul Eggert [Tue, 27 Mar 2012 15:52:20 +0000 (08:52 -0700)] 
doc: add chmod examples

Discussed in https://bugs.gnu.org/11043 .

* doc/coreutils.texi (chmod invocation): Add examples.

6 years agodoc: fix minor mistakes in "env.x"
Bjarni Ingi Gislason [Mon, 1 Oct 2018 21:40:27 +0000 (21:40 +0000)] 
doc: fix minor mistakes in "env.x"

* man/env.x (OPTIONS): Fix a spelling mistake.  Protect a period at the
beginning of a line.

6 years agoid: support multiple specified users
Achilles Gaikwad [Mon, 23 Jul 2018 19:39:13 +0000 (01:09 +0530)] 
id: support multiple specified users

  $ id root nobody
  uid=0(root) gid=0(root) groups=0(root)
  uid=99(nobody) gid=99(nobody) groups=99(nobody)

* src/id.c (main): Make variables opt_zero, just_group_list,
just_group, use_real, just_user global to be used in a new
function.
(print_stuff): New function that will print user and group
information for the specified USER.
When using -G option delimit each record with two NULs.
Restructure the code in the file to have global variables
followed by functions.
* tests/id/zero.sh: Add test cases to check the usage
of -z option with multiple users.
* tests/id/uid.sh: Add a test case to ensure all users
are queried in the presence of errors.
* doc/coreutils.texi: Document the interface changes.
* NEWS: Mention the new feature.

6 years agodoc: csplit: clarify handling of regexps with negative offsets
Stéphane Campinas [Tue, 25 Sep 2018 06:29:39 +0000 (23:29 -0700)] 
doc: csplit: clarify handling of regexps with negative offsets

* doc/coreutils.texi (csplit invocation): Detail the behavior
with regexp patterns and negative offsets, which differs from
line number patterns, to avoid looping on the input.  For example:
  $ seq 50 | csplit -s - /15/-5 /12/
  csplit: ‘/12/’: match not found

6 years agodoc: csplit: clarify input may not be reproducible from output
Pádraig Brady [Mon, 24 Sep 2018 04:14:08 +0000 (21:14 -0700)] 
doc: csplit: clarify input may not be reproducible from output

* doc/coreutils.texi (csplit invocation): Clarify that
portions of the input may be skipped and thus the input
may not be reproducible by just concatenating the output files.
Fixes https://bugs.gnu.org/32317

7 years agodf: omit redundant comparison
Paul Eggert [Fri, 27 Jul 2018 19:00:02 +0000 (12:00 -0700)] 
df: omit redundant comparison

Trivial inefficiency reported by Bruno Haible in:
http://lists.gnu.org/r/bug-gnulib/2018-07/msg00109.html
* src/df.c (hide_problematic_chars): Omit redundant test.

7 years agodf: tune slightly
Paul Eggert [Thu, 26 Jul 2018 08:56:28 +0000 (01:56 -0700)] 
df: tune slightly

* src/df.c (get_header, get_dev):
Avoid calling mbswidth twice when once will do.

7 years agodf: avoid multibyte character corruption on macOS
Paul Eggert [Sun, 22 Jul 2018 16:50:20 +0000 (09:50 -0700)] 
df: avoid multibyte character corruption on macOS

This improves on the earlier fix for the problem reported by
Chih-Hsuan Yen (Bug#32236), by also looking for other control
characters and for encoding errors.
* src/df.c: Include wchar.h and wctype.h instead of c-ctype.h.
(hide_problematic_chars): Process the string as multibyte.
Use iswcntrl, not c_iscntrl.

7 years agodf: avoid multibyte character corruption on macOS
Chih-Hsuan Yen [Sat, 21 Jul 2018 20:19:23 +0000 (13:19 -0700)] 
df: avoid multibyte character corruption on macOS

* src/df.c (hide_problematic_chars): Use c_iscntrl() as
passing 8 bit characters to iscntrl() is not supported on macOS.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/32236

7 years agodoc: improve documentation of binary prefixes
Wodry [Sun, 22 Jul 2018 15:16:23 +0000 (08:16 -0700)] 
doc: improve documentation of binary prefixes

* doc/coreutils.texi (Common options):
* src/dd.c, src/head.c, src/od.c, src/stdbuf.c, src/tail.c (usage):
* src/system.h (emit_size_note):
Mention binary prefixes (Bug#32242).
Copyright-paperwork-exempt: Yes

7 years agotests: avoid false failure on sparc 32 bit
Pádraig Brady [Sun, 15 Jul 2018 17:50:53 +0000 (10:50 -0700)] 
tests: avoid false failure on sparc 32 bit

* tests/rm/rm-readdir-fail.sh: Skip the test entirely on 32 bit,
so we avoid conflating the 32bit and 64 bit types, as that
triggers alignment issues (SIGBUS) on Gentoo sparc.
Fixes https://bugs.gnu.org/29886

7 years agobuild: update gnulib submodule to latest
Paul Eggert [Thu, 5 Jul 2018 16:33:48 +0000 (09:33 -0700)] 
build: update gnulib submodule to latest

* bootstrap.conf, src/copy.c, src/mv.c, src/shred.c:
Adjust to renaming of renameat2 to renameatu.

7 years agotests: fix skipping in some tests
Pádraig Brady [Thu, 5 Jul 2018 00:46:07 +0000 (17:46 -0700)] 
tests: fix skipping in some tests

* tests/cp/cp-a-selinux.sh: Use 'skip_' rather than the probably
undefined 'skip'.
* tests/du/2g.sh: Likewise.
* tests/install/install-Z-selinux.sh: Likewise.
* tests/misc/chcon.sh: Likewise.
* tests/misc/selinux.sh: Likewise.
* tests/mkdir/restorecon.sh: Likewise.
* cfg.mk (sc_prohibit-skip): A new syntax check to catch the issue.

7 years agomaint: init.cfg: fix a minor test-related quoting bug
Jim Meyering [Sun, 1 Jul 2018 16:05:53 +0000 (09:05 -0700)] 
maint: init.cfg: fix a minor test-related quoting bug

* init.cfg (require_membership_in_two_groups_): This fixes a bug
introduced by me in v8.15-8-gdd0e4c562.  Luckily, the consequence
of low-probability triggering the bug was the mere added backslash
in the diagnostic: "...but running id -G\ either...".  It would be
triggered in a test failure for one who is a member of only one or
fewer groups.

7 years agomaint: post-release administrivia
Pádraig Brady [Mon, 2 Jul 2018 01:28:37 +0000 (18:28 -0700)] 
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

7 years agoversion 8.30 v8.30
Pádraig Brady [Mon, 2 Jul 2018 00:56:07 +0000 (17:56 -0700)] 
version 8.30

* NEWS: Record release date.

7 years agotests: standardize perl usage in tests
Pádraig Brady [Sun, 1 Jul 2018 01:50:40 +0000 (18:50 -0700)] 
tests: standardize perl usage in tests

* tests/cp/fiemap-FMR.sh: Ensure perl is parameterized to $PERL,
and ensure require_perl_ is used, so tests are skipped appropriately.
* tests/cp/preserve-gid.sh: Likewise.
* tests/du/long-from-unreadable.sh: Likewise.
* tests/misc/env-S-script.sh: Likewise.
* tests/misc/sort-benchmark-random.sh: Likewise.
* tests/rm/deep-2.sh: Likewise.

7 years agomaint: copy: avoid new static analyzer warnings
Pádraig Brady [Thu, 28 Jun 2018 03:33:30 +0000 (20:33 -0700)] 
maint: copy: avoid new static analyzer warnings

* src/copy.c (copy_internal): Use the lint protected src_mode,
rather than accessing the src_sb again.  Also unconditionally
populate src_sb when !x->move_mode and in lint mode.
Reported by Kamil Dudka with coverity and clang analyzer.

7 years agomaint: fix recent stale comments and spelling mistakes
Pádraig Brady [Thu, 28 Jun 2018 01:09:11 +0000 (18:09 -0700)] 
maint: fix recent stale comments and spelling mistakes

* doc/coreutils.texi: s/seperator/separator/.
* tests/misc/env-S.pl: Likewise.
* src/env.c: Fix stale comment.

7 years agomaint: disable overly agressive sc_gitignore_redundant
Pádraig Brady [Wed, 27 Jun 2018 08:44:51 +0000 (01:44 -0700)] 
maint: disable overly agressive sc_gitignore_redundant

* cfg.mk (sc_gitignore_redundant): Disabled for now as too
aggressive flagging entries like /lib/arg-nonnull.h in
a newly checked out repo.

7 years agoenv: adjust diagnostics provided for shebang usage
Pádraig Brady [Wed, 27 Jun 2018 06:52:38 +0000 (23:52 -0700)] 
env: adjust diagnostics provided for shebang usage

* src/env.c (main): Don't process '-' specially since
that causes an issue on the openbsd getopt implementation
where a lone '-' is now processed as an option, and anyway
it doesn't particuarly help diagnosing common shebang
usage issues.  Also don't restrict the extra diagnostics
for shebang usage to the case with 3 arguments, as
further arguments can be passed to a script.
* tests/misc/env-S.pl: Adjust accordingly.

7 years agotests: accept getopt errors without single-quotes
Assaf Gordon [Tue, 26 Jun 2018 11:04:45 +0000 (05:04 -0600)] 
tests: accept getopt errors without single-quotes

On OpenBSD 6.2, invalid single options produce error messages
without single quotes:

    $ ./src/chroot -/
    chroot: unknown option -- /

As opposed to other systems:

    ./src/chroot: invalid option -- '/'

Modify the grep search to accept this.

* tests/misc/usage_vs_getopt.sh (checkprg): Change the grep pattern
to accomodate no-single-quotes cases.

7 years agotests: fix false failures when perl not available
Pádraig Brady [Tue, 26 Jun 2018 07:43:00 +0000 (00:43 -0700)] 
tests: fix false failures when perl not available

* tests/local.mk: Reference the stub that skips perl tests,
with the correct path.

7 years agotests: fix false failure with limited shebang lines
Pádraig Brady [Tue, 26 Jun 2018 07:39:48 +0000 (00:39 -0700)] 
tests: fix false failure with limited shebang lines

* tests/misc/env-S-script.sh: Provide a wrapper to
emulate shebang processing, but without length limits,
which are 127 on Linux for example.

7 years agomaint: update gnulib to latest
Pádraig Brady [Wed, 27 Jun 2018 07:48:03 +0000 (00:48 -0700)] 
maint: update gnulib to latest

* gnulib: Update to latest, which incorporates
a thread linking fix from Bruno Haible,
which was seen on newer Ubuntu systems.

7 years agotests: remove unused Data::Dumper perl module
Assaf Gordon [Tue, 26 Jun 2018 18:59:11 +0000 (12:59 -0600)] 
tests: remove unused Data::Dumper perl module

The module is not needed anymore (was used during development).
Despite being a Perl core module, platforms like CentOS don't install
it by default.  Reported by Bruno Haible at
https://lists.gnu.org/r/coreutils/2018-06/msg00093.html.

* tests/misc/csplit-suppress-matched.pl: Remove Data::Dumper.

7 years agomaint: fix -Werror=suggest-attribute=malloc in expr.c
Carlos Santos [Mon, 25 Jun 2018 03:00:14 +0000 (00:00 -0300)] 
maint: fix -Werror=suggest-attribute=malloc in expr.c

Add attribute 'malloc' to mpz_get_str to prevent
the following on GCC 8.1.1

  src/expr.c:117:1: error: function might be candidate for attribute
    'malloc' if it is known to return normally
      [-Werror=suggest-attribute=malloc]
   mpz_get_str (char const *str, int base, mpz_t z)
   ^~~~~~~~~~~
  cc1: all warnings being treated as errors

* src/expr.c (mpz_get_str): Add _GL_ATTRIBUTE_MALLOC.

7 years agomaint: update gnulib to latest
Pádraig Brady [Sun, 24 Jun 2018 04:52:12 +0000 (21:52 -0700)] 
maint: update gnulib to latest

* gnulib: Update to latest.
* .gitignore: Add new entries.
* bootstrap.conf: Enable wchar-single, which will enable more
efficient replacements of wcwidth and mbrtowc, as we indicate
that the charset will no change between invocations of these functions.

7 years agomaint: sync longlong.h from gmp repo
Pádraig Brady [Sun, 24 Jun 2018 22:48:32 +0000 (15:48 -0700)] 
maint: sync longlong.h from gmp repo

* src/longlong.h: Sync changes.  No functional change.

7 years agomaint: avoid false positive in src/fs-magic-compare
Pádraig Brady [Sun, 24 Jun 2018 22:33:06 +0000 (15:33 -0700)] 
maint: avoid false positive in src/fs-magic-compare

* src/local.mk (fs_normalize_perl_subst): `make src/fs-magic-compare`
was reporting incorrectly that AFS was not being handled.
Add a mapping to our KAFS identifier.
* .gitignore: Add intermediate files from `make src/fs-magic-compare`

7 years agotests: initialize fail=0 to avoid "unary operator expected" errors
Bernhard Voelker [Thu, 21 Jun 2018 22:29:00 +0000 (00:29 +0200)] 
tests: initialize fail=0 to avoid "unary operator expected" errors

With an uninitialized variable 'fail', the unquoted use like
  test $fail = 1
lead to the shell error
  "unary operator expected".

The uninitialized 'fail' variable was a side effect of
  https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=e91c0d4f9
which was pulled into coreutils-v8.26 with
  https://git.sv.gnu.org/cgit/coreutils.git/commit/?id=ef9650170
Coreutils test code relied and relies on 'fail' to be initialized,
so initialize that variable here.

* tests/local.mk (TESTS_ENVIRONMENT): Initialize fail=0.

7 years agomaint: do not depend directly on gnulib's now-unused ftello module
Jim Meyering [Tue, 19 Jun 2018 23:49:39 +0000 (16:49 -0700)] 
maint: do not depend directly on gnulib's now-unused ftello module

* bootstrap.conf (gnulib_modules): Remove ftello, since it is
no longer used directly, since v8.9-11-geab97b307.

7 years agotests: provide an option to relax the need for gdb
Pádraig Brady [Thu, 21 Jun 2018 03:48:36 +0000 (20:48 -0700)] 
tests: provide an option to relax the need for gdb

* tests/rm/r-root.sh: gdb provides extra protection,
but is not strictly necessary.  So provide an option
for maintainers to relax the requirements.

7 years agorm: add --preserve-root=all to protect mounts
Pádraig Brady [Mon, 11 Jun 2018 06:02:58 +0000 (23:02 -0700)] 
rm: add --preserve-root=all to protect mounts

* src/remove.c (rm_fts): With the --preserve-root=all extension,
reject command line arguments that are mount points.
* src/remove.h (rm_options): Add preserve_all_root to store config.
* src/mv.c (rm_option_init): Init preserve_all_root to false.
* src/rm.c (main): Init preserve_all_root as per option.
(usage): Describe the new option.
* src/remove.c (rm_fts): Lookup the parent device id,
and reject the cli argument if a separate file system.
* tests/rm/one-file-system.sh: Add a test case.
* NEWS: Mention the new feature.

7 years agocp: add --reflink=never to force standard copy mode
Adam Borowski [Sun, 17 Jun 2018 22:38:04 +0000 (00:38 +0200)] 
cp: add --reflink=never to force standard copy mode

This mode is currently the default, but most if not all users of
reflink-capable filesystems want --reflink=auto, which is often
encapsulated into an alias.  Adding --reflink=never allows overriding
such an alias.

* doc/coreutils.texi (cp invocation): Describe the new option.
* src/cp.c: Support --reflink=never.
* tests/cp/reflink-auto.sh: Add a test case.
* NEWS: Mention the new feature.

7 years agoenv: add -S/--split-string option
Assaf Gordon [Sat, 21 Apr 2018 02:58:28 +0000 (20:58 -0600)] 
env: add -S/--split-string option

Adopted from FreeBSD's env(1), useful for specifing multiple
parameters on a shebang (#!) script line, e.g:

   #!/usr/bin/env -S perl -w -T

Discussed in https://lists.gnu.org/r/coreutils/2018-04/msg00011.html

* src/env.c (valid_escape_sequence,escape_char,scan_varname,
  extract_varname,validate_split_str,build_argv,
  parse_split_string): New functions.
  (main): Process new option and call parse_split_string.
  (usage): Mention new option.
* tests/misc/env-S.pl: Test new option from the command line.
* tests/misc/env-S-script.sh: Test new option from shebang scripts.
* tests/local.mk (all_tests): Add new tests.
* man/env.x (OPTIONS): Show a brief example of -S usage and point to
the full documentation for more information.
* doc/coreutils.texi (env invocation): Detail usage of -S/--split-string
option.
* NEWS: Mention new option.

7 years agoenv: add -v/--debug option
Assaf Gordon [Fri, 20 Apr 2018 00:26:07 +0000 (18:26 -0600)] 
env: add -v/--debug option

Prints verbose information about each step:

  $ env -v -uFOO  -C /tmp BAR=BAZ date -u
  env: unset:    FOO
  env: setenv:   BAR=BAZ
  env: chdir:    '/tmp'
  env: executing: date
  env:    arg[0]= ‘date’
  env:    arg[1]= ‘-u’
  Sun Apr 22 08:52:30 UTC 2018

Inspired by FreeBSD's env(1).

* src/env.c (usage): Mention new option.
  (main): Print debug information if requested.
* NEWS: Mention new option.
* doc/coreutils.texi (env invocation): Mention -v/--debug.

7 years agomaint: refactor unsetenv call in env
Assaf Gordon [Tue, 24 Apr 2018 23:37:53 +0000 (17:37 -0600)] 
maint: refactor unsetenv call in env

Keep unset envvars (-uFOO) in an array for later deletion,
instead of reiterating over argv.  Done in preparation for
'-S string' feature. Related to '-u' discussion in
https://lists.gnu.org/r/coreutils/2018-04/msg00013.html

* src/env.c (append_unset_var,unset_envvars): New functions.
 (main): Use new functions.

7 years agols: ignore case when coloring file extensions
Kaxandra Labat [Sun, 17 Jun 2018 03:45:33 +0000 (20:45 -0700)] 
ls: ignore case when coloring file extensions

* src/ls.c (get_color_indicator): s/STREQ_LEN/c_strncasecmp/
* src/dircolors.hin: Remove a now redundant entry.
* tests/ls/color-ext.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.

7 years agomd5sum,b2sum,sha*sum: support -z,--zero option
Pádraig Brady [Mon, 11 Jun 2018 00:45:35 +0000 (17:45 -0700)] 
md5sum,b2sum,sha*sum: support -z,--zero option

* doc/coreutils.texi (md5sum invocation): Describe the new option,
and how it's not supported by --check, and how it disables escaping.
* src/md5sum.c (delim): A new global to parmeterize the out delimiter.
(main): Don't enable file name escaping with -z, and output '\0'.
* tests/misc/md5sum-newline.pl: Add a test case.
* NEWS: Mention the new feature.

7 years agowc: optimize processing of ASCII in multi byte locales
Pádraig Brady [Fri, 18 May 2018 04:41:46 +0000 (21:41 -0700)] 
wc: optimize processing of ASCII in multi byte locales

===== Benchmark setup (on GNU/Linux) ====
$ yes áááááááááááááááááááá | head -n100000 > mbc.txt
$ yes 12345678901234567890 | head -n100000 > num.txt

===== Before ====
$ time src/wc -Lm < mbc.txt
real    0m0.186s
$ time src/wc -m < mbc.txt
real    0m0.186s
$ time src/wc -Lm < num.txt
real    0m0.055s
$ time src/wc -m < num.txt
real    0m0.056s

==== After ====
$ time src/wc -Lm < mbc.txt
real    0m0.196s
$ time src/wc -m < mbc.txt
real    0m0.173s
$ time src/wc -Lm < num.txt
real    0m0.031s
$ time src/wc -m < num.txt
real    0m0.028s

* src/wc.c (wc): Only call wide variant functions like
iswprint() and wcwidth() for non is_basic() characters.
I.E. non ISO C "basic character set" characters.
This is especially significant on OSX where wcwidth()
is very expensive (about 10x in tests).
* NEWS: Mention the improvement.
Suggested by Eric Fischer.

7 years agodoc: port test.1 to doclifter
Paul Eggert [Thu, 14 Jun 2018 19:04:57 +0000 (12:04 -0700)] 
doc: port test.1 to doclifter

* man/test.x: Use \& instead of quoting (Bug#31803).

7 years agodoc: port man pages to doclifter
Paul Eggert [Wed, 13 Jun 2018 23:00:45 +0000 (16:00 -0700)] 
doc: port man pages to doclifter

Problem reported by Eric S. Raymond (Bug#31803).
* man/test.x: Add SYNOPSIS section, since help2man
understandably gets confused by the square brackets.
* src/ln.c (usage): Omit parenthetical "(Nth form)" in usage,
as it confuses doclifter.

7 years agocp: preserve existing permissions with --no-preserve=mode
Pádraig Brady [Sun, 3 Jun 2018 23:19:20 +0000 (16:19 -0700)] 
cp: preserve existing permissions with --no-preserve=mode

This issue was introduced in commit v8.19-145-g24ebca6

* src/copy.c (copy_internal): With --no-preserve=mode,
only reset permissions for newly created files.
(copy_reg): Likewise.
* NEWS: Mention the fix.
* tests/cp/preserve-mode.sh: Add a test case.
Fixes https://bugs.gnu.org/31675

7 years agotests: fix periodic false failure in month alignment
Pádraig Brady [Tue, 29 May 2018 17:10:35 +0000 (10:10 -0700)] 
tests: fix periodic false failure in month alignment

* tests/ls/abmon-align.sh: Base relative month adjustment
from the middle of the month, to avoid failures due
to months being repeated.
Fixes https://bugs.gnu.org/31644

7 years agodoc: formatting fixes in "du.x" and "rm.x"
Bjarni Ingi Gislason [Sat, 26 May 2018 00:10:11 +0000 (00:10 +0000)] 
doc: formatting fixes in "du.x" and "rm.x"

Avoid warnings from: groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

* man/du.x: Change ".BR" to ".B" if there is only one argument.
Protect an end-of-sentence indicator (.?!) with '\&'
if it does not mean an end of a sentence.
Change '--' to '\-\-' if it indicates an option.
* man/rm.x: Change '\=' to '='.

7 years agocp: with --force; replace self referential symlinks
Pádraig Brady [Wed, 16 May 2018 06:41:36 +0000 (23:41 -0700)] 
cp: with --force; replace self referential symlinks

* src/copy.c (copy_internal): Don't fail immediately upon
getting ELOOP when running stat() on the destination,
rather proceeding if -f specified, allowing the link
to be removed.  If the loop is not in the final component
of the destination path, we still fail but at the
subsequent unlink() stage.
* doc/coreutils.texi (cp invocation): Adjust wording to say
that --force doesn't work with dangling links, rather than
all links that can't be traversed.
* tests/cp/thru-dangling.sh: Add a test case.
* NEWS: Mention the change in behavior.
Discussed in https://bugs.gnu.org/31335

7 years agocp: fix symlink checks when overwriting files
Pádraig Brady [Mon, 14 May 2018 09:26:05 +0000 (02:26 -0700)] 
cp: fix symlink checks when overwriting files

Ensure this _does_ recreate the symlink
  Given "path1" and "path2" are on different devices.
  $ touch "path1/file"
  $ cd path2/; ln -s path1/file
  $ cp -dsf path1/file .

Ensure this does _not_ overwrite file
  $ touch file
  $ ln -s file l1
  $ cp -sf l1 file

* src/copy.c (same_file_ok): Remove device ids from consideration,
instead deferring to future EXDEV with --link or allowing
the first case above to work.
Also ensure that we do not exist this function too early,
when the destination file is not a symlink, which protects
against the second case.
* tests/cp/cross-dev-symlink.sh: Add a test for the first case.
* tests/cp/same-file.sh: Add a test for the second case above.
* NEWS: Mention the bug fixes.
* THANKS.in: Mention the reporters who also analyzed the code.
Fixes https://bugs.gnu.org/31364

7 years agocp: ensure --remove-destination doesn't traverse symlinks
Pádraig Brady [Fri, 4 May 2018 04:19:15 +0000 (21:19 -0700)] 
cp: ensure --remove-destination doesn't traverse symlinks

* src/cp.c (target_directory_operand): Allow through inaccessible
arguments with -f or --remove.
* doc/coreutils.texi (cp invocation): Clarify that -f doesn't directly
impact the removal of non-traversable symlinks.
* tests/cp/dir-rm-dest.sh: Test the new behavior.
* tests/cp/thru-dangling.sh: Enforce -f behavior wrt symlinks.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/31335

7 years agomaint: make chmod/chgrp/chown leak free under valgrind
Pádraig Brady [Mon, 14 May 2018 01:52:25 +0000 (18:52 -0700)] 
maint: make chmod/chgrp/chown leak free under valgrind

* src/chmod.c: Deallocate the mode change array in dev mode.
* src/chown.c: Make chopt_free() actually deallocate, but
only call in dev mode.
* src/chgrp.c: Likewise.

7 years agodoc: improve formatting of nl --help
Pádraig Brady [Tue, 15 May 2018 04:33:37 +0000 (21:33 -0700)] 
doc: improve formatting of nl --help

* src/nl.c (usage): Better delineate the information.

7 years agowho: simplify port to GCC 8
Paul Eggert [Mon, 14 May 2018 20:49:35 +0000 (13:49 -0700)] 
who: simplify port to GCC 8

* src/who.c (make_id_equals_comment): Use simpler workaround
for GCC bug 85602.  Suggested by Martin Sebor in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85602#c3

7 years agobuild: make GCC 8 adjustments more portable
Pádraig Brady [Fri, 4 May 2018 01:56:30 +0000 (18:56 -0700)] 
build: make GCC 8 adjustments more portable

* src/chown-core.h (chopt_free): Just define away this noop.
* src/chown-core.c (chopt_free): Remove the empty implementation.

7 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 4 May 2018 00:41:41 +0000 (17:41 -0700)] 
build: update gnulib submodule to latest

7 years agomaint: port to GCC 8
Paul Eggert [Thu, 3 May 2018 20:03:34 +0000 (13:03 -0700)] 
maint: port to GCC 8

* src/chown-core.h (chopt_free, gid_to_name, uid_to_name):
No longer const.
* src/make-prime-list.c (xalloc): Add malloc attribute.
* src/who.c (make_id_equals_comment): Work around GCC bug 85602
by using mempcpy rather than strncat.  Although the old code
was correct, strncat raises so many hackles that it’s not
worth maintaining its use here.

7 years agomaint: remove strpbrk module
Paul Eggert [Thu, 3 May 2018 19:59:21 +0000 (12:59 -0700)] 
maint: remove strpbrk module

* bootstrap.conf (gnulib_modules): Remove obsolete module strpbrk.

7 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 1 May 2018 19:15:22 +0000 (12:15 -0700)] 
build: update gnulib submodule to latest

7 years agodoc: retroactively adjust info about tail and closed output
Pádraig Brady [Sat, 21 Apr 2018 00:51:14 +0000 (17:51 -0700)] 
doc: retroactively adjust info about tail and closed output

* NEWS: Expand on the 8.28 description of how tail more
responsively reacts to closed output, and move from "Improvements"
to "Changed behavior".
* cfg.mk (old_NEWS_hash): Regenerate.
Fixes https://bugs.gnu.org/31225

7 years agodoc: timeout --help: mention 0 DURATION disables timeout
Pádraig Brady [Thu, 19 Apr 2018 03:08:12 +0000 (20:08 -0700)] 
doc: timeout --help: mention 0 DURATION disables timeout

* src/timeout.c (usage): Mention that a duration of 0 disables
the associated timeout, which is both concise info and useful
functionality as timeouts are frequently configured.

7 years agodoc: retroactively document -e/-u addition in NEWS
Eric Blake [Tue, 3 Apr 2018 14:40:43 +0000 (09:40 -0500)] 
doc: retroactively document -e/-u addition in NEWS

Prompted by https://bugs.gnu.org/31045

* NEWS: Update 8.8 blurb to mention other split additions.
* cfg.mk (old_NEWS_hash): Regenerate.

7 years agodoc: Clarify octal bits in permissions
Paul Eggert [Tue, 3 Apr 2018 15:40:34 +0000 (08:40 -0700)] 
doc: Clarify octal bits in permissions

* doc/perm.texi (Numeric Modes): Briefly explain octal.
Reorder description to make it more intuitive (Bug#29069).

7 years agocut: improve large file support on 32 bit
Tobias Stoeckmann [Mon, 26 Mar 2018 11:37:12 +0000 (13:37 +0200)] 
cut: improve large file support on 32 bit

Increase max range from SIZE_MAX to UINTMAX_MAX, which will
allow cut to support line lengths up to the max file size
on all systems. The inherent SIZE_MAX limitation in cut was
removed with the enhancements in https://bugs.gnu.org/13127.
Also numfmt gets similarly increased --field ranges due to
shared code.

* src/cut.c: s/size_t/uintmax_t/.
* src/numfmt.c: Likewise.
* src/set-fields.c: Likewise.
* src/set-fields.h: Likewise.
* tests/misc/cut-huge-range.sh: Adjust accordingly.
* tests/misc/numfmt.pl: Likewise.
* NEWS: Mention the improvement.

7 years agotests: avoid a recent syntax-check failure
Pádraig Brady [Wed, 28 Mar 2018 06:51:29 +0000 (23:51 -0700)] 
tests: avoid a recent syntax-check failure

* tests/ls/a-option.sh: s/framework_failure/&_/.

7 years agols: -A now overrides -a
Paul Eggert [Tue, 27 Mar 2018 21:55:22 +0000 (14:55 -0700)] 
ls: -A now overrides -a

Problem reported by Karl Berry (Bug#30963).
* NEWS: Mention this.
* src/ls.c (decode_switches): Implement this.
* tests/ls/a-option.sh: New file.
* tests/local.mk (all_tests): Add it.

7 years agodoc: fix two typos in github templates
Roland Hieber [Tue, 20 Mar 2018 13:34:03 +0000 (14:34 +0100)] 
doc: fix two typos in github templates

* .github/ISSUE_TEMPLATE.txt: Fix typo "coreitils" in the URL to the bug
tracker.
* .github/PULL_REQUEST_TEMPLATE.txt: Likewise.

7 years agols: increase the allowed abmon width from 5 to 12
Pádraig Brady [Wed, 14 Mar 2018 18:31:43 +0000 (11:31 -0700)] 
ls: increase the allowed abmon width from 5 to 12

This will impact relatively few languages,
and will make Arabic or Catalan etc.
output unambiguous abbreviated month names.

* src/ls.c (MAX_MON_WIDTH): Increase from 5 to 12.
* NEWS: Mention the bug fix.
* tests/ls/abmon-align.sh: Augment to check for ambiguous output.
Fixes https://bugs.gnu.org/30814

7 years agostat,tail: add support for the EXFS file system
Brent Petit [Tue, 9 Jan 2018 21:43:24 +0000 (21:43 +0000)] 
stat,tail: add support for the EXFS file system

Enhanced XFS (EXFS) is a version of XFS maintained by HPE.
EXFS uses a unique magic number to allow the use of community
XFS, and EXFS filesystems at the same time.

* src/stat.c (human_fstype): Add file system ID definition,
and use "exfs" as the name.
* NEWS: Mention the Improvement.

7 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 6 Mar 2018 23:15:24 +0000 (15:15 -0800)] 
build: update gnulib submodule to latest

7 years agostat: work around IBM xlC bug
Paul Eggert [Mon, 5 Mar 2018 23:50:39 +0000 (15:50 -0800)] 
stat: work around IBM xlC bug

Problem reported by John Wiersba (Bug#30718)
* src/stat.c (human_time): Avoid giving an integer constant
expression a name, as it runs afoul of a bug in IBM XL C/C++ for
AIX 12.01.0000.0002.

7 years agomaint: adjust email address of Keith Thompson in THANKS.in
Bernhard Voelker [Sun, 4 Mar 2018 19:31:49 +0000 (20:31 +0100)] 
maint: adjust email address of Keith Thompson in THANKS.in

* THANKS.in (Keith Thompson): Update email address as requested by
himself at https://lists.gnu.org/r/coreutils/2018-03/msg00004.html

7 years agocp: set appropriate default permissions for special files
Pádraig Brady [Tue, 20 Feb 2018 03:10:14 +0000 (19:10 -0800)] 
cp: set appropriate default permissions for special files

This issue was introduced in commit v8.19-145-g24ebca6

* src/copy.c (copy_internal): When setting default permissions
to use with --no-preserve=mode, only set executable bits for
directories or sockets.
* NEWS: Mention the fix.
* tests/cp/preserve-mode.sh: Add a test case.
Fixes https://bugs.gnu.org/30534

7 years agodoc: use consistent example format in manual
Pádraig Brady [Sun, 21 Jan 2018 04:30:52 +0000 (20:30 -0800)] 
doc: use consistent example format in manual

* doc/coreutils.texi: Use @example consistently
as we don't need the smaller or fixed width representation.
This is especially true for the synopsis of commands.
@smallexample is rendered left aligned for HTML
which is awkward to read with the center aligned main content.

7 years agomv: clarify ‘mv -n A A’ change
Paul Eggert [Wed, 10 Jan 2018 08:48:51 +0000 (00:48 -0800)] 
mv: clarify ‘mv -n A A’ change

7 years agomv: fewer syscalls for ‘mv a b’
Paul Eggert [Wed, 10 Jan 2018 08:48:51 +0000 (00:48 -0800)] 
mv: fewer syscalls for ‘mv a b’

This builds on a previous patch for mv atomicity (Bug#29961).
It merely improves performance; it does not fix bugs.
* src/copy.h (struct cp_options): New members last_file, rename_errno.
* src/copy.c (copy_internal): Support new rename_errno member
for the copy options.  Avoid calling stat when new members
suggest it’s not needed.
(cp_options_default): Initialize new members.
* src/mv.c: Include renameat2.h.
(main): With two arguments, first call ‘renamat2 (AT_FDCWD, "a",
AT_FDCWD, "b", RENAME_NOREPLACE)’.  Use its results to skip
remaining processing if possible; for example, if it succeeds
there is no need to stat either "a" or "b".  Also, set
x.last_file when it is the last file to rename.

7 years agomv: improve -n atomicity
Paul Eggert [Wed, 10 Jan 2018 08:48:51 +0000 (00:48 -0800)] 
mv: improve -n atomicity

Problem reported by Kamil Dudka (Bug#29961).
* NEWS: Mention this.
* src/copy.c: Include renameat2.h.
(copy_internal): If mv, try renameat2 first thing, with
RENAME_NOREPLACE.  If this works, skip most of the remaining code.
Also, fail quickly if it fails with EEXIST, and we are using -n.

7 years agodoc: warn about following symlinks recursively in chown/chgrp
Michael Orlitzky [Thu, 4 Jan 2018 16:38:21 +0000 (11:38 -0500)] 
doc: warn about following symlinks recursively in chown/chgrp

In both chown and chgrp (which shares its code with chown), operating
on symlinks recursively has a window of vulnerability where the
destination user or group can change the target of the operation.
Warn about combining the --dereference, --recursive, and -L flags.

* doc/coreutils.texi (warnOptDerefWithRec): Add macro.
(node chown invocation): Add it to --dereference and -L.
(node chgrp invocation): Likewise.

See also: CVE-2017-18018

7 years agocp: remove ASSIGN_BASENAME_STRDUPA
Paul Eggert [Sat, 6 Jan 2018 06:55:47 +0000 (22:55 -0800)] 
cp: remove ASSIGN_BASENAME_STRDUPA

* src/cp.c (do_copy): Just use ASSIGN_STRDUPA, as this simplifies
the code and uses less memory.

7 years agomv: -n overrides -u
Paul Eggert [Thu, 4 Jan 2018 21:57:40 +0000 (13:57 -0800)] 
mv: -n overrides -u

* NEWS: Mention these fixes.
* doc/coreutils.texi (cp invocation, mv invocation):
Mention that -n is silent, and that it overrides -u.
* src/cp.c, src/mv.c (main): -n overrides -u.

7 years agotr: add -A, for compatibility with AIX tr
Paul Eggert [Wed, 3 Jan 2018 19:02:17 +0000 (11:02 -0800)] 
tr: add -A, for compatibility with AIX tr

Problem reported by Michael (Bug#29946).
* src/tr.c (main): Add undocumented -A option.

7 years agodoc: clarify chown/chgrp --dereference defaults
Michael Orlitzky [Thu, 28 Dec 2017 20:52:42 +0000 (15:52 -0500)] 
doc: clarify chown/chgrp --dereference defaults

* doc/coreutils.texi: the documentation for the --dereference
  flag of chown/chgrp states that it is the default mode of
  operation. Document that this is only the case when operating
  non-recursively.

7 years agotests: avoid false failure with xargs on AIX
Pádraig Brady [Tue, 2 Jan 2018 12:52:11 +0000 (12:52 +0000)] 
tests: avoid false failure with xargs on AIX

* tests/misc/shred-remove.sh: AIX xargs defaults to using
'_' to indicate end of input, thus ignoring it.
Rather than specifying -E to avoid this behavior, simplify
by removing sed and xargs usage.

7 years agomaint: update all copyright year number ranges
Pádraig Brady [Mon, 1 Jan 2018 15:57:22 +0000 (15:57 +0000)] 
maint: update all copyright year number ranges

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

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.

7 years agomaint: post-release administrivia
Pádraig Brady [Wed, 27 Dec 2017 18:26:39 +0000 (18:26 +0000)] 
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

7 years agoversion 8.29 v8.29
Pádraig Brady [Wed, 27 Dec 2017 17:54:32 +0000 (17:54 +0000)] 
version 8.29

* NEWS: Record release date.