Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jan 2002 04:56:58 +0100
From:      Cliff Sarginson <cliff@raggedclown.net>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: shells confusion
Message-ID:  <20020126035658.GC1290@raggedclown.net>
In-Reply-To: <20020126020430.P175-100000@BLAST>
References:  <20020126020430.P175-100000@BLAST>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

> 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.

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).
 
> also, why single user mode proposes /bin/sh as default?
> is there any particular reason for it?
> 
Well it is probably true to say that most (all) Unix users 
know /bin/sh, not all of them know csh. Again it is the
lowest common denominator I guess is the reasoning here.

> i'm a bit confused on which shell to pick from programming.
> also i've been thinking of perl, but for the moment i think
> i've got to learn at least how to do basic shell programming,
> not only to write programs, but also to understand scrips that
> come with the system.
> 
Leave perl alone for now and learn shell programming.
There are a few shells that are super-sets of /bin/sh, notably
the Korn shell and the Bash shell. Bash is the one I would
personally advise you to use. You need to install it from
the ports first. 

> but the question is 'which shell' ...
> 
> any advice on this matter will be appreciated.
> 
In summary, *not* the csh for scripts.
Learn sh for scripts.
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.

-- 
Regards
Cliff



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020126035658.GC1290>