Re: HEADS UP: change in ports rc.d script behaviour

From: Mike Makonnen <mtm_at_identd.net>
Date: Tue, 27 Jul 2004 10:28:56 +0300
On Mon, Jul 26, 2004 at 11:23:52AM +0000, Christian Weisgerber wrote:
> Craig Rodrigues <rodrigc_at_crodrigues.org> wrote:
> 
> > > 4. If you must include a default value for an rc.conf(5) knob,
> > >    make sure that you put it in an if [ -z "$foo_knob"] clause.
> > 
> > As a simple alternative to an if clause, I've done this for the 
> > isc-dhcp3-server port:
> > 
> > [ -z "$dhcpd_enable" ] && dhcpd_enable="NO"
> 
> dhcpd_enable=${dhcpd_enable:-NO}

Actually, when I was doing the patching yesterday, I realized that
my original suggestion wasn't correct. Yours is closer but still
wrong. It should be:
dhcpd_enable=${dhcpd_enable-"NO"}

This is because the ports scripts should define it *only* if the user
hasn't specified it. This isn't terribly important for an *_enable knob,
but it is crucial for something like foo_flags="". The ':-' modifier
to the parameter sets the variable if it doesn't exist or it's empty, while
the second only sets it if it doesn't exit. Here's an example:

The first and WRONG way: ${dhcpd_flags:-NO}:
rc.conf: dhcpd_flags=
rc.d/dhcpd.sh: dhcpd_flags="-x foo"
during execution: dhcpd_flags="-x foo"

The RIGHT way: ${dhcpd_flags-"-x foo"}
rc.conf: dhcpd_flags=
rc.d/dhcpd.sh: dhcpd_flags="-x foo"
during execution: dhcpd_flags=""

Cheers.
--
Mike Makonnen  | GPG-KEY: http://www.identd.net/~mtm/mtm.asc
mtm_at_identd.net | Fingerprint: AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
mtm_at_FreeBSD.Org| FreeBSD - Unleash the Daemon !
Received on Tue Jul 27 2004 - 05:28:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:03 UTC