Commit graph

15280 commits

Author SHA1 Message Date
Dag-Erling Smørgrav ed1967df2d asa: Rewrite to fix line termination issue.
The standard is somewhat unclear, but on the balance, I believe that the
phrase “the rest of the input line” should be interpreted to mean the
rest of the input line including the terminating newline if and only if
there is one.  This means the current implementation is incorrect on two
points:

- First, it suppresses the previous line's newline in the '1' case.

- Second, it unconditionally emits a newline at the end of the output
  for non-empty input, even if the input did not end with a newline.

Resolve this by rewriting the main loop.  Instead of special-casing the
first line and then assuming that every line ends with a newline, we
remember how each line ends and emit that either at the beginning of
the next line or at the end of the file except in the one case ('+')
where the standard explicitly says not to.

While here, try to reduce diff to upstream a little and update their
RCS tag to reflect the fact that while we've diverged significantly
from them, we've incorporated all their changes.  Remove the useless
second RCS tag.

We also update the tests to account for the change in interpretation
of the '1' case and add a test case for unterminated input.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D43326

(cherry picked from commit c2356a440d)
2024-01-17 17:16:00 +01:00
Dag-Erling Smørgrav 282a377c09 find: Add a warning about -delete.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	pauamma_gundo.com
Differential Revision:	https://reviews.freebsd.org/D43162

(cherry picked from commit 45438f9c8b)
2024-01-17 17:16:00 +01:00
Dag-Erling Smørgrav 127f4dd60b gzip: Add support for decompressing zstd files.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37236

(cherry picked from commit f9349d4274)
2024-01-17 16:52:31 +01:00
Tom Jones 80e3a8b5c6 Remove SMALL conditionals from gzip
gzip has SMALL conditionals which enable building a reduced size version
of the binary. These exist as part of the introduction of BSD licensed
gzip in 2004 in NetBSD and appear to have been required to reach a size
for inclusion in their install media. For more information see commits
to gzip in the NetBSD tree on the 28th of March 2004.

SMALL doesn't appear to be hooked up to our build system and
complicates gzip quite a bit.

Reviewed by:	kevans,	imp
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D34047

(cherry picked from commit 4669f23ef7)
2024-01-17 16:52:02 +01:00
Tom Jones ab215565c8 Fix test output when gzip is run with -tlv
When run with test, verbose and list we need to parse the file otherwise
the test output is "NOT OK" even for the file is valid.

Reviewed by:	kevans, allanjude, imp
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D34046

(cherry picked from commit 21c966a6b9)
2024-01-17 16:52:02 +01:00
Wolfram Schneider 03bff02e81 Revert "fix using man(1) with multiple pages"
This reverts commit 79e7fef944.

man.sh on stable/13 is missing some new features.
Unfortunately this means that this fix is not working as on stable/14.
Be patient and wait until the following 2 commits are ready to merge.
2024-01-15 19:05:08 +00:00
Wolfram Schneider 79e7fef944 fix using man(1) with multiple pages
PR: 275978
Reported by: Mohamed Akram
Fixes: 789480702e
MFC after: 1 week

