From owner-freebsd-questions Fri Jan 25 21:49:14 2002 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (dsl-64-192-6-133.telocity.com [64.192.6.133]) by hub.freebsd.org (Postfix) with SMTP id EC10C37B402 for ; Fri, 25 Jan 2002 21:49:05 -0800 (PST) Received: (qmail 65353 invoked by uid 100); 26 Jan 2002 05:49:02 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15442.17229.937600.658651@guru.mired.org> Date: Fri, 25 Jan 2002 23:49:01 -0600 To: Bernie Cc: questions@freebsd.org Subject: Re: shells confusion In-Reply-To: <947431@toto.iv> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ From: "Mike Meyer" X-Delivery-Agent: TMDA/0.44 (Python 2.2; freebsd-4.4-STABLE-i386) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bernie types: > i'm planning to learn shell programming but i'm not sure > on which one to choose... > > i've been reading in the 'FreeBSD unleashed' that people > wanting to do shell programming should stay away from > c-shell as it's realy good for interactive, but very bad > for scripts. is this true? Yes. However, some of the more serious problems have been fixed in the variants. > also, looking into the scripts in /etc, i see a line on the > top saying 'bin/sh'. so are they all written in 'sh' and > not csh ? if so, why freebsd comes with csh as default? Because csh is better for interactive use than sh. > also, why single user mode proposes /bin/sh as default? > is there any particular reason for it? Probably because no one has bothered to change it. > i'm a bit confused on which shell to pick from programming. > also i've been thinking of perl, but for the moment i think > i've got to learn at least how to do basic shell programming, > not only to write programs, but also to understand scrips that > come with the system. I'd agree with that, as Perl scripts often invoke commands, and one of the design goals was to make it easy for shell programmers to learn. It's not clear the latter is a *good* thing, but that's a different thread. > but the question is 'which shell' ... Unix shells fall into three different classes: sh and variants, csh and variants, and "other". As Charles pointed out, bash is by far the most popular shell for interactive use. It picks up most of the nice interactive features of csh, along with features from variants of csh and sh. However, not all systems come with bash, though they all come with an sh variant. An sh script should work fine in bash, but not necessarily the reverse, because of the extra features. Which leads to the conclusion: learn sh for scripting. It will be applicable on all Unix systems, and everything you learn will be applicable in bash, though there may be quicker or easier ways to do certain things. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message