From owner-freebsd-rc@FreeBSD.ORG Mon May 9 01:49:46 2011 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 530481065702 for ; Mon, 9 May 2011 01:49:46 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-yi0-f54.google.com (mail-yi0-f54.google.com [209.85.218.54]) by mx1.freebsd.org (Postfix) with ESMTP id EE0D98FC19 for ; Mon, 9 May 2011 01:49:45 +0000 (UTC) Received: by yie12 with SMTP id 12so2085431yie.13 for ; Sun, 08 May 2011 18:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:x-openpgp-key-id:x-openpgp-key-fingerprint :x-openpgp-key-url; bh=mH/qv92a4Hz/gywIgSs30D61QXOoKeLbjvfTkq9XP+0=; b=MiNDovH4AJcAHMoWX4Z17TLUsDZSAcbkjgKNM1jdqcptI23nG+NXwAan9Y4352M6Bz esX6zw9hCLrJWRq3pigRF+wTKhwaF1vbDSpxTssjt7wetF9yKew9SoGtnXNPrtReE/CB OhBEogLfqjhSiqb8FEUNnOZrPKnZw83Pq3pMA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:x-openpgp-key-id :x-openpgp-key-fingerprint:x-openpgp-key-url; b=J5fUhalP1klqyQoywcie0TcV3FTQxA/2ugsoytf839TJtvzAQ2p6P5ha4BiUgQO/HK ubb5sKKywMp2CpyPfdUsMhP4yRyO2aMUlYy3eYLNpmC5NVMKonxlxXkgGHu1hhn9jY8o riXn3WjRLqC9VGuSpdTCTIlHgMpexgfMgTP4Y= Received: by 10.236.190.230 with SMTP id e66mr981489yhn.479.1304905785265; Sun, 08 May 2011 18:49:45 -0700 (PDT) Received: from DataIX.net ([99.190.84.116]) by mx.google.com with ESMTPS id d46sm2408222yhn.74.2011.05.08.18.49.43 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 May 2011 18:49:44 -0700 (PDT) Sender: "J. Hellenthal" Received: from DataIX.net (localhost [127.0.0.1]) by DataIX.net (8.14.4/8.14.4) with ESMTP id p491nepr022990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 8 May 2011 21:49:41 -0400 (EDT) (envelope-from jhell@DataIX.net) Received: (from jhell@localhost) by DataIX.net (8.14.4/8.14.4/Submit) id p491nd3o022989; Sun, 8 May 2011 21:49:39 -0400 (EDT) (envelope-from jhell@DataIX.net) Date: Sun, 8 May 2011 21:49:39 -0400 From: Jason Hellenthal To: Devin Teske Message-ID: <20110509014939.GK3527@DataIX.net> References: <20110508191336.GC3527@DataIX.net> <5474DF9C-500A-4B51-948F-F56A66051476@vicor.com> <20110508215432.GG3527@DataIX.net> <20110509002349.GI3527@DataIX.net> <2E9FCA3F-79B7-4FE8-883E-EA1D45EECE56@vicor.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="boAH8PqvUi1v1f55" Content-Disposition: inline In-Reply-To: <2E9FCA3F-79B7-4FE8-883E-EA1D45EECE56@vicor.com> X-OpenPGP-Key-Id: 0x89D8547E X-OpenPGP-Key-Fingerprint: 85EF E26B 07BB 3777 76BE B12A 9057 8789 89D8 547E X-OpenPGP-Key-URL: http://bit.ly/0x89D8547E Cc: Garrett Cooper , freebsd-rc@freebsd.org Subject: Re: [RFC][Change-Request] Create usefulness in rc.subr etc/rc.conf.d/*.conf namespace. X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2011 01:49:46 -0000 --boAH8PqvUi1v1f55 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Devin, On Sun, May 08, 2011 at 05:57:05PM -0700, Devin Teske wrote: >=20 > On May 8, 2011, at 5:23 PM, Jason Hellenthal wrote: >=20 > >=20 > > Devin, > >=20 > > On Sun, May 08, 2011 at 03:52:06PM -0700, Devin Teske wrote: > >>=20 > >> I second Jilles all-builtin solution using `for' globbing (no forking = external processes or sub-shells). > >>=20 > >> Slight modification for brevity: > >>=20 > >> for _modular_conf in /etc/rc.conf.d/*.conf; do > >> [ -f "$_modular_conf" -a -x "$_modular_conf" ] || continue > >> debug "Sourcing $_modular_conf" > >> . "$_modular_conf" > >> done > >>=20 > >> Though I still think it ought to be: > >>=20 > >> for _modular_conf in /etc/rc.conf.d/*.conf; do > >> [ -f "$_modular_conf" ] || continue > >> debug "Sourcing $_modular_conf" > >> . "$_modular_conf" > >> done > >>=20 > >=20 > > Keeping with the examples of the rest of the style of rc.subr and plent= y=20 > > of other shell scripts here. This would be a distortion of the=20 > > functionality that the original loop is doing and should be avoided. > >=20 >=20 > I've picked up this tid-bit over the years: >=20 > 1. Since a conditional block causes all code within to be indented... > 2. if you have a condition which can cause a continuance within a looping= bock... > 3. utilizing said conditional early-on can prevent unnecessary indentatio= n in the following lines. >=20 > It's kind of moot for such a small example, but if you get to nesting 300= + lines at multiple levels of nesting then it's worth re-evaluating the use= of "early continuances". >=20 > Here's the basic idea... >=20 > for item in list; do > : condition to continue > : what the loop does > done >=20 > opposed to: >=20 > for item in list; do > if : condition to not continue; then > : what the loop does > fi > done >=20 > How about this half-and-half approach (actual code): >=20 > for _modular_conf in /etc/rc.conf.d/*.conf; do > if [ ! -f "$_modular_conf" ]; then > continue > fi > debug "Sourcing $_modular_conf" > . "$_modular_conf" > done >=20 > Of course, one's interpretation of the above syntax is conditional on mem= orizing that "!" is pronounced "not" (just as my previous syntax hinges on = memorizing that "||" is pronounced "or"/"else" -- allowing either syntax to= be read/interpreted with ease). >=20 > Just thought I'd share my experiences. Not everyone develops the same sty= le(9) for every language. Yeah Yeah! I agree its a very valid point but that is only about indenting= =20 for the most part. There isnt really a need for varience from the style=20 that is already in the script ;) Ill do the same type of things depending on the situation. I have also=20 been known to stretch the very fabric of time and space just to fit a=20 conditional statement to match style. ;) Think I am a little ADHD in the=20 sense that I am very picky about stuff matching. --=20 Regards, (jhell) Jason Hellenthal --boAH8PqvUi1v1f55 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) Comment: http://bit.ly/0x89D8547E iQEcBAEBAgAGBQJNx0gzAAoJEJBXh4mJ2FR+A34H/0sNU6MrngqH3sV/jAm8iXGD dI/lnD5THG5s8lx7BO39S8gwFu6Hrx5ac2Lylow6xmrE4h+iVJt+ej2835lzGjnl Z7UrJPPm/8jI89Vz8sbhl7LEluahth+sYbMl9lnVrRE489l/u7qakC5bUS0MvHcj hHXIM2fWfiVBc5SNzLdgxHdrm64/zR8y0LC+4H/EQyuGahi9/Q3+HxQALE1CETJS P5+qWIQDZky37GXcuE6Luq0egMvY/9UyC9Ym+ajO/p8zwg7zi2UcrQos73cZP0Fe VMiLdiai8tL578hkzCOsbEIf9MZS2AxMKnjSnw83oAsx9xKR3lVGjcemitt/Cqg= =4uMH -----END PGP SIGNATURE----- --boAH8PqvUi1v1f55--