Shell Script Portability
As we’ll see in a bit, many different shells are available for Linux, Unix, and Unix-like operating systems. Thus far though, we’ve mainly just been working with bash
. The big advantage of bash
is that it comes already installed on most Linux distros, macOS, and OpenIndiana. It normally isn’t installed by default on the BSD-type distros, but you can install it yourself, if you need to.
The big advantage of bash
is that it can use different scripting constructs that can make life easier for scripters. The big disadvantage of bash
is that many of these bash
constructs aren’t always available in non-bash
shells. That’s not a big problem if you can install bash
on all of your machines, but that’s not always possible. (I’ll explain why in just a bit.)
In this chapter, I’ll show you some of the bash
alternatives that you might encounter, and how to make your shell scripts run on a wide variety of these...