I’ve encountered a situation where it would be very helpful to know the breakdown of shell use by percentage. For example, I’m looking for something like
bash: X%, sh: Y%, csh, tcsh, zsh, ksh, dash, etc..
Obviously, I know there are several complications – multiple shells, the definition of “use”, uncertainty and so forth, but I would like to see an informed answer derived from actual data and based on some stated metric, even if the result could be horribly wrong.
Bonus if there is historical data demonstrating a shift in preferences.
My guess is that BASH is now the shell of choice and makes up the vast lion share of shell users. It’s the default shell on Linux, and Linux has pretty much taken over the Unix world. (Yes, Linux is not really Unix, but it’s damn close).
Csh was the domain of the BSD set which included SunOS, and Mac OS X. However, Mac OS X switched to Bash in version 10.4 and Solaris switched to the POSIX shell (which is like Bash-like in syntax).
A bit of history…
Most Unix users used Csh as their default shell, but programmed in Bourne shell. Csh had a lot of features missing in Bourne shell like aliasing and command line editing which were nice to have when you used it interactively. However, Csh was a poor programming shell. Tom Christiansen’s seminal paper on Csh sort of sealed the deal on programming in Csh. The truth is that even BSD based systems used Bourne shell in startup scripts, etc.
When Kornshell came out, I switched with a lot of other users. Kornshell had the familiar Bourne shell syntax, but also had the power user features that Csh had. In fact, the Kornshell’s command history ability was way superior to Csh’s command history. The biggest issue with Kornshell is that it was owned by AT&T and was not open source. Almost all commerical Unix platforms (except for SunOS) had Kornshell available. However, open source platforms couldn’t use Kornshell.
Bash was developed in the late 1980s to be a true OSS shell with many of the features of Kornshell. However, Bash tried to be more compliant with the POSIX standard (which took a lot of Kornshell’s features).
I still prefer Kornshell (mainly due to habit), but I’m finding it on fewer systems. I tell most new Unix heads to learn BASH since it has the most resources and is the most readily available.
My recommendation is not to worry too much about Bash vs. Kornshell vs. Bourne Shell vs. Posix. They’re all pretty identical. Forget Csh. The official Turbo Csh page hasn’t been updated since 2004.
If you write shell scripts, use features that are common among all the Bourne type shells. Use
printfinstead ofechoorprint(A Kornshell feature), use[and]instead of[[and]]since the double square braces aren’t completely compatible between all the shells. Avoid arrays too. Bash 4.0 supports them, but not earlier versions. Kornshell supports both numeric and string arrays, but they’re declared differently from Bash. That still leaves about 90% of the features of the shell script.Besides, you’re really better off writing in Python or Perl which are more powerful and faster scripting languages. Plus, both are more platform independent than the various shells. I write shell scripts, but anything more than a few dozen lines, and I switch to a real scripting language.