Date:        Thu, 10 Apr 2025 14:25:45 +0200
    From:        Christoph Badura <b...@bsd.de>
    Message-ID:  <20250410122545.ga26...@irregular-apocalypse.k.bsd.de>

  | echo '$start_precmd="$start_precmd; drvctl -d pchb0' >> 
/etc/rc.conf.d/modules

That would want to be:

echo 'start_precmd=${start_precmd:+"${start_precmd}; "}"drvctl -d pchb0"' \
         >> /etc/rc.conf.d/modules

or the new command could be prepended, that's a bit easier, as

        cmd;

is legal sh code, but

        ;cmd

is not (hence all the crud above), so:

echo 'start_precmd="drvctl -d pchb0; ${start_precmd:-}"' >> 
/etc/rc.conf.d/modules

should work, and both be the same when there is no existing start_precmd.

Or the way Iain Hibbert suggested, though I doubt there's much point wrapping
one single command in a function (if one wanted more than that one command,
perhaps testing something, maybe the "pchb0" string could come from a variable
set in rc.conf, and the command only be run if that var is set

modules_prestart()
{
        if test -n "${bus_to_delete:-}"
        then
                drvctl -d "${bus_to_delete}"
        fi
}

perhaps (but do think of a better name for the variable, and do set
it in rc.conf when required).

kre

Reply via email to