|
|
Bash has two completely different things going for it.
It really is a good shell. It is one of ~~2 shells (the other is zsh) that integrate some of the cool csh features like ! history substitution with the posix syntax. It has lots of extensions, including arrays.
It is the FSF/GNU shell. In the open source world, this gives it a sort of cachet.
I should also add that it is not always the default. ash is often used as /bin/sh so that while bash may be the interactive shell, ash is the "just run the command file" shell. This is because ash is smaller and faster, and contains all the posix features. Using ash as an interactive shell is sometimes problematic. On, say, NetBSD, it works well, because there it is built with all the features. It's kind of their one shell whereas bash is an external package. But on Linux ash is usually considered non-interactive, so they disable the history and line editing on the theory that it is just used to run those huge gnu configure scripts.
UPDATE: There is an inaccurate history of the shell being copied from place-to-place on the web, and people are understandably believing it. I will try to give an accurate version and provide a few links to substantiate it here.
- The first shell was most certainly not the Bourne shell but was written by Ken Thompson himself and distributed in V6, which is the version AT&T sent to various universities and government labs. This is what put Unix on the map. It had all the basics,
<, >, >>, |, &, but it just had simple goto control syntax via an external program that seeked on standard input. There were no complex shell scripts then. Later shells would open the command input on a separate fd. It may look simple today but in the horror-movie that was 1970's computing it was the best thing on earth. Believe it or not, this ancient shell has its own twitter stream today and, of course, a home page.
- The second shell was
csh, written (as was vi) by Bill Joy at UCB. This was before GNU readline and NetBSD editline, so it must have seemed perfectly reasonable to do history with the ! syntax. Csh added most of today's shell features but with csh syntax. csh did not change any syntax, gratuitously or otherwise. It was actually backwards compatible to the Thompson shell, and originally included TS source code.
- The third shell was the Bourne shell, with different syntax. Unix was being developed in parallel at UCB and AT&T. This shell had a weird memory allocator (I think it just used more memory, trapped SIGSEGV, did a new brk(2), and then tried again) that made it hard to run on new Unix ports, so
osh and csh stayed popular for some time. There was no internet and it was licensed SW, so in that environment it's possible that Stephen Bourne didn't know about Joy's shell and certainly Joy didn't know about Bourne. It's possible that the two shells first met when UCB got a VAX and a prerelease of the now-forgotten Unix/32V. I remember Bill complaining about the memory allocation. Note that both shells were backward-compatible to the V6 shell, they simply extended the syntax in different directions.
- Now there really were multiple incompatible shells, to which AT&T added the Bourne-compatible
ksh. Eventually, csh had semi-available source code, but it was tied up in a lawsuit between AT&T and the University of California. Still, these were the glory days of BSD Unix as sophisticated companies who could afford the $50,000 fee would buy the AT&T license but install the 4.x BSD distributions, and universities got it for free.
- In this situation with many legal and technical issues, various independent implementations were undertaken. At least as many went with the
csh syntax as went with the Bourne shell syntax, and some merged the two. You had at least tcsh, zsh, bash, and ash. The Bourne syntax was "official", being part of AT&T releases, but in those days BSD was quite important, and Sun, initially BSD, distributed a fair amount of the Unix SW that the world encountered.
- Partly because of the USL lawsuit, the FSF and Linux had an open field. AT&T had managed to pick a fight with one of the few entities on earth larger than they were (The State of California) and in the end they didn't win the suit, and so eventually BSD distribution was on a firm legal footing. But by then Linux and bash were firmly on the map, and now BSD is a niche.
- Finally, bash is a good shell and fully deserves the credit for its own success. csh would have been eclipsed by tcsh and zsh even if ash, bash, and ksh had not won the syntax war.
|
|
answered Oct 27 '09 at 4:19
|
|