Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Do shells have any actual advantages or disadvantages? They can all run any binary, they all support pipes and > (output to file). Why would one choose bash over sh, or sh over ksh, etc? Why does any shell other than sh exist in the first place?

share|improve this question

closed as not constructive by jasonwryan, Shadur, uther, rahmu, warl0ck Feb 3 '13 at 8:07

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Have you ever tried to use something like dash as your interactive shell? – jordanm Feb 2 '13 at 17:43
@jordanm no, because I've never had any reason to use anything but bash other than using up two characters fewer on each line. – tkbx Feb 2 '13 at 17:46
Technically they don't run any binaries, they run a system command that asks the kernel to do so, since only the kernel can do so. – goldilocks Feb 2 '13 at 21:02
up vote 3 down vote accepted

An executable sh is requisite for contemporary Unix-like operating systems. There are various standards (e.g. POSIX) dictating what that means, although since "unix-like" doesn't necessarily mean "certified compliant" with anything, the reality varies somewhat. In general, they at least implement something compatible with sh, the original Bourne shell. This is why sh is usually a symbolic link, and "sh" is best understood today as a standard for the behaviour of whatever it links to.

bash is the Bourne Again Shell, which is what sh often links to on GNU/Linux systems (but there are other possibilities, such as dash and ash). Bash includes all the features of sh and is intended to provide backward compatibility for sh scripts. There are apparently some potential obscure glitches in this compatibility, but they are probably not too significant.

So in terms of functionality, bash extends sh; it does everything a sh should and a whole lot more. Another popular extended sh implementation which also satisfies POSIX is the KornShell, ksh.

The other general purpose command shell lineage still used in the *nix world is C shell, csh. C shell, however, is not compatible with sh code, and an implementation would never be linked to sh.

share|improve this answer
No sh is no longer the Bourne shell. Just like it was no longer the Thomson shell when the Bourne shell came out and became the new de-facto standard. Now sh is a standard specification of a language based on a subset of ksh88, no longer an implementation. Or said otherwise, sh are a lot of different implementations of an interpreter for that sh specification. bash is the sh of the GNU project, the main reason why it's so widely used despite not being the best of shells. – Stéphane Chazelas Feb 2 '13 at 18:17
Fair enough. Well, there is the history anyway. Somebody should write a wikipedia entry for sh then, since it redirects to "bourne shell". I'll add a bit about the POSIX spec for sh... To be fair, sh in the context of "a shell" would refer to the bourne shell, and not a specification. – goldilocks Feb 2 '13 at 18:23
The "and a whole lot more" is what I'm trying to find out. – tkbx Feb 2 '13 at 22:08
@tkbx : there's a few things mentioned in the wikipedia page -- regular expressions, associative arrays. You'll probably find a ton of stuff in the NEWS or CHANGELOG file of the source. "Differences between shells" in a pragmatic here and now sense is not really about sh and bash, since in colloquial and practical terms on a POSIX system, sh == bash. I wrote this post to clear that up. The Korn shell and C shell are their own story and would make for a more interesting contrast. – goldilocks Feb 2 '13 at 22:27
@goldilocks, POSIX absolutely does not imply sh == bash. On recent Debian versions, /bin/sh is dash, not bash. On recent Solaris versions, /bin/sh is a ksh derivative, not bash. And on many embedded systems that can claim POSIX compliance, /bin/sh is Busybox's sh, which is ash, not bash. – godlygeek Jul 9 '14 at 13:38

Mostly common differences you may find in Difference between ksh,bash and different shells post on unix.com My opinion that it is like a choice different distros. Everyone chooses what he likes.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.