On Sun, Jul 09, 2006, Amos Shapira wrote about "Re: good book in tcsh shell
programming.":
> 1. Scriptability - for this I think that learning what a standard
> "Bourne Shell" will accept is an important step towards writing
> portable scripts (or just being able to move from one environment to
> another, e.g. from Debian Sid to Solaris 8).
The issue is that the original bourne shell is missing a lot of features
which makes scripting in modern shells (like zsh or bash) easy and fun.
For example, I wonder how many on this list remember that the original
Bourne Shell did not have functions; It also did not have integers, and
to count or calculate you needed to use external commands like "expr" and
"seq". Another example I mentioned in a previous mail is that the Bourne
shell did not even have a way to print a message: you needed to use the "echo"
command, which itself had different syntax on System V and BSD variants of
Unix.
In short, I do agree that knowning what the original bourne shell contained
is important, especially for writing portable scripts (like autoconf). But
for day to day scripting, there's no reason to limit yourself this way.
I use zsh's advanced filename globbing, arrays, and other features extensively
in the scripts I write for my own use, for example.
> 2. Interactive use - use whatever you like.
But this leads to what happens in the Technion: people used tcsh because
they liked its interactivity, and this lead them to use tcsh for scripts,
which sucks! So you should pick a shell which is good both for interactivity
and scripting.
In fact, this issue is related to one of the things I like best about the
Unix philosophy: scripting is just automating what you do interactively.
If you know how to do something interactively, you already know how to
script it - just take the commands and stick them in a file. This is a
far-cry from what happens in the Windows world where there's a huge abyss
between the way you do things interactively (using a mouse) and how you
script them (using VB or COM or whatever).
I would like to keep this gap in Unix as small as it ever was, which is
why for most uses I use the same shell interactively and for my scripts,
and why I continue to prefer command line utilities to GUI applications.
> it became available.
> I'm pretty sure that csh was invented in order to cater for the
> interactive part of the equation and wasn't quite meant to be used for
> scripting.
I understand differently. As I understand, Bourne Shell and Csh were both
created around the same time, independently (the former at Bell Labs, the
latter at Berkeley), to replace Unix's first attempt of shell. They had
completely different designs and emphases, but neither was meant to be
more interactive than the other. Later, as CRT terminals became common
(hey, we're talking ancient history here :-)), both shells were considered
outdated, and replacements were written for both: David Korn of Bell Labs
designed ksh to replace the Bourne Shell, and in CMU "tcsh" was written
to replace csh. ksh inherited sh's style, and tcsh inherited csh's style,
so most objections many people had for csh scripting remained true also
for tcsh.
> >It is worth knowing which shell features are specific to a certain shell
> >and which are the original bash, e.g., for writing portable shell scripts,
>
> See? You seem to have it mixed up already :) You meant "the original
> Bourne shell" didn't you?
Yes, sorry for the Freudian slip :-)
> Read the Wikipedia link I sent in my first response - the Bourne shell
> was enhanced a bit since it was first introduced (for a start - it was
> converted from assembly to B then to C :). Also the echo command is
> supposed to be a built in command with syntax defined as part of the
> shell's standard syntax.
I just checked, and in Solaris 5.8, "echo" (a /bin/sh builtin) and "/bin/echo"
both do this:
$ echo -n hi
-n hi
$
With GNU/Linux's /bin/sh+echo or /bin/echo you get
$ echo -n hi
hi$
> >A standard is needed, yes. But the 30 year old Bourne shell is too old...
>
> It's not that old. It was updated since its first introduction.
Where is this update defined?
--
Nadav Har'El | Sunday, Jul 9 2006, 13 Tammuz 5766
[EMAIL PROTECTED] |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |This signature was intentionally left
http://nadav.harel.org.il |boring.
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]