[net.bugs.4bsd] - csh weirdness

promislo@qucis.UUCP (Eric Promislow) (04/01/86)

	I think the latest debate on problems with struggling with the
vagaries of C-shell programming points out a couple of problems many
people find:

		1.) First, the Berekely people seem to have a propensity towards
documenting everything once.  Exactly once.  As Greg mentioned, I recall
reading somewhere that the shell won't do a history substitution on an
exclamation point if it is followed by white space or a newline.  I
don't know where I read it (probably in the csh manual), but I know it
wasn't mentioned in the test (1) page.  This is the sort of thing that
causes people to dump on Unix (and C) for overloading operators.

		2.) Those beginners with the fairly common misfortune of not 
having a guru around have a fairly vast choice of books to look at on
getting started, all assuming that the reader is using the Bourne shell
(okay, this holds at least for all the books I've looked at).  I've
used about six different Unix systems, III, V, and 4.2, and nobody used
the Bourne shell on it.  I'm beginning to suspect the authors skip the
C-shell (with perhaps a perfunctory aside towards mentioning the '%'
prompt) exactly because of the sort of complications Messrs. Dunn and
Woods pointed out.

		If anyone out there has compiled a short but complete guide to
effective  C-shell programming and usage, we sure could use a copy
around here.

	As for my advice, I learned the history mechanism largely by
trial and error, appreciate the escape-key completion (documented
nowhere, as far as I can tell) and job-control features, and do all my
shell programming with the Bourne shell.  I don't see any reason
to write scripts in the C-shell, except for the aforementioned
exercising of masochistic tendencies.

	Eric Promislow,
	Queen's University, Kingston, Ontario

	( ...utcsri!ihnp4!promislo )

karl@cbrma.UUCP (Karl Kleinpaste) (04/02/86)

In article <132@qucis.UUCP> promislo@qucis.UUCP (Eric Promislow) writes:
>	As for my advice, I learned the history mechanism largely by
>trial and error, appreciate the escape-key completion (documented
>nowhere, as far as I can tell)

It's not documented because it's not part of the standard csh.  There
are a several versions of tenex completion and line-editing front-ends
for csh out there.  Ken Greer at HP sent out the first one in Oct
1983.  Paul Placeway sent out a version of a line editor front end
about 2 years ago.  I have another which I wrote because I don't like
Paul's.  I'd distribute it, but I've had problems (political, not
technical) with doing so.

The distributed front-ends of this type for csh have always been
distributed with manual pages of some sort.  If you haven't got such
manual pages around, complain to your sysadmin about it.
-- 
Karl Kleinpaste

jpn@teddy.UUCP (04/03/86)

In article <132@qucis.UUCP> promislo@qucis.UUCP (Eric Promislow) writes:
>		1.) First, the Berekely people seem to have a propensity towards
>documenting everything once.  Exactly once.  As Greg mentioned, I recall
>reading somewhere that the shell won't do a history substitution on an
>exclamation point if it is followed by white space or a newline.  I
>don't know where I read it (probably in the csh manual), but I know it
>wasn't mentioned in the test (1) page.  This is the sort of thing that
>causes people to dump on Unix (and C) for overloading operators.

Why SHOULD it be documented in "test(1)"?!?  Conditionals in csh do NOT USE
"test(1)".  In fact, the syntax of csh conditionals is different than test(1).
You must be thinking about sh scripts!

However, it IS documented under "csh", where it ought to be.  What is
unfortunate is the overloading of '!' as the not operator and the history
selector.  I believe this is a historical problem, since history was added
late in csh'es development.  Anyway, it probably ought to be pointed out
in a warning note near the description of conditional expressions.

Thank GOD the berkeley people only document ONCE!  I HATE the VMS manuals!
A better documentation cross reference would be useful, though.

>		If anyone out there has compiled a short but complete guide to
>effective  C-shell programming and usage, we sure could use a copy
>around here.

I'm sure there are books.  I never felt the need for them.  See below.

>	As for my advice, I learned the history mechanism largely by
>trial and error, appreciate the escape-key completion (documented
>nowhere, as far as I can tell) and job-control features, and do all my
>shell programming with the Bourne shell.

Well, escape-key completion is NOT part of the standard C-shell, so
I suspect that you are running a bastardized version of csh.  Why not
ask your system guru (the one who installed the bastardized version!?)

