git: 667e30d9d480 - main - sysrc: sort -fd and comments

From: Devin Teske <dteske_at_FreeBSD.org>
Date: Wed, 25 Nov 2026 21:51:22 UTC
The branch main has been updated by dteske:

URL: https://cgit.FreeBSD.org/src/commit/?id=667e30d9d480c4162848812382360267ece02b14

commit 667e30d9d480c4162848812382360267ece02b14
Author:     Devin Teske <dteske@FreeBSD.org>
AuthorDate: 2026-11-25 21:44:40 +0000
Commit:     Devin Teske <dteske@FreeBSD.org>
CommitDate: 2026-11-25 21:47:37 +0000

    sysrc: sort -fd and comments
    
    Reviewed by:    kfv, ngie
    Differential Revision:  https://reviews.freebsd.org/D61719
---
 usr.sbin/sysrc/sysrc   | 89 +++++++++++++++++++++++++-------------------------
 usr.sbin/sysrc/sysrc.8 | 72 ++++++++++++++++++++--------------------
 2 files changed, 81 insertions(+), 80 deletions(-)

diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
index dc3a3e39cf3b..a02538901136 100644
--- a/usr.sbin/sysrc/sysrc
+++ b/usr.sbin/sysrc/sysrc
@@ -16,30 +16,30 @@ pgm="${0##*/}" # Program basename
 #
 # Version information
 #
-SYSRC_VERSION="8.3 Nov-16,2026"
+SYSRC_VERSION="8.4 Nov-18,2026"
 
 #
 # Options
 #
-CHECK_ONLY=
-DEFAULT=
-DELETE=
-DESCRIBE=
-EXISTING_ONLY=
-IGNORE_UNKNOWNS=
-JAIL=
-LIST_SERVICE_CONFS=
-LIST_CONFS=
-QUIET=
-RAW=
-ROOTDIR=
-SERVICE=
-SHOW_ALL=
-SHOW_EQUALS=
-SHOW_FILE=
-SHOW_NAME=1
-SHOW_VALUE=1
-VERBOSE=
+CHECK_ONLY=		# -c
+DEFAULT=		# -D
+DELETE=			# -x / -X
+DESCRIBE=		# -d
+EXISTING_ONLY=		# -E
+IGNORE_UNKNOWNS=	# -i
+JAIL=			# -j jail
+LIST_CONFS=		# -l
+LIST_SERVICE_CONFS=	# -L
+QUIET=			# -q
+RAW=			# -r
+ROOTDIR=		# -R rootdir
+SERVICE=		# -s svcname
+SHOW_ALL=		# -a / -A
+SHOW_EQUALS=		# -e
+SHOW_FILE=		# -F
+SHOW_NAME=1		# -n
+SHOW_VALUE=1		# -N
+VERBOSE=		# -v
 
 ############################################################ FUNCTIONS
 
@@ -82,30 +82,30 @@ help()
 	f_err "Usage: %s [OPTIONS] -l | -L [name ...]\n" "$pgm"
 
 	f_err "OPTIONS:\n"
-	f_err "$optfmt" "-a" \
-	      "Dump a list of all non-default configuration variables."
 	f_err "$optfmt" "-A" \
 	      "Dump a list of all configuration variables (incl. defaults)."
+	f_err "$optfmt" "-a" \
+	      "Dump a list of all non-default configuration variables."
 	f_err "$optfmt" "-c" \
 	      "Check. Return success if set or no changes, else error."
-	f_err "$optfmt" "-d" \
-	      "Print a description of the given variable."
 	f_err "$optfmt" "-D" \
 	      "Show default value(s) only (this is the same as setting"
 	f_err "$optfmt" "" \
 	      "RC_CONFS to NULL or passing \`-f' with a NULL file-argument)."
