Date: Tue, 27 Jul 2004 10:28:56 +0300 From: Mike Makonnen <mtm@identd.net> To: Christian Weisgerber <naddy@mips.inka.de> Cc: freebsd-current@freebsd.org Subject: Re: HEADS UP: change in ports rc.d script behaviour Message-ID: <20040727072856.GC1403@rogue.acs-et.com> In-Reply-To: <ce2pk8$2nqg$1@kemoauc.mips.inka.de> References: <20040725141208.GA28326@rogue.acs-et.com> <20040725173934.GA1213@crodrigues.org> <ce2pk8$2nqg$1@kemoauc.mips.inka.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jul 26, 2004 at 11:23:52AM +0000, Christian Weisgerber wrote: > Craig Rodrigues <rodrigc@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@identd.net | Fingerprint: AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55 mtm@FreeBSD.Org| FreeBSD - Unleash the Daemon !
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040727072856.GC1403>