From owner-freebsd-current@FreeBSD.ORG Tue Jul 27 07:28:59 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 225AA16A4CE for ; Tue, 27 Jul 2004 07:28:59 +0000 (GMT) Received: from telecom.net.et (sparrow.telecom.net.et [213.55.64.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id D5AE943D54 for ; Tue, 27 Jul 2004 07:28:56 +0000 (GMT) (envelope-from mtm@identd.net) Received: from [213.55.67.163] (HELO pool-151-200-10-97.res.east.verizon.net) by telecom.net.et (CommuniGate Pro SMTP 3.4.8) with ESMTP-TLS id 52729174; Tue, 27 Jul 2004 10:22:09 +0300 Received: from rogue.acs-et.com (localhost [127.0.0.1]) ESMTP id i6R7TCu2004823; Tue, 27 Jul 2004 10:29:20 +0300 (EAT) (envelope-from mtm@rogue.acs-et.com) Received: (from mtm@localhost) by rogue.acs-et.com (8.12.11/8.12.11/Submit) id i6R7T03A004822; Tue, 27 Jul 2004 10:29:00 +0300 (EAT) (envelope-from mtm) Date: Tue, 27 Jul 2004 10:28:56 +0300 From: Mike Makonnen To: Christian Weisgerber Message-ID: <20040727072856.GC1403@rogue.acs-et.com> References: <20040725141208.GA28326@rogue.acs-et.com> <20040725173934.GA1213@crodrigues.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD/5.2-CURRENT (i386) cc: freebsd-current@freebsd.org Subject: Re: HEADS UP: change in ports rc.d script behaviour X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jul 2004 07:28:59 -0000 On Mon, Jul 26, 2004 at 11:23:52AM +0000, Christian Weisgerber wrote: > Craig Rodrigues 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 !