+	f_err "$optfmt" "-d" \
+	      "Print a description of the given variable."
+	f_err "$optfmt" "-E" \
+	      "Existing files only with \`-[lL]' or when changing a setting."
 	f_err "$optfmt" "-e" \
 	      "Print query results as \`var=value' (useful for producing"
 	f_err "$optfmt" "" \
 	      "output to be fed back in). Ignored if \`-n' is specified."
-	f_err "$optfmt" "-E" \
-	      "Existing files only with \`-[lL]' or when changing a setting."
+	f_err "$optfmt" "-F" \
+	      "Show only the last rc.conf(5) file each directive is in."
 	f_err "$optfmt" "-f file" \
 	      "Operate on the specified file(s) instead of rc_conf_files."
 	f_err "$optfmt" "" \
 	      "Can be specified multiple times for additional files."
-	f_err "$optfmt" "-F" \
-	      "Show only the last rc.conf(5) file each directive is in."
 	f_err "$optfmt" "-h" \
 	      "Print a short usage statement to stderr and exit."
 	f_err "$optfmt" "--help" \
@@ -116,20 +116,20 @@ help()
 	      "The jid or name of the jail to operate within (overrides"
 	f_err "$optfmt" "" \
 	      "\`-R dir'; requires jexec(8))."
-	f_err "$optfmt" "-l" \
-	      "List configuration files used at startup on stdout and exit."
 	f_err "$optfmt" "-L" \
 	      "List all configuration files including rc.conf.d entries."
-	f_err "$optfmt" "-n" \
-	      "Show only variable values, not their names."
+	f_err "$optfmt" "-l" \
+	      "List configuration files used at startup on stdout and exit."
 	f_err "$optfmt" "-N" \
 	      "Show only variable names, not their values."
+	f_err "$optfmt" "-n" \
+	      "Show only variable values, not their names."
 	f_err "$optfmt" "-q" \
 	      "Quiet. Disable verbose and hide certain errors."
-	f_err "$optfmt" "-r" \
-	      "Show raw, unexpanded value(s)."
 	f_err "$optfmt" "-R dir" \
 	      "Operate within the root directory \`dir' rather than \`/'."
+	f_err "$optfmt" "-r" \
+	      "Show raw, unexpanded value(s)."
 	f_err "$optfmt" "-s name" \
 	      "Process additional \`rc.conf.d' entries for service name."
 	f_err "$optfmt" "" \
@@ -219,37 +219,37 @@ unset arg
 #
 # Process command-line flags
 #
-while getopts aAcdDeEf:Fhij:lLnNqrR:s:vxX flag; do
+while getopts AacDdEeFf:hij:LlNnqR:rs:vXx flag; do
 	case "$flag" in
-	a) SHOW_ALL=${SHOW_ALL:-1} ;;
 	A) SHOW_ALL=2 ;;
+	a) SHOW_ALL=${SHOW_ALL:-1} ;;
 	c) CHECK_ONLY=1 ;;
-	d) DESCRIBE=1 ;;
 	D) DEFAULT=1 RC_CONFS= ;;
-	e) SHOW_EQUALS=1 ;;
+	d) DESCRIBE=1 ;;
 	E) EXISTING_ONLY=1 ;;
-	f) DEFAULT= RC_CONFS="$RC_CONFS${RC_CONFS:+ }$OPTARG" ;;
+	e) SHOW_EQUALS=1 ;;
 	F) SHOW_FILE=1 ;;
+	f) DEFAULT= RC_CONFS="$RC_CONFS${RC_CONFS:+ }$OPTARG" ;;
 	h) usage ;; # NOTREACHED
 	i) IGNORE_UNKNOWNS=1 ;;
 	j) [ "$OPTARG" ] ||
 		die "%s: Missing or null argument to \`-j' flag" "$pgm"
 	   JAIL="$OPTARG" ;;
-	l) LIST_CONFS=1 ;;
 	L) LIST_SERVICE_CONFS=1 ;;
-	n) SHOW_NAME= ;;
+	l) LIST_CONFS=1 ;;
 	N) SHOW_VALUE= ;;
