Commit Graph

29457 Commits

Author SHA1 Message Date
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
3f7519130a cp: avoid unnecessary buffer allocation
Do not allocate I/O buffer if copy_file_range suffices.
* src/copy.c (sparse_copy, lseek_copy): Buffer arg is now char **
instead of char *, and buffer is now allocated only if needed.
All uses changed.
2022-02-21 00:19:24 -08:00
Paul Eggert
7dbe465fd3 build: update gnulib submodule to latest 2022-02-19 15:54:45 -08:00
Pádraig Brady
cee468f9c5 doc: env: fix man page reference of exec(2) to exec(3p)
* man/env.x: Change exec() reference from section 2 to 3p.
2022-02-15 17:07:22 +00:00
Pádraig Brady
63228501e6 doc: use bold style for man page references
It's more common to use bold style than not,
for references to other man pages.
Ideally each man page renderer would highlight references,
but currently some rely on styles in the page itself.

* man/help2man: Implement a --bold-refs option that
will mark up references like "name(1)" with bold
style around the "name" component.
* man/local.mk: Pass --bold-refs to our help2man unless disabled.
* configure.ac: Add a --disable-bold-man-page-references option.
Addresses https://bugs.gnu.org/53977
2022-02-15 17:07:22 +00:00
Pádraig Brady
041dfff5db dircolors: speed up processing of TERM entries
* src/dircolors.c (main): Avoid glob matching
when we've already matched in a group of {COLOR,}TERM entries.
2022-02-15 17:01:19 +00:00
Pádraig Brady
75c9fc6740 dircolors: consider COLORTERM as well as TERM env vars
COLORTERM is an environment used usually to expose truecolor support in
terminal emulators.  Therefore support matches on that in addition
to TERM.  Also set the default COLORTERM match pattern so that
we apply colors if COLORTERM is any value.

This implicitly supports a terminal like "foot"
without a need for an explicit TERM entry.

* NEWS: Mention the new feature.
* src/dircolors.c (main): Match COLORTERM like we do for TERM.
* src/dircolors.hin: Add default config to match any COLORTERM.
* tests/misc/dircolors.pl: Add test cases.
2022-02-15 17:01:19 +00:00
Paul Eggert
0b0f1965fb tr: mention multibyte problem in man page
* man/tr.x: Document tr problem.
2022-02-14 12:16:40 -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
Pádraig Brady
26db930c81 chown,chgrp: reinstate numeric id output in -v messages
since gnulib commit ff208d546a,
related to coreutils commit v9.0-143-gabde15969
we no longer maintain numeric IDs through chopt->{user,group}_name.
Therefore we need to adjust to ensure tests/chown/basic.sh passes.

* src/chown-core.c (uid_to_str, gid_to_str): New helper functions
to convert numeric id to string.
(change_file_owner): Use the above new functions to pass
numeric ids to describe_change().
2022-02-13 14:20:16 +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
e7ccf4775e build: update gnulib submodule to latest 2022-02-12 20:15:02 -08:00
Pádraig Brady
195e943be7 doc: avoid using "[" is URLS in --help output
* src/system.h (emit_ancillary_info): While supported if entered
  manually, the "[" character is not highlighted as part of a
  URL by default in terminals, so avoid using it.
  Addresses https://bugs.gnu.org/53946
2022-02-12 18:43:25 +00:00
Pádraig Brady
d35b305109 doc: adust --help, --version alignment
* src/system.h: Adjust the alignment of the --help
and --version option descriptions, to start at column 21.
This better aligns with the descriptions of most commands,
and also aligns with the minimum column a description must
start at to ensure a blank line is not output when a description
follows an option on a line by itself.
2022-02-12 18:23:48 +00:00
Pádraig Brady
a4d8d58429 doc: rmdir: improve --help formatting
* src/rmdir.c (usage): Move description to column 21,
so that a --long-option on its own line without a
trailing description, doesn't have an erroneous blank
line inserted between the option and description.
Also group descriptions with blank lines rather than indents,
so that man pages don't have erroneous blank lines
added within the description.
Addresses https://bugs.gnu.org/53946
2022-02-12 18:16:34 +00:00
Pádraig Brady
dc689eba57 doc: ls: reference dircolors(1) from --help
* src/ls.c (usage): s/dircolors/dircolors(1)/.
* man/ls.x [SEE ALSO]: Reference dircolors(1).
Addresses https://bugs.gnu.org/53946
2022-02-12 18:03:38 +00:00
Pádraig Brady
353ba4978f doc: ls: improve --help formatting
* src/ls.c (usage): Use blank lines to group multi-line
option descriptions, rather than indenting.
This results in more consistent alignment of descriptions,
and also avoids erroneous new lines in generated in man pages.
Addresses https://bugs.gnu.org/53946
2022-02-12 17:55:03 +00: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
Christian Hesse
b65ff7e4d0 dircolors: highlight .avif as image
This add highlighting for AV1 Image File Format (AVIF):
https://aomediacodec.github.io/av1-avif/

* src/dircolors.hin: Highlight .avif as image.

