[96494] in RedHat Linux List

home help back first fref pref prev next nref lref last post

Re: BASH scripting question

daemon@ATHENA.MIT.EDU (Thomas Ribbrock \(Design/DEG\))
Tue Oct 27 14:17:47 1998

Date: Tue, 27 Oct 1998 18:23:32 +0000
From: "Thomas Ribbrock \(Design/DEG\)" <argathin@INAME.COM>
To: RedHat List <redhat-list@redhat.com>
Mail-Followup-To: RedHat List <redhat-list@redhat.com>
In-Reply-To: <Pine.LNX.3.95.981027082049.17347B-100000@homer.giddens.com>; from John H Darrah on Tue, Oct 27, 1998 at 08:40:00AM -0800
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

John H Darrah writes:
> On Tue, 27 Oct 1998, Cameron Simpson wrote:
> >=20
> > Step 1: Never write for "bash" (or the other
> >         dialects like zsh ksh etc) if you can
> >         write for plain vanilla Bourne shell (sh).
> >=20
>=20
> WRONG!!  This is just another one of these
> religious statements that confuse many newcomers.

Ok, let's make it less religious and back it up... :-)
Besides: The original statement did say "if you can"... ;-)

=20
> You write in whatever shell language you need to
> do the job, using *ALL* the features that make the
> task easy to write and maintain.

If you intend to make the resulting script available to the whole Unix
community or if you need to use the script across several different Unix
platforms, your best bet is to write plain sh. If you intend to use the
script on your machine (and maybe similar machines, i.e. same platform, same
setup), you might consider using bash, zsh or ksh.
Writing shell scripts in csh or tcsh is generally not recommended by
experienced shell script writers. The reasons for this can be found here:

http://www.primate.wisc.edu/software/csh-tcsh-book/csh-whynot

Besides: In my opinion, if the job you want to do with the script is too
complicated for a simple sh script, you might as well consider using a
"real" scripting language like e.g. Perl.


> What if you are using csh...? Are you still
> supposed to make it compatible with sh...?

Here you're about to confuse newbies... The shell in which one writes his
shell scripts has absolutely nothing to do with the shell one uses for every
day's work. As a matter of fact, I myself use tcsh on both my SunOS/Solaris
machines at work and on my Linux box at home - but I write all my shell
scripts in sh. I used to use csh syntax, but switched a good while ago, as I
think sh is the better choice (see URL given above).


> Bash is
> no different than awk, perl, sed, csh, python
> which are all scripting languages.=20

bash is very different from csh - see URL above... ;-) And I would call
neither awk nor sed a scripting language as such, though that might be
argued.


> If you are a software developer that *Needs* to be
> compatible with many different Unix systems, then
> it would be a good idea, but *Not* absolutely
> necessary.

This is wrong. If it *needs* to be compatible, it needs to be written in a
scripting language which has a close to 100% probability to exist on all
targeted platforms. sh is a good bet for this. (no, not even Perl is
available on *that* many systems... ;-) )

=20
Just my =A30.02,

Thomas
--=20
                    "Look, ma, no obsolete quotes!"

     Thomas Ribbrock | http://www.bigfoot.com/~kaytan | ICQ#: 15839919
   "You have to live on the edge of reality - to make your dreams come true=
!"


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post