(cherry picked from commit 1e82d882ed)
2024-01-15 07:36:59 +00:00
Ceri Davies 677a7402ce sys/*/conf/*, docs: fix links to handbook
While here, fix all links to older en_US.ISO8859-1 documentation
in the src/ tree.

PR:             255026
Reported by:    Michael Büker <freebsd@michael-bueker.de>
Reviewed by:    dbaio
Differential Revision: https://reviews.freebsd.org/D30265

(cherry picked from commit c1a148873d)
2024-01-09 22:07:46 -05:00
Dimitry Andric 0e1e0ce556 Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the
last commit before the upstream release/17.x branch was created.

PR:		273753
MFC after:	1 month

(cherry picked from commit 06c3fb2749)
2024-01-08 00:04:38 +01:00
Andrew Turner 29d1d72ad5 llvm: Reduce overlinking with the minimal llvm
We only need to link against libz and libzstd when linking against the
fill libllvm, libllvmminimal doesn't use either library. Move adding
libz and libzstd to the list of libraries to link against to where
we decide to use the full libllvm.

Reported by:	Cristian Marussi <Cristian.Marussi@arm.com>
Reported by:	Colin S. Gordon <csgordon@fastmail.com>
Reviewed by:	dim
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D42528

(cherry picked from commit 83771b1914)
2024-01-08 00:04:33 +01:00
Gordon Bergling 23e9ada5ef tail(1): Fix a typo in a source code comment
- s/recieved/received/

(cherry picked from commit c58205be7a)
2024-01-07 12:43:18 +01:00
Wolfram Schneider 5e78db7b45 support spaces in filenames
PR:		275978
MFC after:	1 week

(cherry picked from commit 789480702e)
2024-01-05 08:21:29 +00:00
Wolfram Schneider 05daf91798 improve handling of shell metacharacters in filenames
PR:		275967
MFC after:	1 week

(cherry picked from commit c4368d03e5)
2024-01-05 08:19:10 +00:00
Kyle Evans ee0e6ac147 kdump: use print_mask_arg0 appropriately
Some callers are using print_mask_arg() when they should be using
print_mask_arg0(); the latter should be used when all flags are optional
and there's not a flag to be decoded with a 0-mask.  This turns:

nmount(0x6991e009000,0x8,0<><invalid>0)

into:

nmount(0x6991e009000,0x8,0)

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D43007

(cherry picked from commit a206524709)
2024-01-02 22:47:27 -06:00
Christos Margiolis eefdc4a348 fortune: update mailing list search url
Markmail no longer exists.

Reviewed by:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D43209

(cherry picked from commit 2b1c477d88)
2023-12-31 15:47:37 +02:00
Kyle Evans feafc7d0bc lockf: switch to strtonum() for parsing timeout
Convert waitsec to a long long to be able to hold the full domain of
alarm(3) timeout on all platforms, and let strtonum(3) handle the input
validation.  strtonum(3) also happens to provide a neater interface for
error handling, and it already includes our pre-existing empty input
check.

Sponsored by:	Klara, Inc.

(cherry picked from commit e4967d4d48)
2023-12-14 18:59:27 -06:00
Kyle Evans 663424957d lockf: allow locking file descriptors
This is most useful inside a shell script, allowing one to lock just
portions of a script rather than having to wrap the entire script in a
lock.

PR:		262738
Reviewed by:	0mp, allanjude (both previous versions)
Co-authored-by:	Daniel O'Connor <darius@dons.net.au>
Sponsored by:	Klara, Inc.

(cherry picked from commit 09a7fe0a55)
2023-12-14 18:59:25 -06:00
Kyle Evans fbd1d0bdff lockf: add some tests
Provide basic coverage for the existing options, nothing deeper (e.g.,
pipe closing behavior) is tested in this set.

Reviewed by:	allanjude
Feedback from:	des
Sponsored by:	Klara, Inc.

(cherry picked from commit 296a5a4db1)
2023-12-14 18:59:21 -06:00
Alexander Melkov 159d922f4c lockf: don't hold stdin/stdout/stderr open
None of these are essential in the lockf monitor (parent post-fork), so
close them to maintain the illusion that lockf hasn't been inserted into
the pipeline.  This ensures that the correct effects happen on other
programs in the pipeline if the locked command closes or redirects these
elsewhere.

The original patch used -s to close stdout/stderr rather than closing
them unconditionally, but it's not clear that we really care that much.
kevans dropped that part when taking the patch, patch is otherwise by
listed author.

PR:		112379
Reviewed by:	0mp, allanjude (both earlier version), kevans
Feedback from:	des
Sponsored by:	Klara, Inc.

(cherry picked from commit 18425c19ca)
2023-12-14 18:59:18 -06:00
Kyle Evans 8f5c280463 lockf: hide unavailable error with -n -s
The error message is expected, allow -s to suppress just that one since
it would loosely fall under the definition of "failure to acquire the
lock" described in the manpage for the -s option.

Reviewed by:	0mp, allanjude
Feedback from:	des
Sponsored by:	Klara, Inc.

(cherry picked from commit 3041e6950d)
2023-12-14 18:59:15 -06:00
Kyle Evans aa9ad4d484 lockf: correct omission in the usage statement
The -w flag was added without being noted in the usage statement; fix
that now.

While we're here, re-sort the getopt() string.

Reviewed by:	0mp, allanjude, des
Sponsored by:	Klara, Inc.

(cherry picked from commit 35095fd23f)
2023-12-14 18:59:12 -06:00
Kyle Evans 73f87b9725 localedef: add newlines to error messages
These won't be added elsewhere, so add a little bit of room to make
these messages a little easier to read.  The existing set is a mixed
bag, there are somewhere in the ballpark of 45, 46 printfs to stderr and
19 of those had newlines.

Reviewed by:	yuripv
Sponsored by:	Klara, Inc.

(cherry picked from commit 3141e51d2e)
2023-12-14 18:59:05 -06:00
Kyle Evans 03fe51fb88 localedef: expand the default charmap
POSIX defines a number of other control characters as well as
alternative aliases for some that should be provided in the default set,
so let's go ahead and add those.

Reviewed by:	bapt, yuripv
Sponsored by:	Klara, Inc.

(cherry picked from commit 3a7ffe206c)
2023-12-14 18:59:01 -06:00
Kyle Evans 6bfba60974 localedef: correct definition of right-parenthesis in default charmap
It turns out that right parentheses do exist and are different than
left parentheses, so let's switch to that.

Sponsored by:	Klara, Inc.

(cherry picked from commit 07bc20e474)
2023-12-14 18:58:54 -06:00
Warner Losh 4c45ab6ac8 sort: Only build FreeBSD-specific ALTMON_x stuff when ATLMON_1 is defined
On MacOS, we bootstrap sort. Since ALTMON_* are not defined there, the
build blows up. Since we don't need this feature for the FreeBSD build
process, and since we won't use it unless we actually install the NL
files that have this data in it, just #ifdef it out for now. In the
extremely unlikely event that the FreeBSD bootstrap/build process grows
this dependency, we can evaluate the best solution then (which most
likely is going to be not depend on the local's month names).

Fixes:			3d44dce90a (MacOS builds and github CI)
Sponsored by:		Netflix
Reviewed by:		jrtc27, jlduran@gmail.com, markj
Differential Revision:	https://reviews.freebsd.org/D42868

(cherry picked from commit bd234c0d4c)
2023-12-15 02:41:05 +02:00
Christos Margiolis e1028df36d sort: test against all month formats in month-sort
The CLDR specification [1] defines three possible month formats:

- Abbreviation (e.g Jan, Ιαν)
- Full (e.g January, Ιανουαρίου)
- Standalone (e.g January, Ιανουάριος)

Many languages use different case endings depending on whether the month
is referenced as a standalone word (nominative case), or in date context
(genitive, partitive, etc.). sort(1)'s -M option currently sorts months
by testing input against only the abbrevation format, which is
essentially a substring of the full format. While this works fine for
languages like English, where there are no cases, for languages where
there is a different case ending between the abbreviation/full and
standalone formats, it is not sufficient.

For example, in Greek, "May" can take the following forms:

Abbreviation: Μαΐ (genitive case)
Full: Μαΐου (genitive case)
Standalone: Μάιος (nominative case)

If we use the standalone format in Greek, sort(1) will not able to match
"Μαΐ" to "Μάιος" and the sort will fail.

This change makes sort(1) test against all three formats. It also works
when the input contains mixed formats.

[1] https://cldr.unicode.org/translation/date-time/date-time-patterns

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D42847

(cherry picked from commit 3d44dce90a)
2023-12-15 02:40:14 +02:00
Kenneth D. Merry 9e6e28bb8e Add IBM TS1170 density codes and specs.
These were obtained from a drive, but they agree with the IBM
documentation.

The bpi/bpmm values are the same as TS1160, but the number of
tracks is much larger (18944 tracks vs 8704 for TS1160).  The tapes
are also longer, 1337m total.  (According to the MAM on a sample JF
tape.  I don't have a JE tape handy to compare.)  The end result
is a 50TB raw capacity (150TB compressed) for TS1170 with a JF
cartridge vs 20TB raw capacity (60TB compressed) for TS1160 with
a JE cartridge.

lib/libmt/mtlib.c:
	Add the TS1170 density codes to the denstiy table in libmt.

usr.bin/mt/mt.1:
	Add the TS1170 density codes and specs to the density table
	in the mt(1) man page.  As usual for TS drives, there is an
	encrypted and non-encrypted density code (0x79 and 0x59
	respectively).

Sponsored by:	Spectra Logic

(cherry picked from commit 83823d063a)
2023-12-14 16:00:54 -05:00
Dag-Erling Smørgrav 817f2d83bd tail: Fix heap overflow in -F case.
The number of events we track can vary over time, but we only allocate
enough space for the exact number of events we are tracking when we
first begin, resulting in a trivially reproducable heap overflow.  Fix
this by allocating enough space for the greatest possible number of
events (two per file) and clean up the code a bit.

Also add a test case which triggers the aforementioned heap overflow,
although we don't currently have a way to detect it.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D42839

(cherry picked from commit 621f45532c)

tail: Clean up error messages.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D42842

(cherry picked from commit b70e57be2c)
2023-12-13 17:39:38 +01:00
Mateusz Piotrowski ed64bde3c5 tail.1: Lint with mandoc(1)
MFC after:	3 days
Sponsored by:	Klara, Inc.

(cherry picked from commit 51c27021b2)
2023-12-13 17:39:38 +01:00
Dag-Erling Smørgrav 58073ccbe3 tail: Verify correct behavior when input does not end in a newline.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D39116

(cherry picked from commit fa3af3ce50)
2023-12-13 17:39:38 +01:00
Warner Losh 3109a31bf2 tail: Retry kevent if the system call was interrupted
kevent returns EINTR when I suspend / resume. This causes tail -f
and tail -F to exit with interrupt system call. Ignore this error
and try kevent again.

Sponsored by:		Netflix

(cherry picked from commit ef6f20ce47)
2023-12-13 17:39:38 +01:00
Xin LI 585762c373 Improve usability of head(1) and tail(1):
- Consistently support -q (quiet) and -v (verbose)
 - Allow specifying numbers with SI prefixes supported by expand_number(3)
 - Remove 2^31 limit on lines for head(1)

MFC after:		2 weeks
Reviewed by:		lwhsu, pauamma, gbe
Relnotes:		yes
Differential Revision: https://reviews.freebsd.org/D35720

(cherry picked from commit 643ac419fa)
2023-12-13 17:39:38 +01:00
Dag-Erling Smørgrav dc7d88c71d libfetch, fetch: Stop recommending the use of ca_root_nss.
MFC after:	3 days
Reviewed by:	kevans, emaste
Differential Revision:	https://reviews.freebsd.org/D42119

(cherry picked from commit 2821a7498f)
2023-12-13 17:21:29 +01:00
Maxim Sobolev 4d4b3a3426 vmstat: fix column names broken in c168508655
Loss of the trailing space in the multi-line format string has
resulted in column name being emitted as "FAILSLEEP", instead of
two columns "FAIL" and "SLEEP".

(cherry picked from commit 62d47a4db4)
2023-12-04 17:48:21 -08:00
Baptiste Daroussin ef922c733a nvi: import version 2.2.1
(cherry picked from commit 0fcececbac)
2023-12-04 11:34:07 +01:00
Mateusz Piotrowski 29cdffb68a tail.1: Add an example for +n 1
MFC after:	3 days
Sponsored by:	Klara, Inc.

(cherry picked from commit 9f20787fe8)
2023-12-01 12:20:25 +01:00
Kyle Evans 9c170b3d52 grep: don't rely on implementation-defined malloc(0) behavior
The very few places that rely on malloc/calloc of a zero-size region
won't attempt to dereference it, so just return NULL rather than rolling
the dice with the underlying malloc implementation.

Reported by:	brooks, Shawn Webb

(cherry picked from commit e116e040f3)
2023-11-25 22:07:17 -06:00
Kyle Evans 2c7e964254 install: handle -m +X more accurately
As described by chmod(1), +X in the mode may be used to optionally set
the +x bit if the file is a directory if any of the execute/search bits
are set in the original mode.  The latter is not applicable because we
assume -m is a fresh mask, but a functional +X could be useful in the
former case if we're passing along a common INSTALL_MODE that's designed
to install either 0644 or 0755 depending simply on whether it's a
directory or not.

Reviewed by:	des
Sponsored by:	Klara, Inc.

(cherry picked from commit 767c97c501)
2023-11-25 22:07:17 -06:00
Kristof Provost 0a97a28c6c netstat: fix missing tab in icmp6 output
PR:		275044
Submitted by:	sigsys@gmail.com
Reviewed by:	kp
MFC after:	1 week

(cherry picked from commit 4b5634f4e5)
2023-11-19 20:29:44 +01:00
John Baldwin de270f81b2 Purge more stray embedded $FreeBSD$ strings
These do not use __FBSDID but instead use bare char arrays.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41957

(cherry picked from commit eba230afba)
2023-10-24 11:13:18 -07:00
John Baldwin 7a5518ed1a factor: Remove an empty #ifdef __FBSDID clause
(cherry picked from commit f2f73fa7bd)
2023-10-24 11:13:18 -07:00
Dag-Erling Smørgrav db95aeb922 split: Further option parsing improvements.
* Whenever possible, use strtonum() to parse numeric arguments.
* Improve usefulness and consistency of error messages.
* While here, fix some type and style issues.

Sponsored by:	Klara, Inc.
Reviewed by:	christos, kevans
Differential Revision:	https://reviews.freebsd.org/D42010

(cherry picked from commit d7399551b0)

split: Improve GNU compatibility.

* Like GNU split, turn autoextend back on if given -a0.
* Add a test case that verifies that -a<non-zero> turns autoextend off.
* Add a test case that verifies that -a0 turns autoextend back on.

Sponsored by:	Klara, Inc.
Reviewed by:	christos, kevans
Differential Revision:	https://reviews.freebsd.org/D42011

(cherry picked from commit d9d69a6f6f)
2023-10-05 17:55:30 +02:00
Mateusz Piotrowski db91ad3642 manpages: Fix use of At macro
The versions for the At macro from 1 to 7 must be prefixed with "v".

MFC after:	3 days

(cherry picked from commit 8b73b57c1b)
2023-10-04 13:18:49 +02:00
Warner Losh 5d26c78b50 basename: fix history
Basename(1) first appeared in the 7th edition. It was not in the 6th
edition, or PWB releases. It's on all the subsequent descendants.

Dirname(1) first appeared in System III, and was later picked up in
4.3-Reno and 8th edition research unix (though was not in 4.1BSD where
the bulk of 8th edition came from). In System III and V8 it was a shell
script, though the BSD version is in C.

Sponsored by:		Netflix

(cherry picked from commit f394c73666)
2023-10-04 13:18:39 +02:00
Warner Losh 41d03ea794 banner: Correct history.
Banner appeared in the 6th edition of AT&T Research unit. It was
subsequently on all the Berkeley tapes, as well as PWB, System III and
System V. The PWB/AT&T and BSD banner programs were different, and the
current FreeBSD banner program shares many elements of the 3BSD one,
though the font has changed.

Sponsored by:		Netflix

(cherry picked from commit b77e235dd5)
2023-10-04 13:17:44 +02:00
Mateusz Piotrowski 237ce4092c vtfontcvt(8): Update usage() to match vtfontcvt.8
MFC after:	2 weeks

(cherry picked from commit ef2d0816dd)
2023-10-04 13:14:18 +02:00
Mateusz Piotrowski f787c870f6 vtfontcvt.8: Use D1 instead of Ql for readability
MFC after:	2 weeks

(cherry picked from commit cad64622ca)
2023-10-04 13:14:14 +02:00
Mateusz Piotrowski c0141df5f4 vtfontcvt.8: Sort synopsis
MFC after:	2 weeks

(cherry picked from commit e0bd2ab2eb)
2023-10-04 13:14:10 +02:00
Mateusz Piotrowski 24319ec19e vtfontcvt.8: Improve synopsis and -f documentation
MFC after:	2 weeks

(cherry picked from commit b38e3722f5)
2023-10-04 13:14:05 +02:00
Wolfram Schneider d03af6473e switch groff parameter -man to -mandoc for new groff release 1.23.0
PR: 273565

(cherry picked from commit cd89fe3923)
2023-09-25 17:31:50 +00:00