Signed-off-by: Christian Hesse <mail@eworm.de>
2022-02-07 13:51:24 +00:00
Paul Eggert
8a3dedfef9 date: test against bug#50115
* tests/misc/date.pl: Add test.
2022-02-05 13:47:07 -08:00
Paul Eggert
cf6c849899 build: update gnulib submodule to latest 2022-02-05 13:47:07 -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
413a6cf521 build: update gnulib submodule to latest 2022-02-04 17:43:45 -08:00
Paul Eggert
abde159693 id: print groups of listed name
Problem reported by Vladimir D. Seleznev (Bug#53631).
* src/id.c (main): Do not canonicalize user name before
deciding what groups the user belongs to.
2022-02-04 14:53:35 -08:00
Bernhard Voelker
9a29ee2903 doc: add NEWS entry for recent cksum change
* NEWS (Changes in behavior): Add entry for commit v9.0-92-ga42a03913.
2022-02-01 13:13:05 +00:00
Paul Eggert
59da65b7fe maint: suppress bogus noreturn warnings
* configure.ac: Move the single-binary code before the
gcc-warnings code, so that the latter can depend on the former.
Suppress -Wsuggest-attribute=noreturn with single binaries,
to avoid diagnostics like the following:
  src/expr.c: In function 'single_binary_main_expr':
  error: function might be candidate for attribute 'noreturn'
Problem reported by Pádraig Brady in:
https://lists.gnu.org/r/coreutils/2022-01/msg00061.html
2022-01-31 22:09:37 -08:00
Paul Eggert
1b552e73e8 tr: pacify -fsanitizer=leak
* src/tr.c (main): Use main_exit, not return, in a couple of
places missed last time.
2022-01-31 22:09:37 -08:00
Paul Eggert
222eee9631 chgrp: fix typo in previous change
* src/chgrp.c (main): Use main_exit, not exit.
2022-01-31 22:09:37 -08:00
Paul Eggert
bcc479b0b5 maint: mark some _Noreturn functions
* src/basenc.c (finish_and_exit, do_encode, do_decode):
* src/comm.c (compare_files):
* src/tsort.c (tsort):
* src/uptime.c (uptime):
Mark with _Noreturn.  Otherwise, unoptimized compilations may warn
that the calling renamed-main function doesn't return a value,
when !lint and when single-binary.
2022-01-31 22:09:37 -08:00
Paul Eggert
fb7579768d df: fix memory leak
* src/df.c (devlist_free): Remove.
(filter_mount_list): Free all of devlist, instead of merely
the entries in devlist_table.
2022-01-31 22:09:37 -08:00
Pádraig Brady
253a46d09f maint: cut: avoid exporting recently added variable
* src/cut.c: Make output_delimiter_default static,
as identified by `make syntax-check`.
2022-01-31 22:00:12 +00:00
Paul Eggert
eb3cd9e97b maint: pacify gcc -flto -Wmaybe-uninitialized
* gl/lib/xdectoint.c (__xnumtoint): Tell gcc that ‘error’
does not return here.
* gl/modules/xdectoint (Depends-on): Add stdbool, verify.
2022-01-31 12:07:39 -08:00
Paul Eggert
604f8a6c4d dd: do not access uninitialized
* src/dd.c (parse_integer): Avoid undefined behavior
that accesses an uninitialized ‘n’ when e == LONGINT_INVALID.
Return more-accurate error code when INTMAX_MAX < n.
2022-01-31 12:07:39 -08:00
Paul Eggert
d0e3b0ae1a uptime: simplify -fsanitize=leak pacification
* src/uptime.c (uptime): Exit here ...
(main): ... instead of here.
2022-01-31 12:07:39 -08:00
Paul Eggert
701fcbc78e uniq: remove IF_LINT
* src/uniq.c (check_file): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
cb99998abe unexpand: remove IF_LINT
* src/unexpand.c (unexpand): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
0ea9aacee9 pr: remove IF_LINT
* src/pr.c (read_line): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
10ded12481 truncate: simplify
* src/truncate.c (do_ftruncate): Check != 0 instead of == -1.
Avoid a cast.
(main): Use C99 style decls after statements.
Simplify ‘open’ logic.
2022-01-31 12:07:39 -08:00
Paul Eggert
f8664b6c8e shred: remove IF_LINT
* src/shred.c (dopass): Remove a no-longer-needed IF_LINT.

(read_line): Remove an IF_LINT; no longer needed with
today’s GCC.
2022-01-31 12:07:39 -08:00
Paul Eggert
5288f5ab5e pr: simplify -fsanitize=leak pacification
* src/pr.c (main): Remove an IF_LINT.
Use main_exit rather than return.
2022-01-31 12:07:39 -08:00
Paul Eggert
75a87dc038 pinky: simplify -fsanitize=leak pacification
* src/pinky.c (short_pinky): exit instead of freeing.
2022-01-31 12:07:39 -08:00
Paul Eggert
00973ca777 paste: remove IF_LINT
* src/paste.c (paste_parallel): Remove no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
aafa9bf069 hostname: simplify
* src/hostname.c (sethostname): Provide a substitute on all
platforms, to simplify the mainline code.
(main): Simplify.  Remove an IF_LINT.
Use main_exit rather than return.
2022-01-31 12:07:39 -08:00
Paul Eggert
dba02d1996 factor: remove IF_LINT
* src/factor.c (factor_using_squfof) [USE_SQUFOF]:
Use plain assert (...), not IF_LINT (assert (...)).
This code is currently never compiled or executed,
so this is merely a symbolic cleanup.
2022-01-31 12:07:39 -08:00
Paul Eggert
ec8f3ea958 expand: remove IF_LINT
* src/expand.c (expand): Remove no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
ed93b50eea env: simplify -fsanitize=leak pacification
* src/env.c (unset_envvars): Remove IF_LINT code.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
04d735ea96 md5sum: remove IF_LINTs
* src/digest.c (digest_check): Remove IF_LINTs that are no longer
needed, as GCC has gotten smarter since 2008.
2022-01-31 12:07:39 -08:00
Paul Eggert
c55372d0d8 df: simplify -fsanitize=leak pacification
* src/df.c (print_table, main) [lint]: Omit unnecessary cleanup.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00