Page MenuHomeFreeBSD

D27318.diff
No OneTemporary

D27318.diff

diff --git a/bin/freebsd-version/freebsd-version.1 b/bin/freebsd-version/freebsd-version.1
--- a/bin/freebsd-version/freebsd-version.1
+++ b/bin/freebsd-version/freebsd-version.1
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 1, 2021
+.Dd August 15, 2022
.Dt FREEBSD-VERSION 1
.Os
.Sh NAME
@@ -33,7 +33,7 @@
.Nd print the version and patch level of the installed system
.Sh SYNOPSIS
.Nm
-.Op Fl kru
+.Op Fl kruv
.Op Fl j Ar jail
.Sh DESCRIPTION
The
@@ -61,6 +61,16 @@
These are hardcoded into
.Nm
during the build.
+.It Fl v
+Enable printing verbose output about the kernel and/or userland.
+It's a representation of
+.Pa "__FreeBSD_version" .
+Those are also know as
+.Pa OSRELDATE
+or
+.Pa OSVERSION .
+More information about it is documented in the
+.%B Porter's Handbook .
.It Fl j Ar jail
Print the version and patch level of the installed userland in the
given jail specified by
@@ -70,12 +80,12 @@
This option can be specified multiple times.
.El
.Pp
-If several of the above options are specified,
+If several options are specified,
.Nm
will print the installed kernel version first, then the running kernel
version, next the userland version, and finally the userland version
-of the specified jails, on separate lines.
-If neither is specified, it will print the userland version only.
+of the specified jail, on separate lines.
+If no option is specified, it will print the userland version only.
.Sh IMPLEMENTATION NOTES
The
.Nm
@@ -113,6 +123,11 @@
/bin/freebsd-version -u
.Ed
.Pp
+To print out a more verbose output of the command above:
+.Bd -literal -offset indent
+/bin/freebsd-version -uv
+.Ed
+.Pp
To inspect a system being repaired using a live CD:
.Bd -literal -offset indent
mount -rt ufs /dev/ada0p2 /mnt
@@ -121,6 +136,10 @@
.Sh SEE ALSO
.Xr uname 1 ,
.Xr loader.conf 5
+.Rs
+.%B Porter's Handbook
+.%U https://docs.freebsd.org/en/books/porters-handbook/
+.Re
.Sh HISTORY
The
.Nm
@@ -131,3 +150,5 @@
.Nm
utility and this manual page were written by
.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
+The verbose output was added and documented by
+.An Vinicius Zavam Aq Mt egypcio@FreeBSD.org .
diff --git a/bin/freebsd-version/freebsd-version.sh.in b/bin/freebsd-version/freebsd-version.sh.in
--- a/bin/freebsd-version/freebsd-version.sh.in
+++ b/bin/freebsd-version/freebsd-version.sh.in
@@ -39,6 +39,7 @@
KERNEL_RE='^@@TYPE@@ \([-.0-9A-Za-z]\{1,\}\) .*$'
progname=${0##*/}
+progverbose=0
#
# Print an error message and exit.
@@ -67,21 +68,30 @@
if [ ! -f "$kernfile" -o ! -r "$kernfile" ] ; then
error "unable to locate kernel"
fi
- what -qs "$kernfile" | sed -n "s/$KERNEL_RE/\\1/p"
+ if [ $progverbose -gt 0 ] ; then
+ out=$(what -qs "$kernfile" | sed "s|#[0-9+]||; s|:||" | awk '{print $2,$3}')
+ else
+ out=$(what -qs "$kernfile" | sed -n "s/$KERNEL_RE/\\1/p")
+ fi
+ echo "$out"
}
#
# Print the version of the currently running kernel.
#
running_version() {
- sysctl -n kern.osrelease
+ out=$(sysctl -n kern.osrelease)
+ [ $progverbose -gt 0 ] && out="${out} $(sysctl -n kern.osreldate)"
+ echo "$out"
}
#
# Print the hardcoded userland version.
#
userland_version() {
- echo $USERLAND_VERSION
+ out=$USERLAND_VERSION
+ [ $progverbose -gt 0 ] && out="${USERLAND_VERSION} $(uname -U)"
+ echo "$out"
}
#
@@ -97,7 +107,7 @@
# Print a usage string and exit.
#
usage() {
- echo "usage: $progname [-kru] [-j jail]" >&2
+ echo "usage: $progname [-kruv] [-j jail]" >&2
exit 1
}
@@ -107,7 +117,7 @@
main() {
# parse command-line arguments
local OPTIND=1 OPTARG option
- while getopts "kruj:" option ; do
+ while getopts "kruvj:" option ; do
case $option in
k)
opt_k=1
@@ -118,6 +128,9 @@
u)
opt_u=1
;;
+ v)
+ progverbose=1
+ ;;
j)
if [ $opt_j ] ; then
jail="$jail $OPTARG"

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 31, 7:22 AM (11 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16357393
Default Alt Text
D27318.diff (3 KB)

Event Timeline