Date: 26 Jan 2002 16:14:42 -0800 From: swear@blarg.net (Gary W. Swearingen) To: Jim Conner <jconner@enterit.com> Cc: questions@FreeBSD.ORG Subject: Re: shells confusion Message-ID: <4sg04s645p.04s@localhost.localdomain> In-Reply-To: <5.1.0.14.0.20020126153501.04980750@mail.enterit.com> References: <947431@toto.iv> <5.1.0.14.0.20020126153501.04980750@mail.enterit.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Jim Conner <jconner@enterit.com> writes: > sh is the right way to go. In my last email I suggested ksh and I hold > true to that. Fortunately, if you know how to sh script, you know how > to basicly ksh script. I still suggest scripting in ksh, however. :) I'm afraid that the same could be said for any sh-family script. Worse, if you know how to write ksh (or other advanced shell) script, you don't necessarily know how to write sh script (ie, a script that will work well with other shells that claim to understand sh script). You know too much stuff -- stuff that's only supported by the advanced shell -- but not enough stuff -- all the stuff that makes your script incompatible. Of course, most shell man pages try to tell you what's incompatible, but some aren't very good at it. The FreeBSD sh man page just mentions a "few Berkeley extensions". I suppose those are widely compatible, but it isn't obvious. Will Sun's "sh" or "ksh" or "bash" read almost any FreeBSD "sh" scripts I write using all it's features? But I think you still wind up needing to know at least two shell languages. One that you hope is understood by other shells which you use when you want portability more than a better language and one for the other case. (I which someone would write a man page for that virtual shell language, probably with some notes about unavoidable incompatibilities with various common shells.) I think the suggestion to script in ksh (or bash) is only valid for the non-portable case and the case where you know you can carry the shell with you. The same cases where Python and Perl are competitors with ksh and bash. Since non-portability is generally a bad thing, the issue seems to come down to your choose of language for scripts which require special script interpreters to be installed. From what I've read, ksh93 deserves (except for it's rather restrictive licensing) as much respect as Python or Perl as a choice that should be supported by OS distributions. (But not bash, as it doesn't add enough over portable "sh". OK for the command line, but not for scripting.) But the beginner's first language should always be portable "sh" (the closest to this being "sh" on FreeBSD and (AFAIK) with other sh-family shells being usable only if their "incompatibility/POSIX" notes are paid attention to. (And "pdksh" is best for that, IMO, as it's truly free, portable, well-documented regarding incompatibilities, more sh-compatible than bash, and is good for interactive use.) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4sg04s645p.04s>