+	n) SHOW_NAME= ;;
 	q) QUIET=1 VERBOSE= ;;
-	r) RAW=1 ;;
 	R) [ "$OPTARG" ] ||
 		die "%s: Missing or null argument to \`-R' flag" "$pgm"
 	   ROOTDIR="$OPTARG" ;;
+	r) RAW=1 ;;
 	s) [ "$OPTARG" ] ||
 		die "%s: Missing or null argument to \`-s' flag" "$pgm"
 	   SERVICE="$OPTARG" ;;
 	v) VERBOSE=1 QUIET= ;;
-	x) DELETE=${DELETE:-1} ;;
 	X) DELETE=2 ;;
+	x) DELETE=${DELETE:-1} ;;
 	\?) usage ;; # NOTREACHED
 	esac
 done
@@ -434,7 +434,7 @@ fi
 	die "$pgm: \`-c' option incompatible with \`-a'/\`-A' options"
 
 #
-# Process `-e', `-n', and `-N' command-line options
+# Process `-e', `-N', and `-n' command-line options
 #
 SEP=': '
 [ "$SHOW_FILE" ] && SHOW_EQUALS=
@@ -452,6 +452,7 @@ fi
 if [ "$JAIL" -o "$ROOTDIR" ]; then
 	#
 	# Reconstruct the arguments that we want to carry-over
+	# NB: Order matters
 	#
 	args="
 		${VERBOSE:+-v}
diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8
index 97fbc265ff4c..06460840f5f2 100644
--- a/usr.sbin/sysrc/sysrc.8
+++ b/usr.sbin/sysrc/sysrc.8
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 17, 2026
+.Dd November 18, 2026
 .Dt SYSRC 8
 .Os
 .Sh NAME
@@ -33,25 +33,25 @@
 .Nd safely edit system rc files
 .Sh SYNOPSIS
 .Nm
-.Op Fl cdDeEFhinNqrvx
-.Op Fl s Ar name
+.Op Fl cDdEeFhiNnqrvx
 .Op Fl f Ar file
 .Op Fl j Ar jail | Fl R Ar dir
+.Op Fl s Ar name
 .Ar name Ns Op Ns Oo +|-|. Oc Ns = Ns Ar value
 .Ar ...
 .Nm
-.Op Fl cdDeEFhinNqrvx
-.Op Fl s Ar name
+.Op Fl cDdEeFhiNnqrvx
 .Op Fl f Ar file
 .Op Fl j Ar jail | Fl R Ar dir
-.Fl a | A
+.Op Fl s Ar name
+.Fl A | a
 .Nm
 .Op Fl E
-.Op Fl s Ar name
 .Op Fl f Ar file
+.Op Fl s Ar name
 .Fl l
 .Nm
-.Op Fl eEqv
+.Op Fl Eeqv
 .Fl L
 .Op Ar name ...
 .Sh DESCRIPTION
@@ -64,11 +64,11 @@ appropriate privilege to change values in a safe and effective manner.
 .Pp
 The following options are available:
 .Bl -tag -width indent+
-.It Fl a
-Dump a list of all non-default configuration variables.
 .It Fl A
 Dump a list of all configuration variables
 .Pq incl. defaults .
+.It Fl a
+Dump a list of all non-default configuration variables.
 .It Fl c
 Check only.
 For querying, return success if all requested variables are set
@@ -78,11 +78,18 @@ For assignments, return success if no changes are required, otherwise failure.
 If verbose
 .Pq see Dq Fl v
 prints a message stating whether variables are set and/or changes are required.
