I think this was probably just a typo. initifstat() continues around
a similar loop if the mib data fails to fetch, and fetch_ifstat() was
already using a FOREACH_SAFE loop here so expected to keep going.
Calling clearifstat() from the fetch routine also seems wrong, and the
sort_interface_list() call triggered by the existing needsort = 1 will
itself set needclear to trigger a future clearifstat().
Reported by: GCC 12 -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36823
A small reduction in build infrastructure complexity; when we had both
Clang and GCC in the tree it was useful to have both built, and choose
one or the other to install as /usr/bin/cc. Now only Clang is in the
tree, and there is no point in building and installing base Clang but
not providing it as cc (and c++, cpp).
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37075
Previously the tests just verified if command line arguments raised an
error or not, they did not test how command line arguments affected
the output. This adds some sample (if simple) input and output to
each flag test as well as adding a few additional trivial tests.
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36835
This uses the "::" extension to getopt() to handle options which take
an optional argument.
The updated flag tests were all wrong before and only passed because
the manual parser failed to raise errors when a required argument was
missing. The invalid argument test now gets a better error message.
Reviewed by: brooks, imp, emaste
Differential Revision: https://reviews.freebsd.org/D36834
This also updates various indices and counters from int to size_t to
pacify resulting -Wsign-compare warnings.
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36833
Previously print_header() used sprintf() of a buffer to itself as a
kind of string builder but without checking for overflows. This
raised -Wformat-truncation and -Wrestrict warnings in GCC. Instead,
just conditionally print the new timestamp fields after the initial
strftime()-formatted string. While here, use sizeof(buf) with
strftime() rather than a magic number.
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D36814
The implicit fall-through in the !D_FORCEASCII case caused null
characters to be treated as carriage returns honoring the D_STRIPCR,
D_FOLDBLANKS, and D_IGNOREBLANKS flags.
Reported by: GCC -Wimplicit-fallthrough
Reviewed by: bapt
Fixes: 3cbf98e2be diff: read whole files to determine if they are ASCII text
Differential Revision: https://reviews.freebsd.org/D36813
Have tcpstats (netstat -s) differentiate between received and sent
ECN-marked packets. Also account for IP ECN bits (on TCP packets)
even when the tcp session has not negotiated ECN support.
Event: IETF 115 Hackathon
Reviewed By: glebius, tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D37314
We already did the necessary $TMPDIR fallback, if it's going to be used.
Skip the later check so that we don't accidentally override our -p
argument.
Fixes: ac6f924e1c ("mktemp: add -p/--tmpdir argument")
Sponsored by: Klara, Inc.
In an e-mail Brian Walden wrote that:
"GWRL stands for Gottfried W. R. Luderer, the author of cut(1) and
paste(1), probably around 1978. Those came either from PWB or USG,
as he worked with, or for, Berkley Tague. Thus they made their way
into AT&T commercial UNIX, first into System III and the into System
V, and that's why they are missing from early BSD releases as they
didn't get into Research UNIX until the 8th Edition."
So update the HISTORY and AUTHORS sections for cut(1) and paste(1).
[1] https://minnie.tuhs.org/pipermail/tuhs/2020-January/019955.html
Reviewed by: pauamma, imp
Obtained from: OpenBSD (in partial)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36048
This is a minor cosmetic change; re-organize slightly to set tmpdir to
_PATH_TMP if we didn't otherwise have a tmpdir candidate, then check the
trailing char before appending another slash.
While we're here, remove some bogus whitespace and add a test case for
this change.
Obtained from: https://github.com/apple-oss-distributions/shell_cmds
Sponsored by: Klara, Inc.
This matches other mktemp implementations, including OpenBSD and GNU.
The -p option can be used to provide a tmpdir prefix for specified
templates. Precedence works out like so:
-t flag:
- $TMPDIR
- -p directory
- /tmp
Implied -t flag (no arguments or only -d flag):
- -p directory
- $TMPDIR
- /tmp
Some tests have been added for mktemp(1) in the process.
Reviewed by: imp (earlier version), wosch
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37121
GNU maketemp has long options for -d, -q, and -u, so let's add these
now for compatibility.
Reviewed by: emaste, imp, wosch
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37120
The most accurate information I have found is that
tee(1) first appeared in Version 7 AT&T UNIX.
Reviewed by: pauamma
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37206
Something else may have set errno, breaking the post-getline() logic
that tries to detect the getline() error. This was initially noted in
a jail on a system that has HPET, in a jail that does not expose
/dev/hpet0 -- we see an earlier error in libc's vdso bits.
Fixes: 5c053aa3c5 ("split: switch to getline() [...]")
If the system has been up more longer than a minute, we add 30 seconds to
the uptime so that subsequent calculations will round to the nearest minute
rather than truncate. However, since the introduction of libxo, we output
the raw value after performing the adjustment. Rewrite so that we output
the raw value first, then perform the adjustment and recalculate before
outputting the humanized value.
While there, reduce stack usage and avoid needless allocations.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37128
This was meant to note that both pattern and line matching were
previously restricted, but words are difficult. +line and rearrange.
Sponsored by: Klara, Inc.
This should cover all of the basic functionality, as well as the recent
enhancement to use a dynamic buffer size rather than limiting patterns
and lines to MAXBSIZE.
Reviewed by: bapt
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D36324
Get rid of split's home-grown logic for growing the buffer; arbitrarily
breaking at LONG_MAX bytes instead of 65536 bytes gives us much more
wiggle room. Additionally, we'll actually fail out entirely if we can't
fit a line, which makes noticing this class of problem much easier.
Reviewed by: bapt, emaste, pauamma
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D36323
currently when xargs runs in parallel mode (e.g. -P2), it somtimes
incorrectly returns zero exit code. this commit fix it and also adds
tests.
Reviewed by: mjg
PR: 267110
If the root account is configured to use a different shell than sh,
it fails to retreive the pid of the background process.
Approved by: des
Obtained from: chs
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36930
Previously the code to read from a local file or stdin was sperarated
After the change to remove the home made line reader used for stdin
(replaced by getdelim) it apprears that the rest of the code which is
used to read from any FILE * but stdin can benefit from the exact same
change.