Date: Sat, 26 Jan 2002 15:41:52 -0500 From: Jim Conner <jconner@enterit.com> To: Brian T.Schellenberger <bts@babbleon.org> Cc: Cliff Sarginson <cliff@raggedclown.net>, freebsd-questions@FreeBSD.ORG Subject: Re: shells confusion Message-ID: <5.1.0.14.0.20020126153803.049c9008@mail.enterit.com> In-Reply-To: <20020126070114.C8FD93FE5@i8k.babbleon.org> References: <20020126035658.GC1290@raggedclown.net> <20020126020430.P175-100000@BLAST> <20020126035658.GC1290@raggedclown.net>
index | next in thread | previous in thread | raw e-mail
At 02:01 01.26.2002 -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.
>
>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
Then just do:
if [ $a -gt 4 ]
then
echo "$a is greater than 4"
fi
>(or whatever--the syntax is inexact) it just seems to be to be no contest:
>csh wins, hands-down.
Its all in the eyes of the beholder
>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.
This is true!
>EXCEPT that on non-BSD systems, csh isn't necessarily always avaialble.
That's probably the crux of the whole conversation so far. However, I do
believe this is a good place to state the korn shell (ksh88) is a default
shell on Solaris. Heh, just a note and stuff. Only 1239878912730921 Unix
flavors to go.
>Other than that, when push comes to shove, this is more a matter of personal
>opinion than any inherent superiority of one shell over another.
>
>(Well, bash or zsh, which postdate /bin/sh and csh might be better and of
>course tcsh is better than original csh . . . but /bin/sh is really terrible
>for scripting if you ask me, never mind that it's widely used.)
>
> > > also, looking into the scripts in /etc, i see a line on the
> > > top saying 'bin/sh'. so are they all written in 'sh' and
> > > not csh ? if so, why freebsd comes with csh as default?
> >
> > /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.
Yeah. I've heard csh is a goodlanguage....just never learned it. Never
had a desire to. Everyone who does, though, afaik, loves it.
> >
> > You will be opening up another war here on the subject
> > of which shell should be the default user/root shell.
> > You may notice that "root" has two entries on the system,
> > one as "root" with csh as it's shell, and one as "toor"
> > with sh as it's shell.
> >
> > By the way, csh = tcsh on FreeBSD, I don't know if there
> > is a "pure" csh around anymore. The huge difference between
> > csh as was, and tcsh, being that tcsh is usable (ducks).
>
>The main difference is the interactive history. Lots of other bells &
>whistles, but csh was usable, too. A huge, huge improvement for both
>interactive and scripted use over the original /bin/sh.
>
>
> > In summary, *not* the csh for scripts.
> > Learn sh for scripts.
>
>I agree that you might have to (unfortunately) learn a mininum of sh for
>scripts, because the vast majority of scripts are written in it, but it's
>definately a matter of opinion whether they *should* be written in it.
>
> > Use bash or tcsh for your day to day interactive use.
> >
> > I think most people will give you more or less the same
> > advice, the choice of tcsh or bash will mostly depend on
> > their personal Unix backgrounds as much as anything else.
>
>--
>Brian T. Schellenberger . . . . . . . bts@wnt.sas.com (work)
>Brian, the man from Babble-On . . . . bts@babbleon.org (personal)
> http://www.babbleon.org
>
>-------> Free Dmitry Sklyarov! (let him go home) <-----------
>
>http://www.eff.org http://www.programming-freedom.org
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-questions" in the body of the message
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.6 (MingW32)
Comment: For info see http://www.gnupg.org
- Jim
Philosophy is for those who have nothing better to do than wonder
why philosophy is for those who have nothing better to do than...
mQGiBDxAonQRBACx+sz63XIeo5uTzc5n3Elf7Y13VVZGIM8Pilp3LpBu70/nGQPu
anKYDB3aa1U5cfl+cTK5lOtUxN7Fu0a2Uv0ApIlC1qA8CjDZqlu7PDETFTVrpfGZ
007BHO+y2Y0bVsaMPXdnhbi0LAFSIkNYRhyzNWbAkeMsgA+i2k9hcnhvVwCgor7P
nflXu7xWN9aWt3RJBzqdUR0EAK/1obJFUKQSK39cKTMPQ4u2UPflbS5dJ871naG5
xBAlQAjHAXT+f/fXE2ezrSyoQnlOD4kVbPN3gB5UT5mWoylPuf5W7WmupthVzUUN
IsPDbmAT0YOwgALCfJVS+PrPCC8opmZhTjQBwgxCSY9MWULlzN3X2EEDqWIxluYb
o5W/BACgHA+aFOO5F03QZBBScWn9YBS1ZH3sSlkQEK5RiwGXLmHJacOjn660SbOE
MEKPDLDDJu/vt1fb3VRLc/fPB3aB7fi4XagfobaHbID9rx55slLhD94Q+5JuJSfg
DyJ+vVSA1k+9/SynflPl0QY5zt0xSM+0CBg9mBg2bPyuGsDwXLQ5SmltIENvbm5l
ciAoTmV3IEdQRyBLZXkgZm9yIFNuYWZ1WCkgPGpjb25uZXJAZW50ZXJpdC5jb20+
iFcEExECABcFAjxAonQFCwcKAwQDFQMCAxYCAQIXgAAKCRDmnFh04+r7ZdFiAKCh
t8Vq7ZT6qvh9Dzn0lzZXRM4gywCfSLU/H5UHX7ZoxapfDs9pLxEEZeO5Ag0EPECj
chAIAIsdwiPqW8IsumvpXu59qkfsi4H2nofxvbhMDiapEhgloydehNQOEiHwC/O1
a06PjUmNRLRdK88kjy99R84ILbWUJZUclQB2LcjlttnrIG/FzCMxoLTKOeOCJk8N
ONswBdJdcf/XqbWJBTs/MXeNf4rmShYi6WJ5+jc1IE5PXGf4SR/9bz2r+/GESlrX
tAoNtWl5a/NUxb6b0hR6zU9Y6oO1vpDDJNbcV9mafdYhsvoFYdD2c6JF+JoN+FHR
tEP3k6leYwQ5P0kuUQNgWdWNWZfBq1tQDBfhg1/AV0JBzamyJfd0prFmtUEemKx4
haDsOoT4gLSPNTqSsyDt6TNLtGMAAwUIAINeot1FVpree5bvhy3xL+Pr1UGb++DM
b8Qeer6ERkVQNx7YoU8hfpqOwvEQMyfb9s6HPfSWRUfQRF+g+9ohPgYkH+1nqH3V
PtGSw1kgLOqxZQTVPEcAMhSflt9LSJETIQQByKKh1e5RvOuApwBFmQq3syRhzqv/
j2b6t3IqAB9WR5TnoYkdUtTWM9MGubiFl5B9uH5EHWAlFF8h760U7Xp9m1J3qTyH
EJqjfGj2SP2DK5cisuWOWdPy5aSqT7ZKrcKeSTDUyiHclI1ygFHue8oO0HXqrs+k
KjFdRqIKnzfY9gW/b/6gLHhBDV6BoA9w6+1Y9egOByRcVonE8zY/xMeIRgQYEQIA
BgUCPECjcgAKCRDmnFh04+r7ZcyDAJ4ogYX7W4u8g+QJsksyL4Ld+dObCwCfU7hB
7I3ZgTsYwP6mr5RPjkH5PG8=
=QOu8
-----END PGP PUBLIC KEY BLOCK-----
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5.1.0.14.0.20020126153803.049c9008>
