[comp.unix.wizards] Re^2: Should ``csh'' be part of the System V distribution?

kimcm@ambush.UUCP (Kim Chr. Madsen) (05/17/88)

To my experience, the following observations holds true here.  We are
running System V, allthouh most of us comes from a BSD environment.
We have /bin/sh, /bin/csh, /bin/ksh and a /usr/bin/vsh on-line.  Users
wants to use the csh as their interactive shell, using sh as their
tool for making scripts speculating whether ksh is better than csh for
interactive use, but settles with csh since it is known in depth, and
nobody wants to touch the vsh.

And of course the Bourne shell and the C-shell is the only two shells
with a large user base and therefore more PD scripts, and they're
faily standard although the Bourne shell is a bit more standard than
the C shell.

Pros and cons of the shells (subjective opinion):

Bourne Shell (System V Version):
	+ Fast execution of scripts
	+ Easy language conception
	+ Easy file-descriptor manipulation ( 1>a 2>b 3>&1 etc.)
	+ Functions (added modularity of scripts)
	- No easy alias mechanism (functions are inadequate)
	- No history mechanism
	- Offers only a one-time start-up script (.profile (/etc/profile))

C Shell:
	+ History mechanism with redo and history manipulation.
	+ Superior interactive automatic scripts (.cshrc, .login & .logout)
	+ Good aliasing mechanism
	- Bad programming interface (non-intuitive).
	- Slow execution of scripts
	- Missing functions
	- Bad file-descriptor manipulation.

Korn Shell:
	+ Superior history mechanism with (vi/emacs interface available)
	+ Almost Bourne Shell compatable language plus extensions
	+ Aliasing mechanism (although not so intuitive as the csh)
	- Inadequate automatical scripts (.kshrc, .profile)
	- Does not have a large user base
	
Visual Shell:
	+ Completely different from traditional shell types
	+ Easy to learn to use (unless you're used to traditional shells)
	- Troublesome to get to do anything advanced easy
	- Slow execution and building of commands
	- Offers no programming interface (relies on another shell)	

Kim Chr. Madsen, AmbraSoft A/S, Rojelskaer 15, DK-2840 Holte (Denmark)
UUCP: kimcm@ambush.dk, PHONE: +45 2424 111, FAX: +45 2423 090

Your old men shall dream dreams, your young men shall see visions. 
					-- The Bible, Joel, II:28

gwyn@brl-smoke.ARPA (Doug Gwyn ) (05/19/88)

In article <762@ambush.UUCP> kimcm@ambush.UUCP (Kim Chr. Madsen) writes:
>Bourne Shell (System V Version):
>	- No easy alias mechanism (functions are inadequate)

How so?  Functions are more general than aliases.

>	- No history mechanism

One can be added easily enough.  We have one in ours.  You can also do
this much better using a separate process, for example "mux" running in
your terminal.

>	- Offers only a one-time start-up script (.profile (/etc/profile))

You can obtain .logout yourself by planting an exit trap in your .profile.
Csh sources .login and .cshrc in the wrong order, sources .cshrc even for
scripts, and the hardwired names are inflexible.  BRL's shell uses the
ENV=file option to trigger our equivalent of .cshrc.

dhesi@bsu-cs.UUCP (Rahul Dhesi) (05/19/88)

In article <7924@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>)
writes:
>Csh ... sources .cshrc even for
>scripts...

On 4.3BSD systems, a script that begins with "#! /bin/csh -f" will be
executed by csh without invoking .cshrc.  Note that csh was designed
for 4.xBSD.  This mechanism works well and gives the user a choice.
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi

gwyn@brl-smoke.ARPA (Doug Gwyn ) (05/20/88)

In article <3141@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
>In article <7924@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>)
>writes:
>>Csh ... sources .cshrc even for scripts...
>On 4.3BSD systems, a script that begins with "#! /bin/csh -f" will be
>executed by csh without invoking .cshrc.  Note that csh was designed
>for 4.xBSD.  This mechanism works well and gives the user a choice.

It most certainly does NOT work well!  In practice one ALWAYS needs
to put the -f there, because otherwise there is absolutely no way to
control the behavior of the script.  This is similar to the standard
imported-IFS problem (fixed in BRL sh).

ron@topaz.rutgers.edu (Ron Natalie) (05/21/88)

> Bourne Shell (System V Version):
>	- No easy alias mechanism (functions are inadequate)
Why, seem to wholly sufficient for me.
>	- Offers only a one-time start-up script (.profile (/etc/profile))
Does have .logout compatibility, but it is hidden in the "trap" command.

