wa371@sdcc12.UUCP (wa371) (03/21/85)
>>>>>>Question posed to the net: > There seem to be many books and tutorials on UNIX, but they > deal with the writing of shell scripts only in passing, if at > all. Are there any texts or tutorials that teach the writing > of scripts for the C-shell in some detail? >>>>>>Reply: From: ihnp4!pegasus!hansen First comment is that you really don't want to write C-shell scripts. 1) The Bourne shell is a far superior programming language. 2) Any C-shell script that you write and later want to post or give away to someone else only has a ~50% chance of being usable by that person. (Many systems do not have or WANT the csh.) 3) Bourne shell scripts can be run on all UNIX systems since V7. 4) Start your Bourne shell script with "#! /bin/sh" and your kernel should recognize it directly making it faster at starting up that any comparable csh script. 5) Csh scripts will still source .cshrc and hash everything, so their startup is even slower. 6) Recent versions of the Bourne shell have incremental hashing of commands so that running otherwise identical sh and csh scripts is MUCH faster in sh than in csh. 7) Posting csh scripts will only get you yelled at. :-) Tony Hansen pegasus!hansen >>>>>>Reply: From: ucbvax!ucla-cs!lcc!gm ( Greg McGary) The only tutorial I know of is Bill Joy's `An Introduction to the C-shell'. This article is included with the BSD documentation set in Volume 2 of the programmer's manual. I think you've already discovered that most tutorials are written for the Bourne shell. (/bin/sh) The general consensus is that Kernighan and Pike's `Unix Programming Environment' gives the best available treatment of the subject. Please do not shy away from learning the Bourne Shell because you feel you are most interested in the C-shell. The techniques of shell programming apply to both shells. Once you what you want to do with a shell program and generally how you want to do it, in most cases it is a simple matter of consulting the manual page to select the correct syntax. Also, you may discover (like many of us) that the Bourne Shell is really the shell of choice for programming. It is more capable and less buggy. Personally, I prefer the C-shell for interactive use (until the Korn Shell becomes available...) because of history, job control, and aliases. But for shell programming, I always use the Bourne Shell. Greg McGary Locus Computing Corp. lcc!gm@ucla-cs {ihnpr,randvax,sdcrdcf,ucbvax}!ucla-cs!lcc!gm {trwspp,ucivax}!ucla-va!ucla-cs!lcc!gm trwb!lcc!gm >>>>>>Reply: From: ihnp4!ihnp1!packard!harvard!chavez I wrote a tutorial introduction called "Applications Prototyping in the UNIX Shells" as part of DEC's ULTRIX-32 courseware. I can't distribute the tutorial since it's DEC's property, but I don't see why you couldn't write to DEC Software Support in Marlboro, MA for details. R. Martin Chavez chavez@harvard.ARPA >>>>>>Reply: From: ucbvax!jonathan@ucbcory.Berkeley.ARPA (Jonathan Creighton) Kernighan and Pike have written "The Unix Programming Environment" which contains some tutorial-like chapters on shell programming... IT'S EVERYWHERE!! JC >>>>>>Reply: From: "George R. Cross" <noscvax!cross%lsu.csnet@csnet-relay.arpa> Digital is selling courses on shell programming: Shell Programming for Users EY-2230E-PO Shell Programming for Programmers EY-2231E-PO Ordering Information 1-800-332-5656 Digital Equipment Corporation Educational Services Department 12 Crosby Drive BVUO/E55-41 Bedford, MA 01730 Reference Edu Winter 1985 Issue #37 Page 46 --------- George R. Cross Computer Science Department Louisiana State University Baton Rouge, LA 70803-4020 Phone: 504-388-1495 CSNET: cross@lsu ARPA: cross%lsu@csnet-relay BITNET: cscros at nsnccvm cscros%nsnccvm.BITNET@wiscvm.ARPA >>>>>>Reply: From: ihnp4!utzoo!henry Probably not. Most script-writers use the real shell, not the C shell; for scripts in particular, it's a big win. Kernighan&Pike is a good source for how to write shell scripts. >>>>>>Reply: From: sdcrdcf!hplabs!tektronix!tektools!barbaraz I'm the project leader for UNIX training at Tektronix. To my knowledge, there's nothing available that teaches C-shell programming, other than some local internal documentation that people write out of the goodness of their heart. Are you absolutely set on using C-shell for programming? We try to steer people away from it *for programming*, although we encourage them to use it as a command interpreter, and we teach them Bourne shell programming instead. Some of the major reasons are: - Bourne is usually faster, - Bourne is more portable (only Berkeley sites have C-shell, usually), - The syntax is simpler (people tell me that it's easier to use Bourne shell than remember the differences between C and C-shell), - Bourne has some features that are especially nice for programming (such as traps and the ability to independently redirect each output channel.) If you're set on C-shell, I can't help you. If you'll consider Bourne, look at "The UNIX Programming Environment" (Kernighan and Pike) and "The UNIX System" (S.R. Bourne) - the first half of both books talk about shell programming in quite a bit of detail. Also, once you have the principles, most syntax changes are simply a matter of looking them up in the manual. Barbara Zanzig {allegra, ihnp4, decvax, ucbvax, ...}!tektronix!tektools!barbaraz >>>>>>Reply: From: decvax!utcs!ian (Ian F. Darwin) Few people write serious scripts for csh, since sh is widely admitted to be better as a programming language. For writing sh scripts, see `The UNIX Programming Environment' by Kernighan and Pike. >>>>>>>>>End of summary, 'csh tutorials'. Bernd (the smokeless bear) (Not affiliated with, nor speaking for U.C. San Diego) UUCP: ...!ucbvax!sdcsvax!sdcc12!wa371, ARPA: sdcsvax!sdcc12!wa371@nosc