Re: Linux Bash vs. Unix Bash
"Brian K. White" <[email protected]>
| Newsgroups | gmane.linux.redhat.release.enigma |
|---|---|
| Organization | Aljex Software |
| Message-ID | <009101c30f67$2e1fa5e0$0e00000a@briandesk> |
Rick Warner wrote: >> plain "sh" on most unixes (besides linux) is usually a subset of >> features that both bash and ksh has. they are like 92% overlap in >> most syntax, but there are differences. > > A more correct statement is that bash and ksh are supersets of sh. > AT&T created the reference implementation of sh; Korn (at AT&T) then > created ksh as a superset of Bourne's sh. bash is a much later > superset. > > Script writers who want to ensure that their scripts work under all > bastardizations of 'sh' should write to the USL reference > implementation. Avoid ksh extensions, avoid bash extensions, avoid > SCO extensions; just write to the pre-Novell buyout USL specs for sh > and all should be fine. > > - rick warner agreed, but I find the compromise worth it. at least when writing for ksh, you get to do this: #!/bin/ksh This is reasonably likely to exist on many boxes, and those boxes where ksh is not installed the script will fail in a cleaner, more obvious way. What it *won't* do is "almost work", ie: look like it's working but actually doing some things wrong. And the fix, to make it work on a box where it doesn't, is simpler than editing the script for a different shell. in the bargain, ksh is a lot more useful than sh it's a compromise between the really nice features of bash and the extreme portability of strict USL sh. I find ksh just as handy as bash, and at the same time almost as widely available as sh. so if a box here and there needs to install ksh, I find that better than having a box _beleive_ it can run my script without error because it has a /bin/sh, only to have that box's sh do something dufferent than mine. or almost as bad, having to work hard to write things that are very easy in ksh. I figure even requiring ksh I'm still being 200 times nicer than for example, any perl script and people are certainly not shy about writing those. Brian K. White -- [email protected] -- http://www.aljex.com/bkw/ +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO Prosper/FACTS AutoCAD #callahans Satriani