>C Shell:
>	+ Superior interactive automatic scripts (.cshrc, .login & .logout)
But no system wide .login like /etc/profile.

Of course there are some shells, tcsh and the like you've left out.
However, there is the BRL Bourne Shell, which is the System V R2
shell modified by Doug Gwyn and myself which features:

Full VR2 /bin/sh features (shell functions, etc...)
~user expansions.
Emacs-like command editing (keys are reprogrammable)
Additional startup file (like .cshrc).
Anti-control-D mode (forces you to use logout or exit).
Job Control if you're system supports it.
Optional timeout of idle sessions.
Optional forces superuser prompts to have (#) in them.

-Ron

kre@munnari.oz (Robert Elz) (05/21/88)

In article <7941@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes:
> In article <3141@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
> >On 4.3BSD systems, a script that begins with "#! /bin/csh -f" will be
> 
> It most certainly does NOT work well!  In practice one ALWAYS needs
> to put the -f there,

Depends what the intended use of the script is.  If you were writing
something for just your own use, being able to write it using the same
environment that you would use to just type the commands to the shell
must surely be easier (ie: the script uses all your aliases, variables,
etc, as imported from .cshrc).

Then surely no-one sane would actually write a csh script to be used
for anything more than personal uses, its programming language is so
foul (only just a bit better than the v6 shell it replaced) that you'd
have to be insane.

So, almost no csh script should need the -f ...

kre

stan@sdba.UUCP (Stan Brown) (05/24/88)

> In article <7941@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes:
> > In article <3141@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes:
> > >On 4.3BSD systems, a script that begins with "#! /bin/csh -f" will be
> > 
> > It most certainly does NOT work well!  In practice one ALWAYS needs
> > to put the -f there,
> 
> Depends what the intended use of the script is.  If you were writing
> something for just your own use, being able to write it using the same
> environment that you would use to just type the commands to the shell
> must surely be easier (ie: the script uses all your aliases, variables,
> etc, as imported from .cshrc).
> 
> Then surely no-one sane would actually write a csh script to be used
> for anything more than personal uses, its programming language is so
> foul (only just a bit better than the v6 shell it replaced) that you'd
> have to be insane.
> 

	Interesting, I know a real time indutstrial control
	supervisory system where a large part > 20 % of the code is
	csh scripts (Please note that I didn't say I like it, just
	that I knew it existed !).


-- 
Stan Brown	S. D. Brown & Associates	404-292-9497
gatech!sdba!stan
	"vi forever"

allbery@ncoast.UUCP (Brandon S. Allbery) (05/31/88)

As quoted from <2132@munnari.oz> by kre@munnari.oz (Robert Elz):
+---------------
| Then surely no-one sane would actually write a csh script to be used
| for anything more than personal uses, its programming language is so
| foul (only just a bit better than the v6 shell it replaced) that you'd
| have to be insane.
+---------------

Umm, Robert, have you told this to Richard Stallman?  Last I saw, just such
a script was provided to build Gnu Emacs (and the Makefile does not do
everything that typing "MAKE" to a 4.xBSD csh does).

Or was that intended to be a comment about the Free Software Foundation
and/or RMS?  ;-)
-- 
	      Brandon S. Allbery, moderator of comp.sources.misc
	{well!hoptoad,uunet!marque,cbosgd,sun!mandrill}!ncoast!allbery
Delphi: ALLBERY						     MCI Mail: BALLBERY

dkc@hotlr.ATT (Dave Cornutt) (06/02/88)

In article <7828@ncoast.UUCP> allbery@ncoast.UUCP (Brandon S. Allbery) writes:
 > As quoted from <2132@munnari.oz> by kre@munnari.oz (Robert Elz):
 > +---------------
 > | Then surely no-one sane would actually write a csh script to be used
 > | for anything more than personal uses, its programming language is so
 > | foul (only just a bit better than the v6 shell it replaced) that you'd
 > | have to be insane.
 > +---------------

Hmmm... I must be insane.  I have written several things in csh script, and
I find it considerably easier to write than sh/ksh script.  I actually
prefer being able to use C-style operators instead of having to go look
up obscure "test" operators all the time.

Methinks it's a matter of personal preference, like choice of editors.
(Actually, my perference is to use ksh for interactive use and csh
for scripts.)
-- 
Dave Cornutt, AT&T Bell Labs (rm 4A406,x1088), Holmdel, NJ
UUCP:{ihnp4,allegra,cbosgd}!hotly!dkc
"The opinions expressed herein are not necessarily my employer's, not
necessarily mine, and probably not necessary"