From owner-freebsd-questions@FreeBSD.ORG Sun Sep 9 16:35:25 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB13B16A421 for ; Sun, 9 Sep 2007 16:35:25 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout5.cac.washington.edu (mxout5.cac.washington.edu [140.142.32.135]) by mx1.freebsd.org (Postfix) with ESMTP id AB7B513C45E for ; Sun, 9 Sep 2007 16:35:25 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.33.7] (may be forged)) by mxout5.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW07.06) with ESMTP id l89GYgHf011814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 9 Sep 2007 09:34:42 -0700 X-Auth-Received: from [192.168.10.45] (c-24-10-12-194.hsd1.ca.comcast.net [24.10.12.194]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW07.03) with ESMTP id l89GYeNn029490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 9 Sep 2007 09:34:41 -0700 Message-ID: <46E4209F.5090702@u.washington.edu> Date: Sun, 09 Sep 2007 09:34:39 -0700 From: Garrett Cooper User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Giorgos Keramidas References: <000801c7f274$6fae71e0$6501a8c0@GRANT> <20070909020657.GA4912@kobe.laptop> <46E367F7.6060705@u.washington.edu> <20070909081927.GB98684@thought.org> <006901c7f2e1$0067bb30$6501a8c0@GRANT> <20070909131721.GA1859@kobe.laptop> In-Reply-To: <20070909131721.GA1859@kobe.laptop> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 5.3.3.310218, Antispam-Engine: 2.5.2.313940, Antispam-Data: 2007.9.9.91824 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' Cc: Grant Peel , freebsd-questions@freebsd.org, Gary Kline Subject: Re: csh if..then delhema. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Sep 2007 16:35:25 -0000 Giorgos Keramidas wrote: > On 2007-09-09 08:57, Grant Peel wrote: > >> Thanks for the input gentlemen, >> Interesting to that the question was posted by G(rant) and then >> answered by G(ary), G(arrett) and G(iorgos)! (what are the odds!). >> > > Haha :) > > >> Anywho, I am busily converting the script to perl as per the >> suggestions. I use tcsh rarely, had I of known the quirks I woul shave >> done it in perl from the beguining. >> >> As for Garrett's case method, it didnt work. Created a "case: Too many >> arguments." error. Perhaps because it itself is nested in a 'foreach' >> statement. >> > > `foreach' is a csh construct. If you copied the case/esac code posted > by Garrett, then it wouldn't work. The syntax used by Garrett was for > the Bourne shell (hence the /bin/sh reference above case). > > If you are going to convert everything to /bin/sh, you may as well > convert it to Perl unless there is some very good reason to use only > the pretty minimal data-structures supported by the Bourne shell > (i.e. because you want to run the script in environments where Perl > may be too much to require). > > - Giorgos > > 'for {variable_name}' can replace foreach in Bourne Shell. If you can provide more information, like what you're doing with the shell script, please let us know. I'm a big fan of Perl, in particular in cases where text parsing doesn't cut it in Bourne shell / with the simple utilities (i.e. cut(1), sed(1), etc), but in an effort to try and avoid having Perl installed on every single machine, I provided the previous Bourne shell example. Cheers, -Garrett