-.It Fl d
-Print a description of the given variable.
 .It Fl D
 Show default value(s) only (this is the same as setting RC_CONFS to NULL or
 passing `-f' with a NULL file-argument).
+.It Fl d
+Print a description of the given variable.
+.It Fl E
+When given
+.Sq Fl l
+or
+.Sq Fl L
+to list configuration files, only list those that exist.
+When changing a setting, prefer to modify existing files.
 .It Fl e
 Print query results as
 .Xr sh 1
@@ -93,13 +100,10 @@ Ignored if either
 or
 .Ql Fl F
 is specified.
-.It Fl E
-When given
-.Sq Fl l
-or
-.Sq Fl L
-to list configuration files, only list those that exist.
-When changing a setting, prefer to modify existing files.
+.It Fl F
+Show only the last
+.Xr rc.conf 5
+file each directive is in.
 .It Fl f Ar file
 Operate on the specified file(s) instead of the files obtained by reading the
 .Sq rc_conf_files
@@ -107,10 +111,6 @@ entry in the
 .Ev RC_DEFAULTS
 file.
 This option can be specified multiple times for additional files.
-.It Fl F
-Show only the last
-.Xr rc.conf 5
-file each directive is in.
 .It Fl h
 Print a short usage message to stderr and exit.
 .It Fl -help
@@ -124,8 +124,6 @@ or name of the
 .Ar jail
 to operate within
 .Pq overrides So Fl R Ar dir Sc ; requires Xr jexec 8 .
-.It Fl l
-List configuration files used at startup on stdout and exit.
 .It Fl L
 List all configuration files including rc.conf.d entries on stdout and exit.
 Can be combined with
@@ -135,10 +133,12 @@ or
 to show service names.
 .Nm
 exits with success if all named services are installed, failure otherwise.
-.It Fl n
-Show only variable values, not their names.
+.It Fl l
+List configuration files used at startup on stdout and exit.
 .It Fl N
 Show only variable names, not their values.
+.It Fl n
+Show only variable values, not their names.
 .It Fl q
 Quiet.
 Disable verbose and hide certain errors.
@@ -147,13 +147,13 @@ When combined with
 and one or more
 .Ar name
 arguments, provide only exit status and no output.
-.It Fl r
-Show raw, unexpanded value(s).
 .It Fl R Ar dir
 Operate within the root directory
 .Sq Ar dir
 rather than
 .Sq / .
+.It Fl r
+Show raw, unexpanded value(s).
 .It Fl s Ar name
 If an
 .Li rc.d
@@ -465,26 +465,26 @@ The following standard commands are required by
 .Xr awk 1 ,
 .Xr cat 1 ,
 .Xr chmod 1 ,
+.Xr chown 8 ,
+.Xr chroot 8 ,
 .Xr env 1 ,
 .Xr grep 1 ,
+.Xr jexec 8 ,
+.Xr jls 8 ,
 .Xr mktemp 1 ,
 .Xr mv 1 ,
 .Xr rm 1 ,
 .Xr sh 1 ,
 .Xr stat 1 ,
-.Xr tail 1 ,
-.Xr chown 8 ,
-.Xr chroot 8 ,
-.Xr jls 8 ,
 and
-.Xr jexec 8 .
+.Xr tail 1 .
 .Sh FILES
 .Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact
 .It Pa /etc/defaults/rc.conf
 .It Pa /etc/rc.conf
-.It Pa /etc/rc.conf.local
 .It Pa /etc/rc.conf.d/name
 .It Pa /etc/rc.conf.d/name/*
+.It Pa /etc/rc.conf.local
 .It Pa /usr/local/etc/rc.conf.d/name
 .It Pa /usr/local/etc/rc.conf.d/name/*
 .El
@@ -542,11 +542,11 @@ Return
 if $cloned_interfaces is set:
 .Dl sysrc cloned_interfaces+"alternate"
 .Sh SEE ALSO
-.Xr rc.conf 5 ,
 .Xr jail 8 ,
 .Xr jexec 8 ,
 .Xr jls 8 ,
 .Xr rc 8 ,
+.Xr rc.conf 5 ,
 .Xr rc.subr 8 ,
 .Xr sysctl 8
 .Sh HISTORY