From owner-freebsd-arch Wed Aug 21 0:47: 2 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 DF57C37B400 for ; Wed, 21 Aug 2002 00:46:59 -0700 (PDT) Received: from infinitive.futureperfectcorporation.com (infinitive.futureperfectcorporation.com [196.25.137.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id DAF4743E4A for ; Wed, 21 Aug 2002 00:46:57 -0700 (PDT) (envelope-from nbm@gerund.futureperfectcorporation.com) Received: (qmail 79150 invoked by uid 0); 21 Aug 2002 07:46:47 -0000 Received: from gerund.futureperfectcorporation.com (196.25.137.65) by infinitive.futureperfectcorporation.com with DES-CBC3-SHA encrypted SMTP; 21 Aug 2002 07:46:47 -0000 Received: (qmail 58237 invoked by uid 1001); 21 Aug 2002 07:48:19 -0000 Date: Wed, 21 Aug 2002 09:48:19 +0200 From: Neil Blakey-Milner To: Luigi Rizzo Cc: arch@freebsd.org Subject: Re: ugliness in rc.* scripts Message-ID: <20020821074819.GA58163@mithrandr.moria.org> References: <20020820232538.A53816@iguana.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020820232538.A53816@iguana.icir.org> User-Agent: Mutt/1.3.27i Organization: iTouch Technical and Architectural Services X-Operating-System: FreeBSD 4.3-RELEASE i386 X-URL: http://mithrandr.moria.org/nbm/ 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 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). Neil -- Neil Blakey-Milner nbm@mithrandr.moria.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message