From owner-freebsd-arch Wed Aug 21 8:53:27 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 890AB37B400 for ; Wed, 21 Aug 2002 08:53:24 -0700 (PDT) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8FB4443E6E for ; Wed, 21 Aug 2002 08:53:23 -0700 (PDT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.3/8.12.3) with ESMTP id g7LFrLFl023276; Wed, 21 Aug 2002 09:53:22 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Wed, 21 Aug 2002 09:52:52 -0600 (MDT) Message-Id: <20020821.095252.61131232.imp@bsdimp.com> To: nbm@mithrandr.moria.org Cc: rizzo@icir.org, arch@FreeBSD.ORG Subject: Re: ugliness in rc.* scripts From: "M. Warner Losh" In-Reply-To: <20020821074819.GA58163@mithrandr.moria.org> References: <20020820232538.A53816@iguana.icir.org> <20020821074819.GA58163@mithrandr.moria.org> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message: <20020821074819.GA58163@mithrandr.moria.org> Neil Blakey-Milner writes: : On Tue 2002-08-20 (23:25), Luigi Rizzo wrote: : > Hi, : > in various rc.* scripts we have multiple instances of : > constructs like this: : > : > case ${some_config_variable} in : > [Mm][Ii][Xx][Ed]_[Cc][Aa][Ss][Ee]_[Ss][Tt][Rr][Ii][Nn][Gg]) : > .... : > : > which is not the most desirable thing in terms of readability. : > This would be easily fixed by moving /usr/bin/tr to /bin/tr (statically : > linked) and doing : > : > tolower() { : > echo `tr A-Z a-z <<_EOF : > $*` : > } : > : > case `tolower ${some_config_variable}` in : > mixed_case_string) : > ... : > : > : > (btw, i am not sure why, in the above example the _EOF delimited : > is not required nor i can find any place to put it without being : > processed as stdin. Perhaps a bug in /bin/sh ?) : > : > Anyways, should we go for this ? I believe our scripts would be : > greatly improved. : : I believe the argument for 'case' and those mixed case strings is that : it doesn't spawn a process, whereas "if [ " did at the time. Using : 'echo' and 'tr' and two ``'s will spawn four shells (or something like : that). Why not just have case -i ${some_config_variable} in to do the case folding. This would be a backwards compatible extension: The syntax of the case command is case word in pattern) list ;; ... esac where word is singular, not plural (like in the for loop syntax). Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message