[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: UNIX shells - Bourne and C



Bruce Park <bpark79@hotmail.com> [2002-11-10 16:33:19 -0500]:
> 
> After doing some research, I found out that ash is a clone of a bourne 
> shell from BSD.

Yes.  But it is a modern clone and has all of the modern features and
is very standards conforming.  But it is not the old Bourne shell.

> I was using this last night and I really couldn't find anything that
> differs from the real shell.

Okay, now we get into existentialism.  What is real?  And besides, if
you are asking these questions then we both know you are just
beginning.  As a beginner you should not be able to tell the
difference between the shells.  The differences are subtle and you
would need to be more expert in the shells before you ran into the
differences.

> Now, what can I do about the C shell and the Korn shell?  Are those
> also not free?

The C-shell is free.  On debian you can install either it or tcsh or
both.  If you only have one of them that one will be the csh.  If both
then the bsd-csh will be the csh.

  apt-cache show tcsh
  apt-cache show csh

The Korn shell is not free.  At one time you could buy source from
AT&T by an anonymous uucp connection for IIRC $300 and we did that.
Anonymous uucp, ah, those were the days.  Not!  In any case there is a
ksh clone called pdksh the public domain ksh.  Having used ksh a lot I
find that pdksh is not quite the same as the real ksh from a command
line shell point of view.  But I don't use it much anymore in favor of
bash.

  apt-cache show pdksh

> I'm doing a lot of shell scripting and people are saying that C
> wasn't designed for it.

Well, it [C-shell] was designed for it.  But the designers failed
severely and have been bearing the brunt of the frustrations of the
net for problems with the design ever since.  I recommend you don't
use it for scripting.  It will frustrate you and annoy your users.
Even if you don't see the bugs your users will.  Messages like
"toshort: out of space" mean someone has an enviroment variable longer
than the static buffer size and other cryptic problems.  (That is from
memory and I probably got it wrong but you get the idea.)

[When I last used csh I thought it was the best command line shell for
paper terminals that I had ever used.  Specifically you had all of the
command numbers there on paper ready for you to repeat whenever you
wanted.  That was in the late 1980's when paper terminals were still
in vogue.  But times have changed.]

> I'm sure they are right because I'm reading about it and it says
> that bourne shell scripts are the best since they run faster than
> C.

They probably meant faster than C-shell, not faster than C the
compiled language.  They have similar names and share a small amount
of syntax but are not otherwise more or less related than bash is to
the C compiled language.  It will only confuse people to call C-shell
C, as in the compiled language.

But speed of shell execution is generally not important.  Pay no
attention to those arguments.  That is not a reason to use one shell
over another.  I would optimize your time of writing the program over
execution time.  I would avoid csh because it has frustrating
limitations.

> In reality, I problably would use Perl to do everything but right
> now, the focus is on learning each individual shell to see how and
> why they differ.

A worthy goal.  Install all, play, learn.

As long as you are learning you might want to look into 'ruby'.  Add
it to your list.  It is similar to perl in many ways but with a clean
syntax and it is very object oriented.  Ruby is coming as a new wave
to the interpreted programming language scene.  Do a google search and
you will find many articles and programming tutorials on the web.

  apt-cache show ruby

Enjoy,
Bob

Attachment: pgpv289nqtK1t.pgp
Description: PGP signature


Reply to: