From owner-freebsd-questions Tue Aug 12 21:31:22 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id VAA19761 for questions-outgoing; Tue, 12 Aug 1997 21:31:22 -0700 (PDT) Received: from ethanol.gnu.ai.mit.edu (joelh@ethanol.gnu.ai.mit.edu [128.52.46.64]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id VAA19738; Tue, 12 Aug 1997 21:31:13 -0700 (PDT) Received: by ethanol.gnu.ai.mit.edu (8.8.5/8.6.12GNU) id AAA11205; Wed, 13 Aug 1997 00:30:35 -0400 Date: Wed, 13 Aug 1997 00:30:35 -0400 Message-Id: <199708130430.AAA11205@ethanol.gnu.ai.mit.edu> To: Studded@dal.net CC: FreeBSD-chat@FreeBSD.ORG, FreeBSD-Questions@FreeBSD.ORG In-reply-to: <199708112306.QAA00849@mail.san.rr.com> (Studded@dal.net) Subject: Re: Needed: Info on shells and script writing From: Joel Ray Holveck Reply-to: joelh@gnu.ai.mit.edu Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > I'm looking for a good book on the sh shell and writing scripts > with it. Even better would be some good FAQ's and such available on the > net since "free" is much more in my price range nowadays. :) Best advice is to read existing shell scripts. I believe that GNU autoconf (ftp at prep.ai.mit.edu) comes with several working (ie, real-use) examples. O'Reilly and Associates probably has a good sh programming book. But really, the manual is typically enough... start small (command-command-command, no structure), and build. > Alternatively, is sh "dead" in the modern Unix world? I know Perl > and TCL are very popular, but I'm trying to produce some tools that will > be compatible across a number of platforms, and are easily > accesible/modifiable by people who are not professional system > administrators. Shell scripts become hairy quickly. But for across-the-board Unix compatibility, nothing beats sh (aka the Bourne shell). Every still-used Unix system will probably have ksh, and most likely csh (the latter being less likely), but you can never be quite sure. Bottom line: if you're distributing it cross-platform, use the Bourne shell. If you're using it on your own company's computers only, or for personal use, use your favourite shell. > Finally, for general purposes, what is the "best" shell available, > and why? I know that this topic borders on religious fervor for some > people, This is why I kindly request that nobody reply to the remainder of my message with opinions. Missing significant shells or incorrect *facts* may be corrected. > Personally I'm happy with Bash for my everyday stuff, although from what > I've heard it's looked down on by the purists. Not purists. Traditionalists. Traditional BSD hackers prefer csh. It's (marginally) cleaner, and it's been around longer. Most Linux hackers prefer bash. Almost nobody (who is serious about Unix) uses the Bourne shell as their login shell, but every Unix hacker can program in it. SysV [hiss] traditionalists tend to use ksh (which is a Bourne shell superset). In the beginning was sh, and it was without structure, and void. And came forth from the labs hackers, bearing each idiosyncrasies in their own fashion. Then Berkeley said, "Let there be job control!" And there was job control. And Berkeley said, "Let there be a shell, being of Bourne, which shall wield job control!" And thus was created jsh, but it slipped into the mists of time. Then AT&T said, "Let there be a shell of Bourne, that hath security!" And there was security, not so that of a prison of bars, but of a padded cell with an open window. And thus was created rsh, but it too slipped into the mists of time. (A utility came forth from BSD also known rsh, but that shared only name.) So stepped forth Allman, saying, "This sh(1) is of filth; it is ambiguous and hath many kluges. Let there be a different shell, of programmability and versatility." Thus was created the csh, and was structured in the fashion of C, and BSD looked, and saw it was good. So stepped forth Korn, saying, "This Bourne shell is impotent; it lacks the versaitility which are brought about by functions. Let there be a similar shell, of programmability and versatility." Thus was created the ksh, and though it was of sh(1), it was structured, and USG looked, and saw it was good. So stepped forth Gates, saying, "Let there be a shell for my OS!" And thus was created command.com, and in its hilarity much amusement was to be had by all, save those who were to use it. Then went forth Allman to create other things, and the csh was still, while Korn continued to cause the ksh to grow, and become fruitful. So came hackers from across the lands, from beyond the seas, and created shells of csh, each in their own fashion. So were created tcsh, and zsh, and others. And the hackers came forth, and each took as was in their own form, and were happy. So stepped forth Stallman, saying, "This wealth of shells across the land, and yet the only common shell is the Bourne shell. For GNU, we shall have the Bourne shell, but it shall not be the Bourne shell, lest the Demons of Copyrights destroy us forever. Let the shell be Bourne again!" And thus was created bash, in the form of the Bourne shell, and yet taking from it the lessons learned by the making of csh and ksh and others, and GNU looked, and it was good. So stepped again forth Gates, saying, "Let there be another shell!" And thus was created cmd.exe, and again amusement was had by all. Thus were created the shells and counted thus: sh, jsh, rsh, ksh, csh, tcsh, zsh, and bash, and from these their offspring, too numerous to count. And thus was never created a judge of shells, and the hackers shall choose as they see fit. -- Second law of programming: Anything that can go wrong wi sendmail: segmentation violation -- core dumped