Commit Graph

2137 Commits

Author SHA1 Message Date
Pádraig Brady
187712b97b doc: env: clarify that empty signal args are ignored
It's useful to treat empty and missing arguments differently.
Missing means all signals, while empty means no signals and
so is a no-op.  It's useful to treat empty arguments like
this, so that dynamically specified arguments like the following
are supported

  env --ignore-signals "$SIGS_TO_IGNORE"

Note `env --ignore-signals=` is treated as an empty argument.

* doc/coreutils.texi (env invocation): Empty args are treated
differently to missing arguments, so call that out explicitly.
* src/env.c (usage): Likewise.
Addresses https://bugs.debian.org/1016049
2022-07-26 14:16:55 +01:00
Pádraig Brady
56783caccf doc: date: clarify which options are mutually exclusive
* src/date.c (usage): Specify that --date, --file, --reference,
and --resolution are mutually exclusive.  This is also useful
documentation to group similar options.
* doc/coreutils.texi (Options for date): Likewise.
Addresses https://bugs.gnu.org/55401
2022-07-24 21:09:24 +01:00
Paul Eggert
e6c7091634 dd: doc improvement (Bug#54586)
* doc/coreutils.texi (dd invocation): Explain
fdatasync and fsync better.
2022-07-06 23:42:55 -05:00
Paul Eggert
0ae619f349 build: update gnulib submodule to latest
* bootstrap: Copy from latest Gnulib.
* tests/misc/ls-misc.pl (v_files): Adjust to new Gnulib behavior.
2022-06-03 19:45:47 -07:00
Rasmus Villemoes
f45ab30c0b factor: --exponents: new option for printing in p^e format
When factoring numbers that have a large 2^n factor, it can be hard to
eyeball just how many 2's there are. Add an option to print each prime
power factor in the p^e format (omitting the exponent when it is 1).

* src/factor.c: Add -h, --exponents option for printing in p^e format.
* doc/coreutils.texi (factor invocation): Document the new option.
* tests/misc/factor.pl: Add test case.
* THANKS.in: Add previous suggester
(https://lists.gnu.org/r/coreutils/2017-11/msg00015.html).

Suggested-by: Emanuel Landeholm <emanuel.landeholm@gmail.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2022-05-09 14:38:01 +01:00
Paul Eggert
913f14bbd0 doc: fix ' and ` in PDF output of code
* doc/coreutils.texi: Set txicodequoteundirected and
txicodequotebacktick so that ' and ` in code examples appear
as-is, rather than being transliterated to ’ and ‘.  E.g., prefer
“... this is equivalent to ‘tr '\303\266' '\305\201'’ and ...” to
“... this is equivalent to ‘tr ’\303\266’ ’\305\201’’ and ...”
in PDF output.
2022-04-19 13:40:38 -07:00
Paul Eggert
f0de24e53f doc: fix footnote formats
* doc/coreutils.texi: Reword footnote, or put it right next
to previous punctuation.
2022-04-19 13:40:38 -07:00
Paul Eggert
6106b56191 doc: prefer ö to $'\u7530'
* doc/coreutils.texi (Character arrays): Avoid using shell
notation like $'\u7530' since this isn’t in POSIX yet. Instead,
use ö and Ł which should work in all texinfo output formats.
2022-04-19 13:40:38 -07:00
Pádraig Brady
dd614d6011 doc: rmdir: clarify --ignore-fail-on-non-empty operation
This option has changed from ignoring only ENOTEMPTY|EEXIST
(i.e. ignore errors _solely_ due to dir not empty),
to ignoring some other errors from more protected dirs
that are not empty.  That adjustment was made to better
support use with --parents, to essentially remove as much of
a hierarchy as possible, without erroring as we hit more
protected non empty parent dirs.
That functionality adjustment was originally discussed at:
https://lists.gnu.org/r/bug-coreutils/2008-01/msg00283.html

* src/rmdir.c (usage): Adjust to be more accurate to current behavior.
Also adjust --parents option to be easier to read.
* doc/coreutils.texi (rmdir invocation): Likewise.
Reported at https://github.com/coreutils/coreutils/issues/40
2022-04-17 13:46:03 +01:00
Pádraig Brady
0f2cf20af6 doc: avoid unicode errors in texi conversion
Avoid "Unicode character U+#1 not supported, sorry" error
when converting from texi to dvi or pdf.

* doc/coreutils.texi (tr invocation): Avoid the @U{XXXX}
texi representation, as even though info and html can represent
these characters directly, there are conversion errors
for pdf and dvi.  Instead use the more abstract shell
$'\uXXXX' representation.
2022-04-15 18:28:38 +01:00
Pádraig Brady
54bec51754 doc: install --compare: clarify mode of operation
* doc/coreutils.texi (install invocation): For the --compare option,
clarify that the ownership or permissions of the source files don't
matter.  Also don't imply --owner or --group need to be specified
for --compare to be effective.
* src/install.c (usage): Add more detail on what's being compared.
Fixes https://bugs.gnu.org/50889
2022-04-09 13:00:52 +01:00
Pádraig Brady
aa53e73974 doc: test: clarify that -rwx don't just check perm bits
* src/test.c (usage): State that -rwx is determined by
user access, rather than permission bits.
* doc/coreutils.texi (Access permission tests): Likewise.
* man/test.x [SEE ALSO]: access(2).
Fixes https://bugs.gnu.org/54338
2022-03-12 13:19:06 +00:00
Pádraig Brady
92cb8427c5 stat: only automount with --cached=never
Revert to the default behavior before the introduction of statx().

* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never.
* doc/coreutils.texi (stat invocation): Mention the automount
behavior with --cached=never.
* NEWS: Mention the change in behavior.

Fixes https://bugs.gnu.org/54287
2022-03-07 23:33:21 +00:00
Paul Eggert
8f31074cb4 chown: warn about USER.GROUP
Suggested by Dan Jacobson (Bug#44770).
* src/chown.c, src/chroot.c (main):
Issue warnings if obsolete USER.GROUP notation is present.
2022-02-24 18:19:40 -08:00
Paul Eggert
97e9778296 dd: counts ending in "B" now count bytes
This implements my suggestion in Bug#54112.
* src/dd.c (usage): Document the change.
(parse_integer, scanargs): Implement the change.
Omit some now-obsolete checks for invalid flags.
* tests/dd/bytes.sh: Test the new behavior, while retaining
checks for the now-obsolete usage.
* tests/dd/nocache_eof.sh: Avoid now-obsolete usage.
2022-02-22 18:56:53 -08:00
Paul Eggert
ef694d3448 dd: improve doc relative to POSIX
* doc/coreutils.texi (dd invocation): Improve documentation,
clarifying whether features are extensions to POSIX.
2022-02-22 09:04:27 -08:00
Paul Eggert
4439ef3ec4 dd: support iseek= and oseek=
Alias iseek=N to skip=N, oseek=N to seek=N (Bug#45648).
* src/dd.c (scanargs): Parse iseek= and oseek=.
* tests/dd/skip-seek.pl (sk-seek5): New test case.
2022-02-22 09:04:27 -08:00
Paul Eggert
8d3dce9861 tr: improve multibyte etc. doc
Problem reported by Dan Jacobson (Bug#48248).
* doc/coreutils.texi (tr invocation): Improve documentation for
tr's failure to support multibyte characters POSIX-style.
* doc/coreutils.texi (tr invocation), src/tr.c (usage):
Use terminology closer to POSIX's.
2022-02-14 12:03:49 -08:00
Pádraig Brady
abc4533fe4 dircolors: add --print-ls-colors to display colored entries
* NEWS: Mention the new feature.
* doc/coreutils.texi (dircolors invocation): Describe the new
--print-ls-colors option.
* src/dircolors.c (print_ls_colors): A new global to select
between shell or terminal output.
(append_entry): A new function refactored from dc_parse_stream()
to append the entry in the appropriate format.
(dc_parse_stream): Adjust to call append_entry().
* tests/misc/dircolors.pl: Add test cases.
2022-02-13 18:25:59 +00:00
Paul Eggert
d8047ae86d sort: fix several version-sort problems
This also affects ls -v in some corner cases.
Problems reported by Michael Debertol <https://bugs.gnu.org/49239>.
While looking into this, I spotted some more areas where the
code and documentation did not agree, or where the documentation
was unclear.  In some cases I changed the code; in others
the documentation.  I hope things are nailed down better now.
* doc/sort-version.texi: Distinguish more carefully between
characters and bytes.  Say that non-identical strings can
compare equal, since they now can.  Improve readability in
various ways.  Make it clearer that a suffix can be the
entire string.
* src/ls.c (cmp_version): Fall back on strcmp if filevercmp
reports equality, since filevercmp is no longer a total order.
* src/sort.c (keycompare): Use filenvercmp, to treat NULs correctly.
* tests/misc/ls-misc.pl (v_files):
Adjust test to match new behavior.
* tests/misc/sort-version.sh: Add tests for stability,
and for sorting with NUL bytes.
2022-02-12 20:15:03 -08:00
Paul Eggert
cedf627a90 doc: improve version-sort doc
* doc/coreutils.texi, doc/sort-version.texi:
Capitalize “Coreutils”.
* doc/sort-version.texi: Don’t emphasize natural sort so much,
since Coreutils has just version sort.
Use the term “lexicographic” instead of “alphabetic” or “standard”.
Suggest combining ‘V’ with ‘b’, and show why ‘b’ is needed.
Use shorter titles for sections, as GNU Emacs displays info poorly
when titles are too long to fit in a line.
Use @samp instead of @code for samples of data.
Do not use @samp{@code{...}}; @samp{...} should suffice and
double-nesting looks bad with Emacs.
Omit blank lines in examples that would not be present
in actual shell sessions.
Quote with `` and '', not with " or with '.
Mention dpkg --compare-versions more prominently.
Don’t rely on "\n" being equivalent to "\\n" in shell args.
Prefer Unicode name for hyphen-minus.
2022-02-08 10:52:43 -08:00
Pádraig Brady
b52d66452d doc: fix somewhat ambiguous date format representation
* doc/coreutils.texi (date invocation): Remove @var{...} usage,
as that capitalizes in the representation and thus somewhat
ambiguates the format wrt Month and Minute.  This also avoids
a syntax check failure about redundant capitalization in @var{}.
2022-02-05 12:53:19 +00:00
Paul Eggert
67cd2c3b72 date: improve doc
Problem reported by Dan Jacobson (Bug#51288).
* doc/coreutils.texi (date invocation, Setting the time)
(Options for date):
* src/date.c (usage): Improve doc.
2022-02-04 18:21:46 -08:00
Paul Eggert
50e438972b dd: synchronize output after write errors
Problem reported by Sworddragon (Bug#51345).
* src/dd.c (cleanup): Synchronize output unless dd has been interrupted.
(synchronize_output): New function, split out from dd_copy.
Update conversions_mask so synchronization is done at most once.
(main): Do not die with the output file open, since we want to be
able to synchronize it before exiting.  Synchronize output before
exiting.
2022-01-28 00:01:55 -08:00
Pádraig Brady
4a0a8fdbec doc: csplit: clarify [OFFSET] syntax
* src/csplit.c (usage): Clarify that '+' prefix is optional on OFFSET.
* doc/coreutils.texi (csplit invocation): Likewise.
Fixes https://bugs.gnu.org/53574
2022-01-27 13:07:28 +00:00
Paul Eggert
6df8e86208 doc: fix pluralization typo 2022-01-14 15:47:41 -08:00
Pádraig Brady
3067a9293a 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.
2022-01-02 16:15:55 +00:00
Pádraig Brady
76700e775e build: update gnulib submodule to latest
mainly to get updated copyright year

* doc/fdl.texi: Sync from gnulib.
* .gitignore: Add lib/unictype, as bitmap.h therein is depended on
since gnulib commit f698ea71
2022-01-02 16:14:40 +00:00
Paul Eggert
840ae54cf5 date: new option --resolution
* NEWS, doc/coreutils.texi (Options for date): Mention this.
* src/date.c (RESOLUTION_OPTION): New constant.
(DEBUG_DATE_PARSING_OPTION): Rename from DEBUG_DATE_PARSING.
All uses changed.
(long_options, usage, main): Support --resolution.
2021-12-31 10:53:29 -08:00
Paul Eggert
0cd39a246a date: %-N now means suppress extra digits
* NEWS, doc/coreutils.texi: Mention this.
* bootstrap.conf (gnulib_modules): Add gettime-res.
* src/date.c (res_width, adjust_resolution): New functions.
(main): Adjust %-N to be %9N, or whatever, before using it.
2021-12-31 10:53:29 -08:00
Paul Eggert
1011b88594 doc: Document , vs . in date --rfc-3339=ns 2021-12-31 10:53:29 -08:00
Paul Eggert
d5ae6d8120 doc: colorize -> color
Living so close to Hollywood I know that "colorize"
means adding color to something that was already monochrome,
whereas "color" means to give color to something.
Coreutils apps color text instead of colorizing it.
2021-12-24 09:49:21 -08:00
Pádraig Brady
f60a3981c3 doc: say that printf(1) is preferred over echo(1)
* src/echo.c (usage): Say printf(1) is preferred
due to being more standard and robust.
* man/echo.x [SEE ALSO]: Reference printf(1).
* doc/coreutils.texi (echo invocation): Mention in the
summary that echo is not robust when outputting
any string, and that printf is preferred.
Also expand on the examples showing how to
output a single '-n' string.
Addresses https://bugs.gnu.org/51311
2021-10-22 15:12:33 +01:00
Pádraig Brady
13af84d09a doc: timeout --kill-after: clarify disabled timeouts
* doc/coreutils.texi (timeout invocation): Clarify
that -k is ignored if either its duration or the
main timeout duration is 0.
Addresses https://bugs.gnu.org/51128
2021-10-12 14:47:44 +01:00
Pádraig Brady
0750fcdf34 timeout: ensure --foreground -k exits with status 137
* src/timeout.c (main): Propagate the killed status from the child.
* doc/coreutils.texi (timeout invocation): Remove the
description of the --foreground specific handling of SIGKILL,
now that it's consistent with the default mode of operation.
* tests/misc/timeout.sh: Add a test case.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/51135
2021-10-12 14:32:57 +01:00
Pádraig Brady
d085678bd6 doc: timeout --foreground: add clarification on exit status
* doc/coreutils.texi (timeout invocation): Add detail on
how --foreground allows timeout(1) to use more standard
exit status as the uncatchable SIGKILL is not sent to itself.
Fixes https://bugs.gnu.org/51135
2021-10-11 22:15:52 +01:00
Pádraig Brady
0475ce9f84 doc: adjust ls --zero option order in texinfo
* doc/coreutils.texi (ls invocation - general output formatting):
The option ordering was not changed when the option was renamed
from --null to --zero.
2021-09-26 13:48:03 +01:00
Pádraig Brady
88b7ff98fe cksum: support more transparent emulation of older utils
* src/digest.c: Allow using the --untagged option with --check,
so that `cksum -a md5 --untagged` used to emulate md5sum for example,
may be augmented with the --check option.  Also support the --tag
option with cksum, to allow overriding a previous --untagged setting.
* doc/coreutils.texi: Adjust accordingly.
* tests/misc/cksum-a.sh: Likewise.
2021-09-20 16:21:15 +01:00
Pádraig Brady
ed1c58427d digest: support windows format checksum files
Support checksum files with CRLF line endings,
which is a common gotcha for using --check on windows,
or with checksum files generated on windows.
Note we escape \r here to support the original coreutils format
(with file name at EOL), and file names with literal
\r characters as the last character of their name.

* src/digest.c (filename_unescape): Convert \\r -> \r.
(print_filename): Escape \r -> \\r.
(output_file): Detect \r chars in file names.
(digest_check): Ignore literal \r char at EOL.
* tests/misc/md5sum.pl: Add a test case.
* tests/misc/sha1sum.pl: Likewise.
* NEWS: Mention the improvement.
2021-09-15 20:44:18 +01:00
Pádraig Brady
8d5038af05 cksum: operate in binary mode only
This only practically matters on windows.
But given there are separate text handling options in cygwin,
keep the interface simple, and avoid exposing the
confusing binary/text difference here.

* doc/coreutils.texi (md5sum invocation): Mention that
--binary and --text are not supported by the cksum command.
* src/digest.c: Set flag to use binary mode by default.
(output_file): Don't distinguish text and binary modes with
' ' and '*', and just use ' ' always.
2021-09-15 20:44:18 +01:00
Pádraig Brady
f9a787656b cksum: use --tag format by default
This format is a better default, since it results in simpler usage,
as you don't need to specify --tag on generation or -a on
checking invocations.  Also it's a more general format supporting
mixed and length adjusted digests.

* doc/coreutils.texi (cksum invocation): Document a new --untagged
option, to use the older coreutils format.
(md5sum invocation): Mention that cksum doesn't support --tag.
* src/digest.c: Adjust cksum(1) to default to --tag,
and accept the new --untagged option.
* tests/misc/b2sum.sh: Adjust accordingly.
* tests/misc/cksum-a.sh: Likewise.
* tests/misc/cksum-c.sh: Likewise.
2021-09-15 20:44:18 +01:00
Pádraig Brady
772173a832 cksum: support digest detection for tagged format
Support `cksum --check FILE` without having to specify a digest
algorithm, allowing for more generic file check instructions.
This also supports mixed digest checksum files, supporting
more robust multi digest checks.

* src/digest.c (algorithm_from_tag): A new function to
identify the digest algorithm from a tagged format line.
(split3): Set the algorithm depending on tag, and update
the expected digest length accordingly.
* tests/misc/cksum-c.sh: Add a new test.
* tests/local.mk: Reference the new test.
* tests/misc/md5sum.pl: Adjust to more generic error.
* tests/misc/sha1sum.pl: Likewise.
* doc/coreutils.texi (md5sum invocation): Mention the new -c feature.
* NEWS: Mention the new feature.
2021-09-15 20:44:18 +01:00
Pádraig Brady
8362f2552a digest: add support for sm3
Add message digest sm3, which uses the OSCCA SM3 secure
hash (OSCCA GM/T 0004-2012 SM3) generic hash transformation.

* bootstrap.conf: Add the sm3 module.
* doc/coreutils.texi: Mention the cksum -a option.
* src/digest.c: Provide support for --algorithm='sm3'.
* tests/misc/sm3sum.pl: Add a new test (from Tianjia Zhang)
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.

Tested-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
2021-09-15 20:44:18 +01:00
Pádraig Brady
ad6c8e1181 cksum: add --algorithm option to select digest mode
* src/digest.c: Organize HASH_ALGO_CKSUM to be table driven,
and amalgamate all digest algorithms.
(main): Parse all options if HASH_ALGO_CKSUM, and disallow
--tag, --zero, and --check with the traditional bsd, sysv, and crc
checksums for now.
* src/local.mk: Reorganize to include all digest modules in cksum.
* tests/misc/cksum-a.sh: Add a new test.
* tests/misc/b2sum.sh: Update to default to checking with cksum,
as b2sum's implementation diverges a bit from the others.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (cksum invocation): Adjust the summary to
identify the new mode, and document the new --algorithm option.
* man/cksum.x: Adjust description to be more general.
* man/*sum.x: Add [See Also] section referencing cksum(1).
* NEWS: Mention the new feature.
2021-09-15 20:44:16 +01:00
Pádraig Brady
2aab794c84 cksum: document the --debug option
This should have been part of commit v8.32-113-gb73b9fcb1

* doc/coreutils.texi (cksum invocation): Add the --debug description.
* src/cksum.c (usage): Likewise.
(main): Also give explicit indication when using generic hardware.
2021-09-15 15:35:53 +01:00
Pádraig Brady
f76a568313 doc: fix ambiguities in logname(1) and whoami(1)
* doc/coreutils.texi (whoami invocation): Clarify it prints names,
not numeric IDs.
* man/whoami.x: Likewise.
* man/logname.x: Reference getlogin(3).
* src/logname.c: Clarify that it prints the login name,
rather than the name of the effective user ID.

Fixes https://bugs.gnu.org/48894
2021-09-15 15:26:22 +01:00
Paul Eggert
588790a38c doc: can “can can”
Problem reported by Akbarkhon Variskhanov (Bug#50484).
2021-09-09 08:05:14 -07:00
Paul Eggert
3c855eb572 doc: add missing "as" (thanks to Nelson H.F. Beebe) 2021-09-07 16:15:40 -07:00
Pádraig Brady
e1c21f39cc sum: always output a file name if one passed
Adjust to output the file name if any name parameter is passed.
This is consistent with sum -s, cksum, and sum implementations
on other platforms.  This should not cause significant compat
issues, as multiple fields are already output, and so already
need to be parsed.

* src/sum.c (bsd_sum_file): Output the file name
if any name parameter is passed.
* tests/misc/sum.pl: Adjust accordingly.
* doc/coreutils.texi (sum invocation): Likewise.
* NEWS: Mention the change in behavior.
2021-08-31 11:33:26 +01:00
Paul Eggert
4d355e5270 doc: spell out stdin, stdout, stderr
* doc/coreutils.texi: Spell out words like “stdin” in
English prose.
2021-08-22 13:10:24 -07:00
Pádraig Brady
d1316583b2 doc: add options summary list to tr texinfo
* doc/coreutils.texi (tr invocation): Provide a summary
list of the available options, which is useful to
provide a quick reminder for those already familiar
with the functionality of tr.
Fixes https://bugs.gnu.org/49764
2021-07-29 13:19:33 +01:00
Paul Eggert
d60b2922ff doc: modernize usage of “disk” and “core”
In documentation and comments, don’t assume that secondary storage
devices are disk devices.  Similarly, don’t assume that main memory
uses magnetic cores, which became obsolete in the 1970s.
* src/du.c (usage):
* src/ls.c (usage):
* src/shred.c (usage): Reword to avoid “disk” in usage messages.
2021-07-28 12:30:12 -07:00
Paul Eggert
1625916a1b doc: improve ls documentation
* doc/coreutils.texi (ls invocation): Document implementation more
closely.  Be more consistent about style.  Omit some needless words.
* src/ls.c (usage): Don’t overdocument -f, as the details were wrong.
Omit -1 advice as it’s a bit obsolete now that we have --zero and
is a bit much for --usage output anyway.
2021-07-28 12:30:12 -07:00
Paul Eggert
c75779cac3 ls: rename --null to --zero (Bug#49716)
* NEWS, doc/coreutils.texi (General output formatting):
* src/ls.c (usage):
Document this.
* src/ls.c (ZERO_OPTION): Rename from NULL_OPTION.
All uses changed.
(long_options): Rename --null to --zero.
(dired_dump_obstack, main, print_dir): Use '\n' instead of
eolbyte where eolbyte must equal '\n'.
(decode_switches): Decode --zero instead of --null.
--zero also implies -1, -N, --color=none, --show-control-chars.
Use easier-to-decipher code to set ‘format’ and ‘dired’.
Reject attempts to combine --dired and --zero.
* tests/local.mk: Adjust to test script renaming.
* tests/ls/zero-option.sh: Rename from tests/ls/null-option.sh,
and test --zero instead of --null.
2021-07-27 18:08:39 -07:00
Paul Eggert
7d44ac224c ls: add --null option (Bug#49716)
* NEWS, doc/coreutils.texi (General output formatting):
* src/ls.c (usage): Document this.
* src/ls.c (NULL_OPTION): New constant.
(long_options): Add --null.
(eolbyte): New static var.
(dired_dump_obstack, main, print_dir, print_current_files)
(print_many_per_line, print_horizontal, print_with_separator):
Output eolbyte instead of '\n'.
(decode_switches): Decode --null.
* tests/ls/null-option.sh: New file.
* tests/local.mk (all_tests): Add it.
2021-07-26 00:59:37 -07:00
Pádraig Brady
4a8278229e stat: support more device number representations
In preparation for changing the default device number
representation (to decomposed decimal), provide more
formatting options for device numbers.

These new (FreeBSD compat) formatting options are added:

   %Hd  major device number in decimal (st_dev)
   %Ld  minor device number in decimal (st_dev)
   %Hr  major device type in decimal (st_rdev)
   %Lr  minor device type in decimal (st_rdev)
   %r   (composed) device type in decimal (st_rdev)
   %R   (composed) device type in hex (st_rdev)

* doc/coreutils.texi (stat invocation): Document new formats.
* src/stat.c (print_it): Handle the new %H and %L modifiers.
(print_statfs): Adjust to passing the format as two chars
rather than an int.  Using an int was introduced in commit db42ae78,
but using separate chars is cleaner and more extensible.
(print_stat): Likewise.  Handle any modifiers and the new 'r' format.
(usage): Document the new formats.
* tests/misc/stat-fmt.sh: Add a test case for new modifiers.
Addresses https://bugs.gnu.org/48960
2021-06-21 12:01:04 +01:00
Pádraig Brady
34a48bf0f0 doc: clarify that ln --relative requires --symbolic to be specified
* doc/coreutils.texi (ln invocation): State --symbolic is required.
* src/ln.c (usage): Explicitly state -s is not implied.
Fixes https://bugs.gnu.org/47703
2021-04-11 19:23:37 +01:00
Pádraig Brady
512fe04902 doc: clarify what's counted by wc
* src/wc.c (usage): State that only printable characters are considered
when counting words.  This also disambiguates wether we're talking
about bytes or characters in this context.
* doc/coreutils.texi (wc invocation): Likewise.  Also clarify
that --characters counts valid locale aware characters,
and that --lines does not count a trailing "line" unless
it ends with a newline character.
Fixes https://bugs.gnu.org/47702
2021-04-11 19:23:13 +01:00
Carl Edquist
751ad58e00 ls: add --sort=width option to sort by file name width
This helps identify the outliers for long filenames, and also produces
a more compact display of columns when listing a directory with many
entries of various widths.

* src/ls.c (sort_type, sort_types, sort_width): New sort_width sort
type.
(sort_args): Add "width" sort arg.
(cmp_width, fileinfo_width): New sort function and helper for file name
width.
(quote_name_width): Add function prototype declaration.
(usage): Document --sort=width option.
* doc/coreutils.texi: Document --sort=width option.
* tests/ls/sort-width-option.sh: New test for --sort=width option.
* tests/local.mk: Reference new test.
* NEWS: Mention the new feature.
2021-04-11 14:58:38 +01:00
Paul Eggert
6c4efdc0f5 doc: document env fix
* NEWS, doc/coreutils.texi (env invocation): Document recent change.
2021-03-26 15:17:28 -07:00
Paul Eggert
a71539e628 ptx: remove use of diacrit module
The diacrit module is obsolete, and ptx’s use of it is obsolete
too; it assumes an 8-bit locale (not that common these days) and
that TeX cannot process the 8-bit characters (nowadays, it can).
* NEWS, doc/coreutils.texi (Charset selection in ptx): Document this.
* bootstrap.conf (gnulib_modules): Remove diacrit.
* src/ptx.c: Do not include diacrit.h.
(print_field, fix_output_parameters): Remove obsolete support
for 8-bit diacritics.
2021-03-21 14:01:15 -07:00
Pádraig Brady
2de30c7350 cat: extend --show-ends to show \r\n as ^M$
- \r\n is common a line end combination
  - catting such a file without options causes it to display normally
  - overwriting the first char with $, loses info

* src/cat.c (cat): Convert \r preceeding a \n to ^M.
* tests/misc/cat-E.sh: New test.
* tests/local.mk: Reference new test.
* tests/misc/cat-proc.sh: Fix typo.
* doc/coreutils.texi (cat invocation): Mention the new behavior.
* NEWS: Mention the improvement.
2021-02-10 14:17:26 +00:00
Paul Eggert
735083ba24 expr: fix bug with unmatched \(...\)
Problem reported by Qiuhao Li.
* NEWS: Mention this.
* doc/coreutils.texi (String expressions):
Document the correct behavior, which POSIX requires.
* src/expr.c (docolon): Treat unmatched \(...\) as empty.
* tests/misc/expr.pl: New test.
2021-01-26 09:24:41 -08:00
Paul Eggert
eebed78799 doc: rmdir --recursive substitutes
* doc/coreutils.texi (rmdir invocation): Add note on how to remove
empty subdirectories recursively.
2021-01-18 21:09:27 -08:00
Paul Eggert
06f70d9ee6 doc: modernize and fix regexp xref
* doc/coreutils.texi: Fix regexp cross-reference that had become
out-of-date (Bug#45749).  Also, fix some obsolete references to
SunOS and to /usr/dict/words, and change “Linux” to “GNU/Linux”
where appropriate.  Unfortunately the pipeline example gets more
complicated since /usr/share/dict/words is not sorted the way that
‘comm’ wants.
2021-01-09 13:05:50 -08:00
Bernhard Voelker
f01d9e23db maint: exempt 'doc/fdl.texi' from 'make update-copyright'
This file is a copy from gnulib and therefore should not get changed
by the yearly update.

* .x-update-copyright: Add pattern for the above file.
* doc/fdl.texi: Revert the previous change.
2021-01-02 01:39:15 +01:00
Pádraig Brady
32ff1d1313 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.
2021-01-01 16:36:09 +00:00
Pádraig Brady
08b59f31a5 doc: remove extraneous ./src/ prefix from examples
* doc/coreutils.texi (numfmt invocation): s|./src/numfmt|numfmt|
2020-12-18 14:58:59 +00:00
Pádraig Brady
e5cb4aaa0b doc: add seq inf and sleep inf examples to texinfo
* doc/coreutils.texi (seq invocation): Mention "inf" is supported,
and describe that it's handled specially to generate infinite
whole integer sequences.  Also mention that such infinite generation
is supported for integer steps up to 200.
(sleep invocation): Give `sleep inf` as an example to sleep forever.
* src/seq.c: Add a comment on SEQ_FAST_STEP_LIMIT, to say it's
reflected in the texinfo description.
2020-12-18 14:54:57 +00:00
Paul Eggert
3e61d5dd31 doc: document mkdir -m -p better
Chris Colohan wrote that the man page did not do enough to dispel
a common misunderstanding that “contributed to one of the scariest
outages Google has ever seen” (Bug#45258).
* doc/coreutils.texi (mkdir invocation):
* src/mkdir.c (usage): Document -m vs -p better.
2020-12-15 11:58:48 -08:00
Pádraig Brady
1935528ce9 doc: mention the GNU extensions to nl --section-delimiter
* doc/coreutils.texi (nl invocation): Mention the GNU extensions
of allowing arbitrary length and empty delimiter strings.
* src/nl.c (usage): Likewise.
* tests/misc/nl.sh: Add test cases for the GNU extensions.
2020-12-15 14:11:51 +00:00
Pádraig Brady
c3a5280731 doc: mention that sort -g supports hex numbers
* doc/coreutils.texi (sort invocation): Mention explicitly
that --general-numeric-sort supports arbitrary format hex numbers,
but also mention that consistent case/width hex numbers can
be sorted faster with a standard sort.
2020-11-18 14:00:43 +00:00
Ben Pfaff
1833f51aaa doc: clarify in texinfo that test == ... is non portable
* doc/coreutils.texi (test invocation): Mention non portability
of the double equals form.
2020-11-12 18:59:31 +00:00
KOBAYASHI Takashi
2c898597ea nl: support a negative --line-increment
* src/nl.c (main): Allow -i to accept down to INTMAX_MIN.
* tests/misc/nl.sh: Add test cases.
* NEWS: Mention the new feature.
2020-10-26 13:15:46 +00:00
Pádraig Brady
5b8161ee4d doc: clarify timeout --foreground description
* doc/coreutils.texi (timeout invocation): Avoid any implication
that `timeout --foreground` could be used to retroactively
timeout commands not already invoked by timeout(1).
Fixes bug https://bugs.gnu.org/42831
2020-08-12 18:40:17 +01:00
Bernhard Voelker
881c3f20ec doc: show version in title of HTML manual
* doc/coreutils.texi (@include version.texi): Move before ...
(@settitle): ... this.  Add the version after the package name.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-07/msg00021.html
2020-07-28 23:30:11 +02:00
Pádraig Brady
97757b5eba doc: fix typo in env --split-string documentation
* doc/coreutils.texi: Fix grammar.
2020-07-27 13:16:42 +01:00
Paul Eggert
3f06bde222 doc: modernize date examples
* doc/coreutils.texi: Use more-modern date examples.
Capitalize “Epoch” to be consistent with POSIX.
2020-07-24 13:33:40 -07:00
Bernhard Voelker
49bd08aea5 doc: clarify 'timeout -k' behavior
* doc/coreutils.texi (timeout invocation): Document that the the
duration of --kill-after=DURATION begins when sending the initial
signal.  Also mention that -k does not have any effect if timeout's
duration is 0.

Suggested by Jonny Grant <jg@jguk.org>.
2020-07-20 22:02:02 +02:00
Paul Eggert
55d985064c factor: explain why non-GMP code (Bug#42269)
* doc/coreutils.texi (factor invocation):
* src/factor.c: Explain why the two-word algorithm is useful.
2020-07-08 18:59:41 -07:00
Paul Eggert
67fc55d636 doc: mention expr and factor bignums
* NEWS:
* doc/coreutils.texi (expr invocation, factor invocation):
Mention bignum support on all platforms.  Modernize timings.
2020-07-08 08:11:57 -07:00
Bernhard Voelker
b1c6ef230c doc: add timeout examples
* doc/coreutils.texi (timeout invocation): Add examples.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-06/msg00018.html
2020-07-04 00:19:31 +02:00
Paul Eggert
25725f9d41 cp: default to COW
Likewise for ‘install’.  Proposed in Bug#24400, and long past due.
* NEWS:
* doc/coreutils.texi (cp invocation):
* src/copy.h (enum Reflink_type): Document this.
* src/cp.c (cp_option_init):
* src/install.c (cp_option_init): Implement this.
2020-06-18 22:38:06 -07:00
Bernhard Voelker
189776ff3b doc: timeout: improve documentation of the exit status
* doc/coreutils.texi (timeout invocation): Document that the exit
status is 137 when the KILL signal is used, regardless of whether that
signal is sent to COMMAND or timeout.
* src/timeout.c (usage): Likewise. Also split out and expand
on the possible exit status values to a separate table.

Discussed at https://bugs.gnu.org/41634
2020-06-07 15:41:48 +02:00
Bernhard Voelker
aefd434e56 maint: copy FDL from gnulib instead of using it as module
Since the previous gnulib update, bootstrap outputs this warning:

  Notice from module fdl:
    Don't use this module! Instead, copy the referenced license file \
    into your version control repository.

See gnulib commit:
  https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=88fc5afbccc9

* bootstrap.conf (gnulib_modules): Remove 'fdl'.
* doc/fdl.texi: Add file as a copy of 'gnulib/doc/fdl.texi'.
* doc/.gitignore (/fdl.texi): Remove entry.
* cfg.mk (FILTER_LONG_LINES): Add pattern for the 'fdl.texi' file.
2020-05-25 16:31:08 +02:00
Paul Eggert
6d0107a37f date: document +%-N change
Suggested by Kamil Dudka in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00205.html
* NEWS: Mention the change for coreutils 8.23.
* doc/coreutils.texi (Padding and other flags):
Document it.
2020-05-20 17:32:53 -07:00
Jason Kim
9c8a385aa4 ls: allow --classify to be ignored for non tty output
Have the `ls` `--classify` option take an optional argument for when to
classify ("always", "auto", "never"), just like the optional argument
for `--color`.  When the optional argument is not specified, default to
"always" for backwards compatibility.

* src/ls.c (usage): Update help text.
(decode_switches): Support an optional argument for --classify.
* tests/ls/classify.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2020-04-27 13:48:32 +01:00
Bernhard Voelker
9b4bb9d28a maint: add texi2dvi build directory to doc/.gitignore
* doc/.gitignore (/coreutils.t2p/): Add entry for the build directory
left behind after 'make pdf'.
While at it, sort the file.
2020-03-15 11:20:41 +01:00
Pádraig Brady
61c49d3693 doc: clarify that '%a' stat format outputs mode bits
* src/stat.c (usage): Mention permission bits rather than
"access" so there is no confusion with ACLs etc.
Also indicate we output the file type with '%A'.
* doc/coreutils.texi (stat invocation): Likewise.
Also indicate '%A' is similar to `ls -ld` output.
Addresses https://bugs.gnu.org/39613
2020-02-15 11:24:15 +00:00
Pádraig Brady
2cecc3cc99 ls: support --time=creation to show/sort birth time
* src/ls.c (usage): Reorganize help for --time,
and add description for --time=birth.
(do_statx): Store btime in mtime if available.
(get_stat_btime): A new function to read the creation time
from the appropriate stat structure member.
(cmp_btime): A new function to compare birth time.
(print_long_format): Output '?' when birth time unavailable.
* doc/coreutils.texi: Document --time={birth,creation}.
* tests/local.mk: Reference the new test.
* tests/ls/birthtime.sh: Add a new test.
* NEWS: Mention the new feature.
2020-02-03 19:37:56 +00:00
Pádraig Brady
aaba82431c 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.
2020-01-01 14:16:56 +00:00
Bernhard Voelker
7490e94aa7 doc: add example to demonstrate sub-second sleep times
* doc/coreutils.texi (sleep invocation): Add an example to demonstrate
how to use the floating-point and the scientific notation to sleep
for sub-second times, e.g. milli-, micro- and nanoseconds.

Inspired by Stephane Chazelas in:
  https://lists.gnu.org/r/coreutils/2019-12/msg00005.html
2019-12-08 17:44:37 +01:00
Paul Eggert
ad591a52b4 doc: remove colon from node name
* doc/sort-version.texi (Minus/Hyphen and Colon characters):
Rename from “Minus/Hyphen @samp{-} and Colon @samp{:} characters”,
as texi2any 6.6 complains about colons in node names.
2019-11-11 16:54:19 -08:00
Paul Eggert
0103fb0244 shred: modernize documentation
* doc/coreutils.texi (shred invocation):
Modernize discussion to today’s technology (Bug#38168).
* src/shred.c (usage): Omit lengthy duplication of the manual’s
discussion of file systems and storage devices, as that became out
of sync with the manual.  Instead, just cite the manual.
2019-11-11 16:54:19 -08:00
Pádraig Brady
becf0db0da doc: clarify that truncate creates sparse files
* src/truncate.c (usage): Explicitly mention "sparse".
* doc/coreutils.texi (truncate invocation): Likewise.
Addresses https://bugs.gnu.org/36963
2019-08-08 13:34:54 +01:00
Bernhard Voelker
c0f2219d3a doc: improve new version sort chapter
* doc/sort-version.texi: Fix some typos, avoid overly long lines in
the generated PDF, enclose some sample strings in @samp{...} for better
readability, etc.  This also avoids an sc-avoid-builtin error:
s/builtin/built-in/
2019-07-22 08:52:52 +02:00
Assaf Gordon
3264d4ca0d doc: add "version sort ordering" chapter
* doc/sort-version.texi: New file.
* doc/local.mk (doc_coreutils_TEXINFOS): Add new file.
* doc/coreutils.texi: @include new file, replace previous "Details about
version sort" section.
2019-07-15 13:28:20 -06:00
Paul Eggert
a3a454b9d9 doc: mention ls -l user/group justification
* doc/coreutils.texi (What information is listed):
Document justification of user and group columns in ls -l output
(Bug#36220).
2019-06-18 00:32:25 -07:00
Jeff Layton
6cc35de16f stat: Use statx where available and support --cached
* src/stat.c: Drop statbuf argument from out_epoch_sec().
Use statx() rather than [lf]stat() where available,
so a separate call is not required to get birth time.
Set STATX_* mask bits only for things we want to print,
which can be more efficient on some file systems.
Add a new --cache= command-line option that sets the appropriate hint
flags in the statx call.  These are primarily used with network
file systems to indicate what level of cache coherency is desired.
The new option is available unconditionally for better portability,
and ignored where not implemented.
* doc/coreutils.texi: Add documention for --cached.
* man/stat.x (SEE ALSO): Mention statx().
* NEWS: Mention the new feature.
2019-06-10 22:59:28 +01:00
Pádraig Brady
bb481a0c1d doc: fix description of tail -f on truncated files
* doc/coreutils.texi (tail invocation): Update to match
the new behavior following commit v8.23-189-gb28ff6a
2019-06-09 12:42:15 +01:00
Martin Castillo
4f38974aaf doc: fix typo in sort set operations example
* doc/coreutils.texi (sort invocation): Add a missing -u
option to uniq.
Addresses https://bugs.gnu.org/35849
2019-05-22 14:44:56 +01:00
Paul Eggert
59e01d13e6 dd: improve doc of stderr output
* doc/coreutils.texi (dd invocation):
Document stderr output more carefully.
Say that conv=block can lose input data.
2019-03-19 20:09:02 -07:00
Kamil Dudka
6bd78f27fd doc: improve wording of the --kibibytes option description
Bug: https://bugzilla.redhat.com/1527391 , https://bugs.gnu.org/33646

* doc/coreutils.texi (General output formatting): Improve wording of
'--kibibytes' option.
2019-03-15 12:26:02 -06:00
Assaf Gordon
bf2f64c7d5 doc: replace @hashchar{} with actual hash character
Very old makeinfo-4.13 fails with:
  ./doc/coreutils.texi:2286: Unknown command `hashchar'.
  ./doc/coreutils.texi:2286: Misplaced {.
  ./doc/coreutils.texi:2286: Misplaced }.

Reported Bernhard Voelker in
https://lists.gnu.org/r/coreutils/2019-03/msg00016.html .

* doc/coreutils.texi (basenc invocation): Replace @hashchar{} with
actual hash character.  The special syntax is only required
when referring to #line directives.
2019-03-06 21:59:27 -08:00
Pádraig Brady
6bf6d7f461 env: add --list-signal-handling to output non default handling
* src/env.c (main): Output blocked or ignored signals
before a command is executed.
* doc/coreutils.texi (env invocation): Add the option.
* tests/misc/env-signal-handler.sh: Add a test case.
* NEWS: Mention the new feature.
2019-03-04 00:37:42 -08:00
Assaf Gordon
95adadd9a4 env: new options --{default,ignore,block}-signal[=SIG]
New options to set signal handlers for the command being executed.
--block-signal suggested by Paul Eggert in http://bugs.gnu.org/34488#71
--default-signal is useful to overcome the POSIX limitation that shell
must not override inherited signal state, e.g. the second 'trap' here is
a no-op:

   trap '' PIPE && sh -c 'trap - PIPE ; seq inf | head -n1'

Instead use:

   trap '' PIPE && sh -c 'env --default-signal=PIPE seq inf | head -n1'

Similarly, the following will prevent CTRL-C from terminating the
program:

   env --ignore-signal=INT seq inf > /dev/null

See https://bugs.gnu.org/34488#8

* NEWS: Mention new options.
* doc/coreutils.texi (env invocation): Document new options.
* man/env.x: Add example of --default-signal=SIG usage.
(SEE ALSO): Mention sigprocmask.
* src/env.c (signals): New global variable.
(longopts): Add new options.
(usage): Print new options.
(parse_signal_params): Parse comma-separated list of signals, store in
signals variable.
(reset_signal_handlers): Set each signal to SIG_DFL/SIG_IGN.
(parse_block_signal_params): Parse command-line options.
(set_signal_proc_mask): Call sigprocmask to block/unblock signals.
(main): Process new options.
* src/local.mk (src_env_SOURCES): Add operand2sig.c.
* tests/misc/env-signal-handler.sh: New test.
* tests/local.mk (all_tests): Add new test.
2019-03-04 00:37:07 -08:00
Bernhard Voelker
4ae1369516 doc: further clarify 'yes' alternative in seq invocation
* doc/coreutils.texi (node seq invocation): Clarify to use the tool
'yes'; otherwise the reader may interpret the sentence as if one
could pass 'yes' as the INCREMENT value.
2019-02-27 18:51:30 +01:00
Paul Eggert
2ab2f7a422 doc: more date +%F clarifications
* doc/coreutils.texi (Date conversion specifiers):
Plain %F is actually like %+4Y-%m-%d.
(Padding and other flags): Mention POSIX restrictions.
* src/date.c (usage): Document recent changes.
2019-02-25 10:21:07 -08:00
Paul Eggert
d5c820109e doc: give date +%+F example
* doc/coreutils.texi (Padding and other flags):
Give example for + conversion specification.
2019-02-25 08:03:38 -08:00
Paul Eggert
3e7fd6650e doc: fix typo in previous patch 2019-02-25 00:25:25 -08:00
Paul Eggert
b1e7af28eb date: ‘+’ conversion specification flag
The recent Gnulib update fixed Bug#34608; document and test this.
* NEWS: Mention the change.
* doc/coreutils.texi (Padding and other flags):
Update doc to cover new flag and other POSIX.1-2017 changes.
* tests/misc/date.pl (date-century-plus): New test.
2019-02-24 23:59:55 -08:00
Martin Castillo
f473489f48 doc: fix join examples in texinfo
* doc/coreutils.texi (join invocation): Fix various errors.
Fixes https://bugs.gnu.org/34583
Fixes https://bugs.gnu.org/34584
2019-02-19 23:29:04 -08:00
Filipp Gunbin
620112526b doc: fix typo referencing RFC 2822
* doc/coreutils.texi (date invocation): s/822/2822/.
Fixes https://bugs.gnu.org/34438
2019-02-11 22:56:08 -08:00
Paul Eggert
3fe8bc09be printf,seq,sleep,tail,timeout: accept current-locale floats
These commands now accept floating-point numbers in the
current locale, as well as in the C locale.
Compatibility problem reported by Robert Elz.
* NEWS: Document this.
* bootstrap.conf (gnulib_modules): Add cl-strtod, cl-strtold.
Remove c-strtold.
* doc/coreutils.texi (Floating point, tail invocation)
(printf invocation, timeout invocation, sleep invocation)
(seq invocation): Document this.
* gl/lib/cl-strtod.c, gl/lib/cl-strtod.h, gl/lib/cl-strtold.c:
* gl/modules/cl-strtod, gl/modules/cl-strtold: New files.
* src/printf.c, src/seq.c, src/sleep.c, src/tail.c, src/timeout.c:
Include cl-strtod.h instead of c-strtod.
* src/printf.c (vstrtold):
* src/seq.c (scan_arg, print_numbers):
* src/sleep.c (main):
* src/tail.c (parse_options):
* src/timeout.c (parse_duration):
Use cl_strtold instead of c_strtold.
2019-01-26 22:41:09 -08:00
Paul Eggert
3cd48057c7 doc: update Goldberg URL
* doc/coreutils.texi (Floating point): Update URL.
2019-01-25 11:32:46 -08:00
Paul Eggert
643a7325ec sleep: improve doc
Problem reported by Robert Elz.
* doc/coreutils.texi (sleep invocation):
Say that arguments must be non-negative, which means they cannot
be arbitrary floating-point numbers.  Mention POSIX, not
“historical implementations” that are no longer of practical
interest.  List the extensions to POSIX.
* src/sleep.c (usage): Omit needless words, removing dubious
commentary about “most implementations” and incorrect commentary
about “arbitrary”.  Details about exactly which numbers are
allowed can be found in the documentation.
2019-01-25 11:17:18 -08:00
Assaf Gordon
8dfcf38af1 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.
2019-01-01 16:51:48 -07:00
Assaf Gordon
2f438fa9f5 basenc: A new program complementary to base64/base32
Encodes/decodes data in various common formats:
base64,base64url,base32,base32,base16,base2,z85.

Discussed here:
https://lists.gnu.org/r/coreutils/2018-11/msg00014.html
https://lists.gnu.org/r/coreutils/2018-12/msg00019.html

* AUTHORS: Add basenc.
* README: Reference the new program.
* NEWS: Mention the new program.
* build-aux/gen-lists-of-programs.sh: Add basenc.
* doc/coreutils.texi: (basenc invocation): Document the new command.
* man/.gitignore: Ignore the generated man page.
* man/basenc.x: A new template, with few examples.
* man/local.mk: Reference the new man page.
* scripts/git-hooks/commit-msg: Allow basenc as program prefix.
* src/.gitignore: Ignore the new binary.
* src/basenc.c:
(usage): Mention new options.
(main): Handle new options.
(isbase*, base*_length, base*_encode, base*_decode_ctx): Implement new
encoding/decoding formats.
* src/local.mk: Add new program.
* tests/local.mk: Add new test.
* tests/misc/basenc.pl: New tests.
* tests/misc/help-version.sh (basenc_setup): use '--version' for default
invocation (basenc errors with no parameters).
2018-12-27 23:46:02 -07:00
Pádraig Brady
8d328706c6 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.
2018-10-27 03:05:24 -07:00
Bernhard Voelker
1a674a036b 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.
2018-10-26 11:05:25 +02:00
Paul Eggert
8ea92f2a1d doc: tidy up setuid commentary
* doc/perm.texi (Mode Structure): Improve wording.
(Numeric Modes): Don’t say “on execution” (Bug#9594).
2018-10-20 10:59:17 -07:00
Paul Eggert
4d5db7193c doc: add chmod examples
Discussed in https://bugs.gnu.org/11043 .

* doc/coreutils.texi (chmod invocation): Add examples.
2018-10-17 14:31:04 -06:00
Achilles Gaikwad
a32a756a58 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.
2018-09-29 22:39:26 -07:00
Stéphane Campinas
7262994810 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
2018-09-24 23:48:56 -07:00
Pádraig Brady
f7b2502100 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
2018-09-23 21:17:04 -07:00
Wodry
46d6bd0c0a 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
2018-07-22 08:37:15 -07:00
Pádraig Brady
68cf7ad5ad 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.
2018-06-30 18:56:39 -07:00
Pádraig Brady
c932e5c9ec 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.
2018-06-20 21:18:32 -07:00
Adam Borowski
163df41d45 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.
2018-06-20 21:17:19 -07:00
Assaf Gordon
668306ed86 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.
2018-06-20 21:15:31 -07:00
Assaf Gordon
a0118a71bb 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.
2018-06-20 21:14:47 -07:00
Pádraig Brady
c744c65f50 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.
2018-06-20 21:01:14 -07:00
Pádraig Brady
c732388fa1 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
2018-05-17 20:52:09 -07:00
Pádraig Brady
a391007511 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
2018-05-15 09:52:44 -07:00
Paul Eggert
a8a52e2f05 doc: Clarify octal bits in permissions
* doc/perm.texi (Numeric Modes): Briefly explain octal.
Reorder description to make it more intuitive (Bug#29069).
2018-04-03 08:41:14 -07:00
Pádraig Brady
33f17ab9db 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.
2018-01-21 11:40:57 -08:00
Michael Orlitzky
bc2fd97964 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
2018-01-10 08:45:24 +01:00
Paul Eggert
7e244891b0 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.
2018-01-04 13:57:58 -08:00
Michael Orlitzky
7597cfa482 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.
2018-01-03 19:11:07 +01:00
Pádraig Brady
ece7157933 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.
2018-01-01 15:57:22 +00:00
Bernhard Voelker
47fb363432 doc: mention which privileges are needed to chmod
POSIX specification for chmod(1):
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html

* doc/coreutils.texi (chmod invocation): Add a sentence about who can
change the file mode bits of a file - (almost) a copy from what POSIX
requires.

Fixes https://bugs.gnu.org/29207.
2017-12-18 08:07:12 +01:00
Pádraig Brady
6150b10698 doc: shred: change 'truncate' to the more descriptive 'deallocate'
* doc/coreutils.texi (shred invocation): s/truncate/deallocate/.
* src/shred.c (usage): Likewise.
Fixes https://bugs.gnu.org/29317
2017-12-09 16:54:03 -08:00
Pádraig Brady
f17c1df391 doc: clarify that cp --force may recreate files
* doc/coreutils.texi (cp invocation): The language used
to describe recreating the file was a little confusing
as it mentioned opening a removed file.
Fixes https://bugs.gnu.org/29315
2017-12-09 16:18:00 -08:00
Kamil Dudka
e184a46e39 doc: fix default QUOTING_STYLE for %N format of stat(1)
* doc/coreutils.texi (stat invocation): The default value
of QUOTING_STYLE for the %N format of 'stat --printf' is
'shell-escape-always'.
Fixes https://bugs.gnu.org/29563
Reported by Christian Groessler at
https://bugzilla.redhat.com/1520399#c3
2017-12-04 10:29:42 -08:00
Pádraig Brady
559c7a57c7 timeout: add --verbose to diagnose timeouts
This is useful as handling in shell is complicated
with the varying exit status in the --kill-after case.

* src/timeout.c (main): Handle '-v' and store
COMMAND for the diagnostic.
(cleanup): Diagnose the signal name before sending.
(usage): Document -v, --verbose.
* doc/coreutils.texi (timeout invocation): Likewise.
* tests/misc/timeout.sh: Add a test case.
* NEWS: Mention the new feature
Fixes https://bugs.gnu.org/21760
2017-11-23 17:46:55 -08:00
Bernhard Voelker
e83f10c483 doc: fix "Up" field of realpath usage examples
Older versions of 'makeinfo' choke on a missing reference:

  ./doc/coreutils.texi:14177: `Realpath usage examples' has no Up field\
  (perhaps incorrect sectioning?).
  makeinfo: Removing output file `doc/coreutils.info' due to errors; \
  use --force to preserve.

* doc/coreutils.texi (realpath invocation): Add a menu referencing
the usage examples - introduced in v8.27-91-g7449f0d.
2017-11-05 16:56:39 -08:00
Pádraig Brady
de15a497d1 dd: fix nocache regions passed to posix_fadvise()
Previously with oflag=direct the call to invalidate_cache()
was not passed to the kernel, as it was less than a page size,
and a subsequent call was not made to invalidate the pending space.
Similarly with oflag=nocache the pending space at EOF was
not invalidated.  Even though these amount to only a single page
in the page cache it can be significant.  For example on
XFS before kernel patch v4.9-rc1-4-g0ee7a3f, O_DIRECT files
would have been read inefficiently if any pages were cached,
even if they were already synced to storage.

* src/dd.c (i_nocache_eof, o_nocache_eof): New bools used
to control when we want invalidate_cache(,0) to clear to EOF.
(cache_round): Use IO_BUFSIZE (currently 132KiB) to minimize
calls to the relatively expensive advise function, rather
than page_size.  This also makes it clear that while the
kernel function operates on pages, this size is chosen for
performance reasons.
(invalidate_cache): Refactor to share more code between
input and output paths. Use i_nocache_eof and o_nocache_eof
rather than proxying off max_records.  Ensure we
invalidate full pages when clearing to EOF as the kernel
will ignore any non complete pages.  Fix the offset used
for the output path.
(dd_copy): Invalidate the cache of the input after the
offset is updated, for consistency and so we don't try to
invalidate before the start of the file.  When we read
EOF on input, set flags so that we invalidate to EOF.
(main): Invalidate to EOF in more cases, by depending
on the i_nocache_eof and o_nocache_eof flags.
* doc/coreutils.texi (dd invocation): Clarify the alignment
and persisted caveats on the example applying "nocache"
to part of a file.
* tests/dd/nocache_eof.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Issue reported by Eric Bergen.
2017-10-24 19:38:12 -07:00
Paul Eggert
4b8c92b940 copy: revert recent patch for vulnerable dirs
I plan to propose a better patch to catch vulnerable parent
directories.
* NEWS, doc/coreutils.texi (Target directory): Document this.
* src/cp.c, src/install.c, src/ln.c, src/mv.c:
Do not include targetdir.h.
(target_directory_operand): Remove test for vulnerable parents.
* src/cp.c (stat_target_operand): Remove.  All uses removed.
* src/local.mk (noinst_HEADERS): Remove src/targetdir.h.
(src_ginstall_SOURCES, src_cp_SOURCES, src_ln_SOURCES)
(src_mv_SOURCES): Remove src/targetdir.c.
* src/targetdir.c, src/targetdir.h: Remove.
* tests/mv/vulnerable-target.sh: Remove.
* tests/local.mk (all_root_tests): Remove it.
2017-09-24 23:10:56 -07:00
Pádraig Brady
0be99382d9 maint: fix new syntax check failures from copy restrictions
* doc/coreutils.texi: Remove doubled word.
* src/targetdir.c: Explicitly mark exported function.
* tests/local.mk: This is not a root only test.
* tests/mv/vulnerable-target.sh: Use returns_.
Introduced in v8.28-3-g44ccd1c
2017-09-19 22:21:28 -07:00
Paul Eggert
be87d61299 all: prefer HTTPS in URLs 2017-09-19 01:22:54 -07:00