Why there are multiple shells in a Unix like system?

Because people have different needs and it's good to have alternatives fitting your needs in the given situation. A shell is just a tool on its own and should be replaceable by any other in my opinion. That's the power of Unix/Linux, opposed to what Microsoft Windows has chosen to be.

Similarly... Why are there so many text editors? Why people develop a new browser if there's already one? Why is there GNOME, KDE, Xfce, LXDE, E17, etc.?


Most shells used in modern UNIX environments are meant to conform to the POSIX sh specification. POSIX sh is derived from the original Korn shell (ksh88), which is in turn derived from the earlier Bourne shell, but POSIX sh only specifies a small subset of even ksh88's functionality. A shell that only implements the minimum requirement is missing many features required for writing all but the most trivial of scripts in a safe and reasonable manner. For example, local variables and arrays are non-standard extras.

Therefore, the first reason is to extend the shell with extra features. Different shells choose to focus on different things. For example, Zsh focuses on advanced interactive features while ksh93 (the current "original" korn shell) focuses on powerful programming features and performance. Even very minimal shells like Dash add at least a few non-standard extras like local variables.

Extra features are rarely widely interoperable, if at all. Most of the ksh88 featureset is fairly well interoperable such as the extended globbing syntax, but with non-standard features, there are no guarantees, and you must really know what you're doing to use them in a portable way.

The second reason is legacy. There are still a lot of proprietary Unixes out there that use ancient non-standard implementations for their /bin/sh. Until recently, Solaris still used Bourne as their defuault and chose to maintain the Heirloom shell rather than upgrade to something modern. These systems usually come with different shells you can switch to, for instance by changing your PATH variable or altering shebangs within individual scripts.

So to summarize. There are multiple shells, often by default:

  • For extra features, especially for dealing with non-portable extras.
  • To handle legacy scripts which are often unmaintained.
  • size / performance. Embedded systems often require small shells like mksh or busybox sh.
  • Licensing reasons. AT&T ksh was proprietary software until around 2000 or so. This is largely what gave rise to all the ksh-like clones such as Zsh and Bash.
  • Other historical reasons. Though not very popular today, there have been radical attempts at redesigning the language, such as scsh and es. The process substitution feature of many shells originally comes from rc (with a bit different syntax), and brace expansion from csh. Different shells have different combinations of such features available, usually with some subtle or not so subtle differences.

Short Answer

Due to a weird licensing history, no single entity has developed Unix. It was a community process where both volunteers and corporations have participated. These entities didn't always share all their tools, so separate shells happened. By the time we realized how counter productive this is, it was too late to unify all the shells in use. Instead work has been done to ensure that all these shells would be (theoretically) compatible with one another.

The long answer is complex and tightly linked to the history of Unix itself. There's no way it will hold on a single answer on this page, but it's been widely (mis)documented. You will find more detailed and precise answers by looking around the web and books dealing with Unix history.

Tags:

Shell