aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/awk/awk.1136
-rw-r--r--usr.bin/gh-bc/Makefile6
-rw-r--r--usr.bin/gh-bc/tests/Makefile9
-rw-r--r--usr.bin/man/man.124
-rwxr-xr-xusr.bin/man/man.sh35
-rw-r--r--usr.bin/mandoc/Makefile2
-rw-r--r--usr.bin/netstat/inet.c13
-rw-r--r--usr.bin/netstat/sctp.c8
-rwxr-xr-xusr.bin/patch/tests/unified_patch_test.sh18
-rw-r--r--usr.bin/sockstat/main.c3
-rw-r--r--usr.bin/w/pr_time.c26
-rw-r--r--usr.bin/w/uptime.118
-rw-r--r--usr.bin/w/w.14
13 files changed, 256 insertions, 46 deletions
diff --git a/usr.bin/awk/awk.1 b/usr.bin/awk/awk.1
index 65c91738966b..612669629a02 100644
--- a/usr.bin/awk/awk.1
+++ b/usr.bin/awk/awk.1
@@ -21,7 +21,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
.\" THIS SOFTWARE.
-.Dd July 30, 2021
+.Dd September 3, 2025
.Dt AWK 1
.Os
.Sh NAME
@@ -32,7 +32,7 @@
.Op Fl safe
.Op Fl version
.Op Fl d Ns Op Ar n
-.Op Fl F Ar fs
+.Op Fl F Ar fs | Fl -csv
.Op Fl v Ar var Ns = Ns Ar value
.Op Ar prog | Fl f Ar progfile
.Ar
@@ -42,9 +42,11 @@ scans each input
.Ar file
for lines that match any of a set of patterns specified literally in
.Ar prog
-or in one or more files specified as
+or in one or more files
+specified as
.Fl f Ar progfile .
-With each pattern there can be an associated action that will be performed
+With each pattern
+there can be an associated action that will be performed
when a line of a
.Ar file
matches the pattern.
@@ -76,6 +78,11 @@ to dump core on fatal errors.
.It Fl F Ar fs
Define the input field separator to be the regular expression
.Ar fs .
+.It Fl -csv
+causes
+.Nm
+to process records using (more or less) standard comma-separated values
+(CSV) format.
.It Fl f Ar progfile
Read program code from the specified file
.Ar progfile
@@ -178,7 +185,7 @@ as the field separator, use the
option with a value of
.Sq [t] .
.Pp
-A pattern-action statement has the form
+A pattern-action statement has the form:
.Pp
.D1 Ar pattern Ic \&{ Ar action Ic \&}
.Pp
@@ -347,7 +354,7 @@ in a pattern.
A pattern may consist of two patterns separated by a comma;
in this case, the action is performed for all lines
from an occurrence of the first pattern
-through an occurrence of the second.
+through an occurrence of the second, inclusive.
.Pp
A relational expression is one of the following:
.Pp
@@ -363,7 +370,8 @@ A relational expression is one of the following:
.Pp
where a
.Ar relop
-is any of the six relational operators in C, and a
+is any of the six relational operators in C,
+and a
.Ar matchop
is either
.Ic ~
@@ -386,6 +394,9 @@ and after the last.
and
.Ic END
do not combine with other patterns.
+They may appear multiple times in a program and execute
+in the order they are read by
+.Nm
.Pp
Variable names with special meanings:
.Pp
@@ -428,6 +439,11 @@ The length of the string matched by the
function.
.It Va RS
Input record separator (default newline).
+If empty, blank lines separate records.
+If more than one character long,
+.Va RS
+is treated as a regular expression, and records are
+separated by text matching the expression.
.It Va RSTART
The starting position of the string matched by the
.Fn match
@@ -515,7 +531,8 @@ occurs, or 0 if it does not.
The length of
.Fa s
taken as a string,
-or of
+number of elements in an array for an array argument,
+or length of
.Va $0
if no argument is given.
.It Fn match s r
@@ -696,10 +713,44 @@ records from
.Ar file
remains open until explicitly closed with a call to
.Fn close .
+.It Fn systime
+returns the current date and time as a standard
+.Dq seconds since the epoch
+value.
+.It Fn strftime fmt timestamp
+formats
+.Fa timestamp
+(a value in seconds since the epoch)
+according to
+Fa fmt ,
+which is a format string as supported by
+.Xr strftime 3 .
+Both
+.Fa timestamp
+and
+.Fa fmt
+may be omitted; if no
+.Fa timestamp ,
+the current time of day is used, and if no
+.Fa fmt ,
+a default format of
+.Dq %a %b %e %H:%M:%S %Z %Y
+is used.
.It Fn system cmd
Executes
.Fa cmd
and returns its exit status.
+This will be -1 upon error,
+.Fa cmd 's
+exit status upon a normal exit,
+256 +
+.Va sig
+upon death-by-signal, where
+.Va sig
+is the number of the murdering signal,
+or 512 +
+.Va sig
+if there was a core dump.
.El
.Ss Bit-Operation Functions
.Bl -tag -width "lshift(a, b)"
@@ -725,6 +776,16 @@ Returns integer argument x shifted by n bits to the right.
But note that the
.Ic exit
expression can modify the exit status.
+.Sh ENVIRONMENT VARIABLES
+If
+.Va POSIXLY_CORRECT
+is set in the environment, then
+.Nm
+follows the POSIX rules for
+.Fn sub
+and
+.Fn gsub
+with respect to consecutive backslashes and ampersands.
.Sh EXAMPLES
Print lines longer than 72 characters:
.Pp
@@ -734,7 +795,7 @@ Print first two fields in opposite order:
.Pp
.Dl { print $2, $1 }
.Pp
-Same, with input fields separated by comma and/or blanks and tabs:
+Same, with input fields separated by comma and/or spaces and tabs:
.Bd -literal -offset indent
BEGIN { FS = ",[ \et]*|[ \et]+" }
{ print $2, $1 }
@@ -810,6 +871,63 @@ to it.
.Pp
The scope rules for variables in functions are a botch;
the syntax is worse.
+.Pp
+Input is expected to be UTF-8 encoded.
+Other multibyte character sets are not handled.
+However, in eight-bit locales,
+.Nm
+treats each input byte as a separate character.
+.Sh UNUSUAL FLOATING-POINT VALUES
+.Nm
+was designed before IEEE 754 arithmetic defined Not-A-Number (NaN)
+and Infinity values, which are supported by all modern floating-point
+hardware.
+.Pp
+Because
+.Nm
+uses
+.Xr strtod 3
+and
+.Xr atof 3
+to convert string values to double-precision floating-point values,
+modern C libraries also convert strings starting with
+.Va inf
+and
+.Va nan
+into infinity and NaN values respectively.
+This led to strange results,
+with something like this:
+.Bd -literal -offset indent
+echo nancy | awk '{ print $1 + 0 }'
+.Ed
+.Pp
+printing
+.Dq nan
+instead of zero.
+.Pp
+.Nm
+now follows GNU AWK, and prefilters string values before attempting
+to convert them to numbers, as follows:
+.Bl -tag -width "Hexadecimal values"
+.It Hexadecimal values
+Hexadecimal values (allowed since C99) convert to zero, as they did
+prior to C99.
+.It NaN values
+The two strings
+.Dq +nan
+and
+.Dq -nan
+(case independent) convert to NaN.
+No others do.
+(NaNs can have signs.)
+.It Infinity values
+The two strings
+.Dq +inf
+and
+.Dq -inf
+(case independent) convert to positive and negative infinity, respectively.
+No others do.
+.El
.Sh DEPRECATED BEHAVIOR
One True Awk has accepted
.Fl F Ar t
diff --git a/usr.bin/gh-bc/Makefile b/usr.bin/gh-bc/Makefile
index 0fdc687c0e50..9aa5116f6faa 100644
--- a/usr.bin/gh-bc/Makefile
+++ b/usr.bin/gh-bc/Makefile
@@ -4,6 +4,7 @@ PROG= gh-bc
PROGNAME= bc
BCDIR= ${SRCTOP}/contrib/${PROGNAME}
+VERSION!= cat ${SRCTOP}/contrib/${PROGNAME}/VERSION.txt
SRCS= args.c bc.c bc_lex.c bc_parse.c data.c dc.c dc_lex.c dc_parse.c file.c history.c
SRCS+= lang.c lex.c main.c num.c opt.c parse.c program.c rand.c read.c vector.c vm.c
@@ -31,6 +32,8 @@ CATALOGS+= zh_CN.UTF-8 zh_CN.eucCN zh_CN.GB18030 zh_CN.GB2312 zh_CN.GBK
NLSNAME= bc
NLSSRCDIR= ${BCDIR}/locales
+CFLAGS+= -I${BCDIR}/include
+
CFLAGS+= -DBC_DEFAULT_BANNER=0
CFLAGS+= -DBC_DEFAULT_DIGIT_CLAMP=0
CFLAGS+= -DBC_DEFAULT_EXPR_EXIT=1
@@ -57,7 +60,8 @@ CFLAGS+= -DBUILD_TYPE=A
CFLAGS+= -DMAINEXEC=${PROGNAME}
CFLAGS+= -DNDEBUG
CFLAGS+= -DNLSPATH=/usr/share/nls/%L/%N.cat
-CFLAGS+= -I${BCDIR}/include
+
+CFLAGS+= -DVERSION=${VERSION}
# prevent floating point incompatibilities caused by -flto on some architectures
.if ${MACHINE_ARCH} != riscv64
diff --git a/usr.bin/gh-bc/tests/Makefile b/usr.bin/gh-bc/tests/Makefile
index 464ae4b5d3c3..f2c92aecb0a5 100644
--- a/usr.bin/gh-bc/tests/Makefile
+++ b/usr.bin/gh-bc/tests/Makefile
@@ -17,7 +17,8 @@ FILESfMODE= 0755
FILESGROUPS+= FILEStests
FILEStestsPACKAGE= ${PACKAGE}
FILEStestsDIR= ${TESTSDIR}/tests
-FILEStests!= echo ${TEST_DIR}/tests/*.py ${TEST_DIR}/tests/*.sh ${TEST_DIR}/tests/*.txt
+FILEStests!= echo ${TEST_DIR}/tests/*.py ${TEST_DIR}/tests/*.sed \
+ ${TEST_DIR}/tests/*.sh ${TEST_DIR}/tests/*.txt
FILEStestsMODE= 0755
FILESGROUPS+= FILESbc
@@ -56,10 +57,12 @@ PLAIN_TESTS_SH= bc_tests dc_tests
bc_tests.sh:
echo "#!/bin/sh" > ${.TARGET}
- echo "env LANG=C ${TESTSDIR}/tests/all.sh bc 1 1 0 0 0 bc" >> ${.TARGET}
+ echo 'env LANG=C BC_TEST_OUTPUT_DIR=$$(pwd) \
+ ${TESTSDIR}/tests/all.sh -n bc 1 1 0 0 bc' >> ${.TARGET}
dc_tests.sh:
echo "#!/bin/sh" > ${.TARGET}
- echo "env LANG=C ${TESTSDIR}/tests/all.sh dc 1 1 0 0 0 dc" >> ${.TARGET}
+ echo "env LANG=C BC_TEST_OUTPUT_DIR=\$pwd \
+ ${TESTSDIR}/tests/all.sh -n dc 1 1 0 0 dc" >> ${.TARGET}
.include <bsd.test.mk>
diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1
index 820d6a5b33a9..707677ccce06 100644
--- a/usr.bin/man/man.1
+++ b/usr.bin/man/man.1
@@ -33,7 +33,7 @@
.Nd display online manual documentation pages
.Sh SYNOPSIS
.Nm
-.Op Fl adho
+.Op Fl adhlo
.Op Fl t | w
.Op Fl M Ar manpath
.Op Fl P Ar pager
@@ -144,6 +144,15 @@ Search names and descriptions of all manual pages for an extended regular
.Ar expression ,
emulating basic functionality of
.Xr apropos 1 .
+.It Fl l
+Interpret all arguments as absolute or relative filename(s)
+of the manual page(s) to display.
+No search is done and the options
+.Fl M ,
+.Fl m ,
+and
+.Fl S
+are ignored.
.It Fl m Ar arch Ns Op : Ns Ar machine
Override the default architecture and machine settings allowing lookup of
other platform specific manual pages.
@@ -269,12 +278,15 @@ will search the following paths when considering section 4 manual pages in
.Pa /usr/share/man/man4
.El
.Ss Displaying Specific Manual Files
-The
+For compatibility reasons,
.Nm
-utility also supports displaying a specific manual page if passed a path
-to the file as long as it contains a
+will interpret any argument containing at least one
.Ql /
-character.
+character as an absolute or relative path to a manual page to be
+displayed.
+This heuristic, made redundant by the more widely supported
+.Fl l
+option, is now deprecated and may be removed in future releases.
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm :
@@ -398,7 +410,7 @@ manual page:
.Pp
Show a manual page in the current working directory:
.Pp
-.Dl $ man ./man.1
+.Dl $ man -l man.1
.Pp
Show the location of manual pages in sections 1 and 8 which contain the word
.Ql arm :
diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index 18595042da5f..920223ce3c27 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -511,13 +511,21 @@ man_display_page_groff() {
# Usage: man_find_and_display page
# Search through the manpaths looking for the given page.
man_find_and_display() {
- local found_page locpath p path sect
+ local found_page has_slash locpath p path sect
# Check to see if it's a file. But only if it has a '/' in
- # the filename.
+ # the filename or if -l was specified.
case "$1" in
- */*) if [ -f "$1" -a -r "$1" ]; then
+ */*) has_slash=yes
+ ;;
+ esac
+ if [ -n "$has_slash" -o -n "$lflag" ]; then
+ if [ -f "$1" -a -r "$1" ]; then
decho "Found a usable page, displaying that"
+ if [ -z "$lflag" ]; then
+ echo "Opening a file directly is deprecated," \
+ "use -l instead." >&2
+ fi
unset use_cat
manpage="$1"
setup_cattool "$manpage"
@@ -531,9 +539,12 @@ man_find_and_display() {
man_display_page
fi
return
+ elif [ -n "$lflag" ]; then
+ echo "Cannot read $1" >&2
+ ret=1
+ return
fi
- ;;
- esac
+ fi
IFS=:
for sect in $MANSECT; do
@@ -601,7 +612,7 @@ man_parse_opts() {
local cmd_arg
OPTIND=1
- while getopts 'K:M:P:S:adfhkm:op:tw' cmd_arg; do
+ while getopts 'K:M:P:S:adfhklm:op:tw' cmd_arg; do
case "${cmd_arg}" in
K) Kflag=Kflag
REGEXP=$OPTARG ;;
@@ -613,6 +624,7 @@ man_parse_opts() {
f) fflag=fflag ;;
h) man_usage 0 ;;
k) kflag=kflag ;;
+ l) lflag=lflag ;;
m) mflag=$OPTARG ;;
o) oflag=oflag ;;
p) MANROFFSEQ=$OPTARG ;;
@@ -625,16 +637,19 @@ man_parse_opts() {
shift $(( $OPTIND - 1 ))
# Check the args for incompatible options.
-
- case "${Kflag}${fflag}${kflag}${tflag}${wflag}" in
+ case "${Kflag}${fflag}${kflag}${lflag}${tflag}${wflag}" in
Kflagfflag*) echo "Incompatible options: -K and -f"; man_usage ;;
Kflag*kflag*) echo "Incompatible options: -K and -k"; man_usage ;;
+ Kflag*lflag*) echo "Incompatible options: -K and -l"; man_usage ;;
Kflag*tflag) echo "Incompatible options: -K and -t"; man_usage ;;
fflagkflag*) echo "Incompatible options: -f and -k"; man_usage ;;
+ fflag*lflag*) echo "Incompatible options: -f and -l"; man_usage ;;
fflag*tflag*) echo "Incompatible options: -f and -t"; man_usage ;;
fflag*wflag) echo "Incompatible options: -f and -w"; man_usage ;;
- *kflagtflag*) echo "Incompatible options: -k and -t"; man_usage ;;
+ *kflaglflag*) echo "Incompatible options: -k and -l"; man_usage ;;
+ *kflag*tflag*) echo "Incompatible options: -k and -t"; man_usage ;;
*kflag*wflag) echo "Incompatible options: -k and -w"; man_usage ;;
+ *lflag*wflag) echo "Incompatible options: -l and -w"; man_usage ;;
*tflagwflag) echo "Incompatible options: -t and -w"; man_usage ;;
esac
@@ -751,7 +766,7 @@ man_setup_locale() {
# Display usage for the man utility.
man_usage() {
echo 'Usage:'
- echo ' man [-adho] [-t | -w] [-M manpath] [-P pager] [-S mansect]'
+ echo ' man [-adhlo] [-t | -w] [-M manpath] [-P pager] [-S mansect]'
echo ' [-m arch[:machine]] [-p [eprtv]] [mansect] page [...]'
echo ' man -K | -f | -k expression [...] -- Search manual pages'
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
index c5255b1468fd..0d04aad4e558 100644
--- a/usr.bin/mandoc/Makefile
+++ b/usr.bin/mandoc/Makefile
@@ -4,7 +4,7 @@ MANDOCDIR= ${SRCTOP}/contrib/mandoc
.PATH: ${MANDOCDIR}
PROG= mandoc
-MAN= mandoc.1 eqn.7 mandoc_char.7 tbl.7 man.7 mdoc.7 roff.7
+MAN= mandoc.1 mandoc.db.5 eqn.7 mandoc_char.7 tbl.7 man.7 mdoc.7 roff.7
MLINKS= mandoc.1 mdocml.1
.if ${MK_MAN_UTILS} != no
MAN+= apropos.1 makewhatis.8
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 7014f02032c2..5f36b1599cad 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -767,15 +767,20 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
p1a(tcps_sc_badack, "\t\t{:bad-ack/%ju} {N:/badack}\n");
p1a(tcps_sc_unreach, "\t\t{:unreachable/%ju} {N:/unreach}\n");
p(tcps_sc_zonefail, "\t\t{:zone-failures/%ju} {N:/zone failure%s}\n");
+
+ xo_close_container("syncache");
+
+ xo_open_container("syncookies");
+
p(tcps_sc_sendcookie, "\t{:sent-cookies/%ju} {N:/cookie%s sent}\n");
- p(tcps_sc_recvcookie, "\t{:received-cookies/%ju} "
+ p(tcps_sc_recvcookie, "\t\t{:received-cookies/%ju} "
"{N:/cookie%s received}\n");
- p(tcps_sc_spurcookie, "\t{:spurious-cookies/%ju} "
+ p(tcps_sc_spurcookie, "\t\t{:spurious-cookies/%ju} "
"{N:/spurious cookie%s rejected}\n");
- p(tcps_sc_failcookie, "\t{:failed-cookies/%ju} "
+ p(tcps_sc_failcookie, "\t\t{:failed-cookies/%ju} "
"{N:/failed cookie%s rejected}\n");
- xo_close_container("syncache");
+ xo_close_container("syncookies");
xo_open_container("hostcache");
diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c
index c3abac407327..08cfc31c12c9 100644
--- a/usr.bin/netstat/sctp.c
+++ b/usr.bin/netstat/sctp.c
@@ -622,6 +622,10 @@ sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
"{N:/fast path receives all one chunk}\n");
p1a(sctps_recvexpressm, "\t\t{:receives-fast-path-multipart/%ju} "
"{N:/fast path multi-part data}\n");
+ p1a(sctps_recvswcrc, "\t\t{:performed-receive-crc32c-computation/%ju} "
+ "{N:/performed receive crc32c computation}\n");
+ p1a(sctps_recvhwcrc, "\t\t{:performed-receive-crc32c-offloading/%ju} "
+ "{N:/performed receive crc32c offloading}\n");
/*
* output statistics
@@ -648,6 +652,10 @@ sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
"{N:/output AUTH chunk%s}\n");
p1a(sctps_senderrors, "\t\t{:send-errors/%ju} "
"{N:/ip_output error counter}\n");
+ p1a(sctps_sendswcrc, "\t\t{:performed-receive-crc32c-computation/%ju} "
+ "{N:/performed transmit crc32c computation}\n");
+ p1a(sctps_sendhwcrc, "\t\t{:performed-transmit-crc32c-offloading/%ju} "
+ "{N:/performed transmit crc32c offloading}\n");
/*
* PCKDROPREP statistics
diff --git a/usr.bin/patch/tests/unified_patch_test.sh b/usr.bin/patch/tests/unified_patch_test.sh
index 7d4b74182c41..a91332908773 100755
--- a/usr.bin/patch/tests/unified_patch_test.sh
+++ b/usr.bin/patch/tests/unified_patch_test.sh
@@ -141,6 +141,23 @@ file_removal_body()
atf_check -o inline:"y\n" cat foo
}
+atf_test_case namespace
+namespace_head()
+{
+ atf_set "descr" "Test that patch(1) handles files with spaces in the name"
+}
+namespace_body()
+{
+ echo "ABC" > "with spaces.orig"
+ echo "ZYX" > "with spaces"
+
+ atf_check -s not-exit:0 -o save:spaces.diff \
+ diff -u "with spaces.orig" "with spaces"
+
+ atf_check mv "with spaces.orig" "with spaces"
+ atf_check -o not-empty patch < spaces.diff
+}
+
atf_test_case plinelen
plinelen_body()
{
@@ -166,5 +183,6 @@ atf_init_test_cases()
atf_add_test_case file_creation
atf_add_test_case file_nodupe
atf_add_test_case file_removal
+ atf_add_test_case namespace
atf_add_test_case plinelen
}
diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c
index b5e0248b743a..2e75e4966d80 100644
--- a/usr.bin/sockstat/main.c
+++ b/usr.bin/sockstat/main.c
@@ -1612,7 +1612,7 @@ display(void)
}
}
if (opt_j >= 0)
- return;
+ goto out;
SLIST_FOREACH(s, &nosocks, socket_list) {
if (!check_ports(s))
continue;
@@ -1637,6 +1637,7 @@ display(void)
display_sock(s, &cw, buf, bufsize);
xo_close_instance("socket");
}
+out:
xo_close_list("socket");
xo_close_container("sockstat");
if (xo_finish() < 0)
diff --git a/usr.bin/w/pr_time.c b/usr.bin/w/pr_time.c
index aef8b5dfaa87..445431fe3ec5 100644
--- a/usr.bin/w/pr_time.c
+++ b/usr.bin/w/pr_time.c
@@ -79,8 +79,13 @@ pr_attime(time_t *started, time_t *now)
(void)wcsftime(buf, sizeof(buf), fmt, &tp);
len = wcslen(buf);
width = wcswidth(buf, len);
- xo_attr("since", "%lu", (unsigned long) *started);
- xo_attr("delta", "%lu", (unsigned long) diff);
+ if (xo_get_style(NULL) == XO_STYLE_XML) {
+ xo_attr("since", "%lu", (unsigned long)*started);
+ xo_attr("delta", "%lu", (unsigned long)diff);
+ } else {
+ xo_emit("{e:login-time-since/%lu}{e:login-time-delta/%lu}",
+ (unsigned long)*started, (unsigned long)diff);
+ }
if (len == width)
xo_emit("{:login-time/%-7.7ls/%ls}", buf);
else if (width < 7)
@@ -100,10 +105,16 @@ pr_attime(time_t *started, time_t *now)
int
pr_idle(time_t idle)
{
+ /* In encoded formats, emit the raw data as well */
+ if (xo_get_style(NULL) == XO_STYLE_XML)
+ xo_attr("seconds", "%lu", (unsigned long) idle);
+ else
+ xo_emit("{e:idle-seconds/%lu}", (unsigned long) idle);
+
/* If idle more than 36 hours, print as a number of days. */
if (idle >= 36 * 3600) {
int days = idle / 86400;
- xo_emit(" {:idle/%dday%s} ", days, days > 1 ? "s" : " " );
+ xo_emit(" {q:idle/%dday%s} ", days, days > 1 ? "s" : " " );
if (days >= 100)
return (2);
if (days >= 10)
@@ -111,16 +122,17 @@ pr_idle(time_t idle)
}
/* If idle more than an hour, print as HH:MM. */
- else if (idle >= 3600)
- xo_emit(" {:idle/%2d:%02d/} ",
+ else if (idle >= 3600) {
+ xo_emit(" {q:idle/%2d:%02d} ",
(int)(idle / 3600), (int)((idle % 3600) / 60));
+ }
else if (idle / 60 == 0)
- xo_emit(" - ");
+ xo_emit(" - {q:idle//0}");
/* Else print the minutes idle. */
else
- xo_emit(" {:idle/%2d} ", (int)(idle / 60));
+ xo_emit(" {q:idle/%2d} ", (int)(idle / 60));
return (0); /* not idle longer than 9 days */
}
diff --git a/usr.bin/w/uptime.1 b/usr.bin/w/uptime.1
index b93972d3f932..37881793736f 100644
--- a/usr.bin/w/uptime.1
+++ b/usr.bin/w/uptime.1
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 18, 2020
+.Dd September 11, 2025
.Dt UPTIME 1
.Os
.Sh NAME
@@ -33,6 +33,7 @@
.Nd show how long system has been running
.Sh SYNOPSIS
.Nm
+.Op Fl -libxo
.Sh DESCRIPTION
The
.Nm
@@ -40,6 +41,17 @@ utility displays the current time,
the length of time the system has been up,
the number of users, and the load average of the system over the last
1, 5, and 15 minutes.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl -libxo
+Generate output via
+.Xr libxo 3
+in a selection of different human and machine readable formats.
+See
+.Xr xo_options 7
+for details on command line arguments.
+.El
.Sh FILES
.Bl -tag -width /boot/kernel/kernel
.It Pa /boot/kernel/kernel
@@ -51,7 +63,9 @@ $ uptime
11:23AM up 3:01, 8 users, load averages: 21.09, 15.43, 12.79
.Ed
.Sh SEE ALSO
-.Xr w 1
+.Xr w 1 ,
+.Xr libxo 3 ,
+.Xr xo_options 7
.Sh HISTORY
The
.Nm
diff --git a/usr.bin/w/w.1 b/usr.bin/w/w.1
index 159eb3370c8c..2dbcffdeda1f 100644
--- a/usr.bin/w/w.1
+++ b/usr.bin/w/w.1
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 16, 2025
+.Dd September 11, 2025
.Dt W 1
.Os
.Sh NAME
@@ -54,7 +54,7 @@ user is on, the host from which the user is logged in, the time the user
logged on, the time since the user last typed anything,
and the name and arguments of the current process.
.Pp
-The options are as follows:
+The following options are available:
.Bl -tag -width indent
.It Fl -libxo
Generate output via