Also, don't you have a copy of "An Introduction to the C shell"  by
William Joy?  It is an online document in /usr/doc/csh on all Berkeley
systems, and it is in our printed manuals too!  I felt that it was
an adequate introduction to all the csh features.  An excerpt from the
introduction:

	 UNIX users who have read a general introduction to  the
    system  will  find a valuable basic explanation of the shell
    here.  Simple terminal  interaction  with  _c_s_h  is  possible
    after  reading just the first section of this document.  The
    second section describes the shells capabilities  which  you
    can  explore  after you have begun to become acquainted with
    the shell.  Later sections introduce features which are use-
    ful, but not necessary for all users of the shell.

	 Back matter includes an appendix listing special  char-
    acters  of  the  shell  and a glossary of terms and commands
    introduced in this manual.

ken@rochester.ARPA (Ipse dixit) (04/03/86)

In article <132@qucis.UUCP> promislo@qucis.UUCP (Eric Promislow) writes:
>		1.) First, the Berekely people seem to have a propensity towards
>documenting everything once.  Exactly once.

More like at most once. And in places like the source.

Just whining. Forget it.

	Ken
-- 
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
Snail: CS Dept., U. of Roch., NY 14627. Voice: Ken!

dricej@drilex.UUCP (Craig Jackson) (04/06/86)

Fortunately for everybody, a csh book is now available.  It's called
"The Unix C Shell Field Guide", by Gail Anderson and Paul Anderson, published
by Prentice-Hall.  It appears to be a fairly good coverage of the subject.
-- 
Craig
UUCP: {harvard,linus}!axiom!drilex!dricej
BIX:  cjackson

woods@hao.UUCP (Greg Woods) (04/07/86)

>  I don't see any reason
> to write scripts in the C-shell, except for the aforementioned
> exercising of masochistic tendencies.

  I do. csh(1) has a lot of built-in execution, whereas sh(1) has to
fork a separate process (test(1)) for every bloody "if" test. Bourne
shell scripts, on our poor overloaded VAX 750, are slooooooow.

--Greg

ed@mtxinu.UUCP (Ed Gould) (04/09/86)

>If anyone out there has compiled a short but complete guide to
>effective  C-shell programming and usage, we sure could use a copy
>around here.

_The_Unix_C_Shell_Field_Guide_ by Gail Anderson and Paul Anderson has
just been publshed by Prentice-Hall:  400pp, paper, $23.95.  Write to

	Prentice-Hall, Inc.
	Book Distributioni Center
	Route 59 at Brook Hill Drive
	West Nyack, NY  10995

or check a good bookstore.

-- 
Ed Gould                    mt Xinu, 2910 Seventh St., Berkeley, CA  94710  USA
{ucbvax,decvax}!mtxinu!ed   +1 415 644 0146

"A man of quality is not threatened by a woman of equality."

henry@utzoo.UUCP (Henry Spencer) (04/10/86)

> ...csh(1) has a lot of built-in execution, whereas sh(1) has to
> fork a separate process (test(1)) for every bloody "if" test. Bourne
> shell scripts, on our poor overloaded VAX 750, are slooooooow.

Have you considered getting a modern Bourne shell (as opposed to the
ancient one distributed with 4.2)?  This was fixed long ago.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry

philip@axis.UUCP (Philip Peake) (04/10/86)

In article <2045@hao.UUCP> woods@hao.UUCP writes:
>>  I don't see any reason
>> to write scripts in the C-shell, except for the aforementioned
>> exercising of masochistic tendencies.
>
>  I do. csh(1) has a lot of built-in execution, whereas sh(1) has to
>fork a separate process (test(1)) for every bloody "if" test. Bourne
>shell scripts, on our poor overloaded VAX 750, are slooooooow.
>

Try using a System 5.2 version of sh, it may just make your csh
seem like a snail!


-------------------------------------------------------------------------------
UUCP:	{mcvax,vmucnam,inria}!axis!philip
-- 

-------------------------------------------------------------------------------
UUCP:	{mcvax,vmucnam,inria}!axis!philip

jkh@ucbopal.berkeley.edu (Jordan K. Hubbard) (04/11/86)

>It's not documented because it's not part of the standard csh.  There
>are a several versions of tenex completion and line-editing front-ends
>for csh out there.  Ken Greer at HP sent out the first one in Oct
>1983.  Paul Placeway sent out a version of a line editor front end
>about 2 years ago.  I have another which I wrote because I don't like
>Paul's.  I'd distribute it, but I've had problems (political, not
>technical) with doing so.

This is part of the 4.3 BSD csh.. It's invoked by setting the shell
variable 'filec' to something.. The original (Greer) tcsh also
used to do terminal sanity checking when a program exited and set it
back to something normal if it seemed braindamaged in some way. This
was useful, but as Mike Meyer just pointed out: What happened when
you ran stty? Did it set you back afterward? I didn't know the answer
to that question (it was probably kludged), but we're pretty sure
that the 4.3 csh doesn't do that for you.. So the REAL answer is that
4.3 csh doesn't do EVERYTHING tcsh did..