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

Re: shell scripts.



Quoting Jameson Burt (jameson@mnsinc.com):
> > 
> > call me crazy, but after messing around with shell programming for a while, i
> > discovered perl.  i'm no major system programmer or admin or anything, but
> > why on earth would someone ever want to use some shell programming language
> > over perl?  especially since perl can run on almost any platform, so when
> > whatever shell you are programming for fades away or when you switch from
> > one platform to another, your perl scripts will live on.
> 
> Answering your last questiions first,
> yes perl runs on most every system, but so does the GNU bash shell.

can you run it on Vax too?  i personally hated programming on VMS, but
i was able to do it with Perl.  dunno much about compatibility of bash, so
i'm just asking.

> I tired recompiling my C-programs, so I rewrote my simple ones in
> shell scripts, which I run on both Linux and SunOS/Solaris.
> As for fading away, the original sh shell has been around for how many 
> decades? (at least 2 decades)

of course you're right that Bourne shell has been around for decades, i guess
i wasn't thinking about that one since i really don't know anyone who uses
that as their primary login shell.

> Still, perl is often already on other systems without going through 
> a package install.
> 
exactly, long before i learned how to install packages myself (still learning
actually), i was stuck with just ksh at my summer job.  i really did not like
that shell after getting used to bash at home on linux, so i switched to tcsh
which was the best they had available imho.  so then i couldn't use any
of the things that i'd just learned by working my way through the
"learning the bash shell" O'Reilly book.  PERL filled the gap for me, and i've
been using it ever since and loving it.

> You are unlikely to run perl as your login shell.

well, your example of bourne shell above would fall into this category too.
hmmm...i'd better get started on psh then :)

> One writes some one-liner shell programs for inclusion in .bashrc.

but the thing is, you can just add the perl command and put the one-liner
right there also, right?

> Since one already works with zher login shell, eg, bash,
> one feels more comfortable programming it.  That argument fails when
> you realize the csh shell was created for those used to C programming,
> yet csh works poorly for shell programming.
> 
it is entirely possible to feel comfortable using a shell, but uncomfortable
programming in that shell.  but ideally one would follow the other.

> Perhaps most importantly, perl does an enormous number of unix-like things
> in an un-unix like way: it puts all the tools in one tool called perl.
> One can more easily learn just the bash shell, or awk, or sed,
> then, in the unix way, connect them with pipes.
> Unfortunately, all these programs do not extend to all perl can do.
 
perhaps it's because i've programmed in C for a bit and i have a good memory,
but i didn't think that learning perl was so tough.  especially with that
great O'Reilly book as a guide.  i also do web programming as well, and i'd
much rather use perl for that than any shell language.

> Of course, for big programs one should use perl.
> I read a rule somewhere: "If the program is the size of a Makefile, 
> write the program in a shell; for larger programs, write it in perl."
> Indeed, if one doesn't start a new shell, then a small shell script running
> under the current shell runs more quickly than starting perl to run
> a perl script. But who worries about small unsummed computer times these days?
> 
yet another argument for writing psh :)

> If a person makes only the simplest of programs, zhe can spend less time
> learning a shell than learning perl.
> If a person writes at least a 20 line program once a week, 
> then that person would better spend zher time learning perl
> than learning the admitedly not-so-deep details of a bash shell.
> 
> In unix, we share a great deal in common: a shell, pipes, xterms.
> >From there, we diverge to other tools that differ, depending
> on our tasks but more depending upon our views: for example, get it done now,
> or be able to get future tasks done.
> As the flexible user seeks Debian over RedHat, 
> the same user chooses programming over gui tools, and
> the same future-oriented user might well choose Perl over Bash shell 
> programming.
> 
very good points, thanks for the discussion.

-James Pollard


Reply to: