From owner-freebsd-questions Sat Jan 26 1:49:40 2002 Delivered-To: freebsd-questions@freebsd.org Received: from gull.prod.itd.earthlink.net (gull.mail.pas.earthlink.net [207.217.120.84]) by hub.freebsd.org (Postfix) with ESMTP id 033D137B404 for ; Sat, 26 Jan 2002 01:49:36 -0800 (PST) Received: from dialup-209.245.132.233.dial1.sanjose1.level3.net ([209.245.132.233] helo=blossom.cjclark.org) by gull.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16UPSj-0001iM-00; Sat, 26 Jan 2002 01:49:29 -0800 Received: (from cjc@localhost) by blossom.cjclark.org (8.11.6/8.11.3) id g0Q9nO916438; Sat, 26 Jan 2002 01:49:24 -0800 (PST) (envelope-from cjc) Date: Sat, 26 Jan 2002 01:49:24 -0800 From: "Crist J. Clark" To: "Brian T.Schellenberger" Cc: Cliff Sarginson , freebsd-questions@FreeBSD.ORG Subject: Re: shells confusion Message-ID: <20020126014924.I14394@blossom.cjclark.org> References: <20020126020430.P175-100000@BLAST> <20020126035658.GC1290@raggedclown.net> <20020126070114.C8FD93FE5@i8k.babbleon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020126070114.C8FD93FE5@i8k.babbleon.org>; from bts@babbleon.org on Sat, Jan 26, 2002 at 02:01:14AM -0500 X-URL: http://people.freebsd.org/~cjc/ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, Jan 26, 2002 at 02:01:14AM -0500, Brian T.Schellenberger wrote: > On Friday 25 January 2002 10:56 pm, Cliff Sarginson wrote: > > On Sat, Jan 26, 2002 at 02:18:16AM +0200, Bernie wrote: > > > hi, > > > > > > i'm planning to learn shell programming but i'm not sure > > > on which one to choose... > > > > > > i've been reading in the 'FreeBSD unleashed' that people > > > wanting to do shell programming should stay away from > > > c-shell as it's realy good for interactive, but very bad > > > for scripts. is this true? > > > > Yes and Yes. > > I would not agree with this at all. I find csh much more readable/sensible > than /bin/sh for interactive use. Spaces don't matter; if statements are > vastly more readable, etc. > > Now for really complex "shell" programming I use perl, but C shell is, IMHO, > a lot easier to write and read than /bin/sh. Ack! > There *is* one severe problem with csh that I know of: the quoting rules are > just plain broken; if you get into nested quotes things get screwy quickly. > I work around this with > > set Q = "'" > set QQ = '"' > set $S = '$' > > at the top of my scripts, but I freely admit that it is completely stupid > that I should have to do so, but writing > > if ($a > 4) then > echo "$a is greater than 4" > endif > > vs. > > if [[eval $a > 4]];; > echo "$a just tell me that's more readable. I dare you." > fi > > (or whatever--the syntax is inexact) it just seems to be to be no contest: > csh wins, hands-down. Uh, if [ $a -gt 4 ]; then echo "$a is greater than 4. This is quite readable." fi > Plus the convenience of > > if ($a =~ foo*) > > vs. (as far as I can tell) having to do a switch just for string tests -- > again, csh is the scripting shell for me. if expr "$a" : 'foo.*' >/dev/null; then The thing is that sh(1) can do a ton of stuff csh(1) simply cannot. Try to do this, command 2>err.file In csh(1). Or try, command1 | while read WORD REST; do ... done | command2 In csh(1). [snip] > > /bin/sh is the Unix common denominator of shells, so scripts > > get written in it. They are not written in csh, because as > > stated csh script is unusable for all practical purposes. > > unusable??????? What on earch are you talking about? > > I have many dozens of quite usable csh scripts. And they are readable, too. There are just so many things you simply cannot do in any sane way with csh(1) like the few I eluded to above. -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message