git: 65355d0f213e - main - sysrc: Restore the ability to pin default value
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Nov 2026 04:37:38 UTC
The branch main has been updated by dteske:
URL: https://cgit.FreeBSD.org/src/commit/?id=65355d0f213e11443cd13efad7c98e8ba5b6984b
commit 65355d0f213e11443cd13efad7c98e8ba5b6984b
Author: Devin Teske <dteske@FreeBSD.org>
AuthorDate: 2026-11-26 04:33:42 +0000
Commit: Devin Teske <dteske@FreeBSD.org>
CommitDate: 2026-11-26 04:33:42 +0000
sysrc: Restore the ability to pin default value
Fix 1 issue identified in post-commit review of eaf7113:
POSTCR-1: "unchanged" short-circuit counts a value that only comes
from RC_DEFAULTS, so `sysrc -f file var=<default>` writes nothing.
Add an ATF test to ensure we preserve this functionality.
Reported by: llm-postcr
Fixes: eaf7113bef8f ("sysrc: Add "unchanged" messages")
---
usr.sbin/sysrc/sysrc | 5 +++--
usr.sbin/sysrc/tests/sysrc_test.sh | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
index d79bb4952c40..daa78845ace8 100644
--- a/usr.sbin/sysrc/sysrc
+++ b/usr.sbin/sysrc/sysrc
@@ -16,7 +16,7 @@ pgm="${0##*/}" # Program basename
#
# Version information
#
-SYSRC_VERSION="9.3 Nov-18,2026"
+SYSRC_VERSION="9.3.1 Nov-25,2026"
#
# Options
@@ -925,7 +925,8 @@ while [ $# -gt 0 ]; do
# An unset name is not already NULL
if [ "$before" = "$new" ] &&
- IGNORED=$( f_sysrc_get "$NAME?" )
+ file=$( f_sysrc_find "$NAME" ) &&
+ [ "$file" != "$RC_DEFAULTS" ]
then
if [ "$QUIET" ]; then
: nothing
diff --git a/usr.sbin/sysrc/tests/sysrc_test.sh b/usr.sbin/sysrc/tests/sysrc_test.sh
index 7a5a6f90b85a..60df7d5f34f3 100644
--- a/usr.sbin/sysrc/tests/sysrc_test.sh
+++ b/usr.sbin/sysrc/tests/sysrc_test.sh
@@ -68,6 +68,31 @@ set_variable_body()
cat "${SYSRC_CONF}"
}
+atf_test_case pin_default cleanup
+pin_default_head()
+{
+ atf_set "descr" "Pin a defaults-only value into the target file"
+}
+pin_default_body()
+{
+ RC_DEFAULTS="${PWD}/rc_defaults.conf"
+ echo 'test_enable="NO"' > "${RC_DEFAULTS}"
+ export RC_DEFAULTS
+
+ # Record the default in the target. Do not report it unchanged
+ atf_check -o inline:"test_enable: NO -> NO\n" \
+ sysrc -f "${SYSRC_CONF}" test_enable=NO
+ atf_check -o inline:'test_enable="NO"\n' cat "${SYSRC_CONF}"
+ # Stored outside the defaults file
+ atf_check -o inline:"test_enable: NO (unchanged)\n" \
+ sysrc -f "${SYSRC_CONF}" test_enable=NO
+ atf_check -o inline:'test_enable="NO"\n' cat "${SYSRC_CONF}"
+}
+pin_default_cleanup()
+{
+ unset RC_DEFAULTS
+}
+
atf_test_case remove_variable_x_flag
remove_variable_x_flag_head()
{
@@ -575,6 +600,7 @@ atf_init_test_cases()
{
atf_add_test_case check_variable
atf_add_test_case set_variable
+ atf_add_test_case pin_default
atf_add_test_case set_variable_newline
atf_add_test_case set_variable_backslash
atf_add_test_case remove_variable_x_flag