Date: Sun, 09 Sep 2007 09:34:39 -0700 From: Garrett Cooper <youshi10@u.washington.edu> To: Giorgos Keramidas <keramida@ceid.upatras.gr> Cc: Grant Peel <gpeel@thenetnow.com>, freebsd-questions@freebsd.org, Gary Kline <kline@tao.thought.org> Subject: Re: csh if..then delhema. Message-ID: <46E4209F.5090702@u.washington.edu> In-Reply-To: <20070909131721.GA1859@kobe.laptop> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
Giorgos Keramidas wrote: > On 2007-09-09 08:57, Grant Peel <gpeel@thenetnow.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46E4209F.5090702>