Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Jan 2002 23:49:01 -0600
From:      "Mike Meyer" <mwm-dated-1012456142.0689af@mired.org>
To:        Bernie <Bernie_X@myrealbox.com>
Cc:        questions@freebsd.org
Subject:   Re: shells confusion
Message-ID:  <15442.17229.937600.658651@guru.mired.org>
In-Reply-To: <947431@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
Bernie <Bernie_X@myrealbox.com> types:
> 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. However, some of the more serious problems have been fixed in the
variants.

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

Because csh is better for interactive use than sh.

> also, why single user mode proposes /bin/sh as default?
> is there any particular reason for it?

Probably because no one has bothered to change it.

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

I'd agree with that, as Perl scripts often invoke commands, and one of
the design goals was to make it easy for shell programmers to
learn. It's not clear the latter is a *good* thing, but that's a
different thread.

> but the question is 'which shell' ...

Unix shells fall into three different classes: sh and variants, csh
and variants, and "other". As Charles pointed out, bash is by far the
most popular shell for interactive use. It picks up most of the nice
interactive features of csh, along with features from variants of csh
and sh.  However, not all systems come with bash, though they all come
with an sh variant.  An sh script should work fine in bash, but not
necessarily the reverse, because of the extra features.

Which leads to the conclusion: learn sh for scripting. It will be
applicable on all Unix systems, and everything you learn will be
applicable in bash, though there may be quicker or easier ways to do
certain things.

	<mike
--
Mike Meyer <mwm@mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

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?15442.17229.937600.658651>