|
22.1 Why Use the Bourne Shell?
Unix has been around for more than thirty years and has splintered into
hundreds of small and not so small variants, See section The Diversity of Unix Systems. Much of the subject matter of this book is
concerned with how best to approach writing programs which will work on
as many of these variants as possible. One of the few programming tools
that is absolutely guaranteed to be present on every flavour of Unix in
use today is Steve Bourne's original shell,
However, there are complications. Over the years, OS vendors
have improved Steve Bourne's original shell or have reimplemented it in
an almost, but not quite, compatible way. There also a great number of
Bourne compatible shells which are often used as a system's default
`/bin/sh': This leads us to the black art known as portable shell programming, the art of writing a single script which will run correctly through all of these varying implementations of `/bin/sh'. Of course, Unix systems are constantly evolving and new variations are being introduced all the time (and very old systems which have fallen into disuse can perhaps be ignored by the pragmatic). The amount of system knowledge required to write a truly portable shell script is vast, and a great deal of the information that sets a precedent for a given idiom is necessarily second or third (or tenth) hand. Practically, this means that some of the knowledge accumulated in popular portable shell scripts is very probably folklore -- but that doesn't really matter too much, the important thing is that if you adhere to these idioms, you shouldn't have any problems from people who can't run your program on their system. |