I think we need to update unbound and spamlogd to add OPTIND=1 to local.
After reading these in "man ksh":
Functions
Functions defined with the function reserved word are treated differently
in the following ways from functions defined with the () notation:
o OPTIND is saved/reset and restored on entry and exit from the
function so getopts can be used properly both inside and outside the
function (Bourne-style functions leave OPTIND untouched, so using
getopts inside a function interferes with using getopts outside the
function).
getopts optstring name [arg ...]
Option parsing can be reset by setting OPTIND to 1 (this is done
automatically whenever the shell or a shell procedure is invoked).
Warning: Changing the value of the shell parameter OPTIND to a
value other than 1, or parsing different sets of arguments
without resetting OPTIND, may lead to unexpected results.
I did some testing to see what OPTIND was set to when rc_pre is called.
When I run "rcctl start unbound" then OPTIND is 1 when rc_pre starts.
but if I run "rcctl -q start unbound" then OPTIND is 2 when rc_pre starts.
Just appending OPTIND to local doesn't clear its' value (I still get 2)
Since everything uses bourne-style functions it is probably better
to append OPTIND=1 to the local definitions line to reset it.
/etc/rc.d$ diff -u unbound unbound
--- unbound Sun Nov 16 13:27:50 2025 1.10
+++ unbound Mon Nov 24 22:21:24 2025
@@ -8,7 +8,7 @@
. /etc/rc.d/rc.subr
rc_pre() {
- local _anchor _config _opt
+ local _anchor _config _opt OPTIND=1
while getopts :c: _opt $daemon_flags; do
[[ $_opt == c ]] && _config=$OPTARG
/etc/rc.d$ diff -u spamlogd.orig spamlogd
--- spamlogd Sun Nov 16 13:29:02 2025 1.7
+++ spamlogd Mon Nov 24 22:21:37 2025
@@ -9,7 +9,7 @@
rc_reload=NO
rc_pre() {
- local _opt pflog=pflog0
+ local _opt pflog=pflog0 OPTIND=1
while getopts :l: _opt $daemon_flags; do
[[ $_opt == l ]] && pflog=$OPTARG