Home » Questions » Computers [ Ask a new question ]

Why is Bash everywhere (in most if not all Linux distributions)?

Why is Bash everywhere (in most if not all Linux distributions)?

Bash is used by default in every Linux distribution I have tried, over alternatives like Z shell (zsh). Is there a technical or historical reason for this?

Asked by: Guest | Views: 61
Total answers/comments: 5
Guest [Entry]

"History (acquired not through research but through spending entirely too much time hanging out with Bell Labs people):

In the beginning (if you consider the beginning to be Unix Version 7) was the Bourne shell. Steve Bourne was the first to show that the shell which controlled the user's interaction could be a user program and not a special part of the operating system. A historic breakthrough. The shell itself was relatively clean for scripting, but had no command-line editing or job control. Bourne's Introduction to the Unix Shell is still useful for beginning users today.

Edit: I've ignored some ""prehistory"" from Ken Thompson and John Mashey, also from Multics. I'm sure Bourne was aware of all this work (he was in the same lab, 1127, at Bell Labs), but Bourne's shell was definitive, and the earlier work had little influence except as interpreted by Steve Bourne. For example, although Ken later wrote the Plan 9 C compiler and was very influential on Plan 9, but Tom Duff's paper on the Plan 9 shell (rc) mentions only Bourne's shell, not Thompson's.
The shell is just a user program, so anybody can write one. As Version 7 Unix was being created in New Jersey, Berkeley Unix was being created in California. Bill Joy at Berkeley wrote csh, the C shell. Joy added job control and history, and later command-line editing, but was not aware of Bourne's work and so based his language on the Thompson shell (which I considered ""prehistoric"" in the previous bullet). The Unix community loved job control, but they also loved Bourne's language. For a not-particularly-good polemic against the csh language, see Csh Programming Considered Harmful. For a time, many people used csh interactively for its job-control and history features, but used Bourne's sh to write scripts. This situation was less than ideal.

Edit: Thanks to DigitalRoss for straightening me out on the chronology of csh. Since I got my education from people who refer to BSD as ""the Berkeley heresy"", I was pretty short of facts there.
Dave Korn at Bell Labs did a brilliant re-engineering of the Bourne shell to produce the Korn shell (ksh). It was fully backward compatible with Bourne shell sh but provided a boatload of invaluable improvements. ksh became the basis of a POSIX standard and was shipped standard with Sun software. (This despite the fact that Bill Joy left Berkeley to help found Sun and was one of their leading software guys.)
Bell Labs and AT&T stupidly fail to make ksh open source. ksh88 is widely used, but having sources is not legal. Certain people become so addicted that they become digital criminals.

Edit: Was this really so stupid? Hard to know. Berkeley was already giving Unix away, and other corporations were soon to follow, but this was still the era when the Corporate Masters believed in charging for Unix. But the results: AT&T Unix is dead, after having been sold off to various parties any number of times. BSD and its derivatives are alive and well, but these upstart things called ""Linux"" and ""GNU"" have a huge fraction of mindshare that once belonged to Bell Labs.
The Free Software Foundation does a ""clean-room"", from scratch implementation of a POSIX shell, taking all of Dave Korn's ideas as then current, plus in usual FSF style adding new features of their own, such as programmable completion. They call it the ""Bourne again"" shell, or bash.
In the middle 1990s AT&T open-sources ksh93, but by then it is too late for widespread adoption. The licensing agreement is weirdly nonstandard. bash and ksh diverge, and ksh never achieves market share commensurate with its place in history.

Lessons:

The first adequate product to market wins (sh).
People love new features (job control, command completion), but they love them even more when their old scripts continue to work.
Edit: Professors of engineering should leave history to historians of science :-)"
Guest [Entry]

"To add to what @DigitalRoss said

Bash is a complete superset replacement for posix-sh, even to the point if called as /bin/sh will emulate posix-sh entirely. Posix-sh was the ""standard"" for commercial unix systems as a common-denominator shell. So, something that starts there and builds on it is starting with a lot."
Guest [Entry]

Bash is widely accepted due to its rich set of features. It also adopts features from other shells like C-shell and Korn-shell. Please take a look at these set of features.
Guest [Entry]

"Because 'bash' is 100% 'sh/ksh' compatable and 'ksh' is the POSIX shell.

So if you want a POSIX compliant system, and you are on Linux then you use bash.

If you are on a commercial unix you generally get ksh as the default shell (sometime plain just old sh). For some reason Sun still defaults to the flakey csh c-shell.

The advantage is portability a .sh written for hp-ux or AIX has a good chance of running as a linux 'bash' without any changes."
Guest [Entry]

"And to add to all other answers: zsh is not meant to be backwards compatible. You probably can set it up so that it will be compatible, but then you're losing its features.

I do use zsh as my regular interactive shell, but bash/dash seem more sane to me as a shell scripting languages; they do less magic and are more predictable... this is more important for me when I'm writing a script that is meant to work for several years."