I’ve noticed that basically no system I’ve ever worked with has /bin/sh as a real executable. It’s always a symlink to dash, bash in POSIX mode, or something similar.
Why? What are the disadvantages of using the true, original /bin/sh? (Speed? Licensing?)
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I’d guess lack of features – no command history, no fancy redirection, no command line editing. BSD introduced csh the C shell for those reasons. Another factor is that the Genuine Bourne Shell was only recently available in open source form. Unless you licensed it, you couldn’t distribute it. That put it out of reach for free-of-cost distros, and made it ideologically unpalatable for other distros, and *BSDs.
But the code is available now. You can take a look, compile it, give it a spin.
Method 2
The statement in your question is incorrect. Solaris up to version 10 is providing the legacy true Bourne shell as /bin/sh. This was done not to break compatibility with old scripts that might fail with a different shell. This choice was very frustrating otherwise though.
Most if not all remaining Unix and Unix like releases, including Solaris 11, do provide a POSIX compatible shell as /bin/sh because POSIX mandates the sh command to launch a POSIX shell, not the legacy Bourne shell which is not compliant. /bin/sh is generally :
ksh88orksh93on the commercial Unix implementations- a modified
bashonOS/X(though it used to bezsh) - an
ashorpdkshderivative on otherBSDs bashordashon Gnu/Linux distributions.
It is not necessarily a link but can be a real executable on many systems but Gnu/Linuxes.
Interestingly, despite what states the most upvoted answer to your question, it is not the lack of features that lead distribution developers to install something different than the legacy Bourne shell in /bin/sh but the desire to be as POSIX compliant as possible, i.e. to behave like a Unix like OS. The fact the POSIX shell has more features than the legacy Bourne shell is only a side effect of this standard compliance goal.
It is also a fact some shells, notably bash, behave differently when called sh, and this mostly removes features from the shell, not the other way around.
Method 3
As far as I know the original Bourne shell couldn’t be used by the BSDs and the GNU project, because of its license.
Back then the original Unix had no license and the GNU project needed a shell that was under the GPL so they used the bash.
The same thing is true for BSD4 the parent of all BSDs. Thanks to the AT&T lawsuit they needed to rewrite all source from the original Unix including the Bourne shell.
In the traditional BSD line, the Bourne shell was shipped until
4.3BSD-Reno (but not anymore with Net/2 and the following 4.4BSDs). For license reasons it was then substituted with the bourne-compatible, svr4-like sh by Kenneth Almquist (often called
ash).
From FreeBSDs man sh
A sh command, the Thompson shell, appeared in Version 1 AT&T UNIX. It
was superseded in Version 7 AT&T UNIX by the Bourne shell, which
inherited the name sh.This version of sh was rewritten in 1989 under the BSD license after
the Bourne shell from AT&T System V Release 4 UNIX
So both projects were forced to not use the Bourne shell and settle for an true open source shell.
Method 4
There have been other problems. The Bourne Shell did use sbrk() instead
of malloc() and this made it not very portable.
After the Bourne Shell had become OpenSource via OpenSolaris, I created
a hafway portable version and later a really portable version by replacing
sbrk() by malloc() with the help from Geoff Collyer (the same person that
helped to avoid sbrk() in the Korn Shell).
The initial reason, why I made a portable version of the Bourne Shell is
that I liked to make the History Editor I wrote for my “bsh” between 1982
and 1984 available in the Bourne Shell as well. Meanwhile, I ported most
of the unique characteristics I wrote for “bsh” to the Bourne Shell.
This is among others:
- Compiles and works nearly everywhere including Cygwin (nearly 2x faster than bash)
- The history editor with a LRU ring buffer
- builtin TERMCAP
- Advanced aliases (global persistent aliases, local aliases, ….)
and together with the “dosh” builtin, the Bourne Shell is the
only Bourne Shell alike implementation that allows parameterizable
aliases. - Support to edit complex aliases in the history editor in raw mode.
- Access all 32 bits of the exit(2) code via .sh.* variables.
- advanced automated timing with 6 digit resolution
- pushd/popd/dirs
- builtin “find”
- Pipe from stderr
- Using vfork() for better performance.
- finally fixed all documented bugs from the SVr4 Bourne Shell,
e.g. suspend always works in job control mode.
…
The online man page is at:
http://schillix.sourceforge.net/man/man1/bosh.1.html
The sources are part of the schily toolbox at:
https://sourceforge.net/projects/schilytools/files/
I recommend to use:
http://sourceforge.net/projects/schilytools/files/schily-2015-08-18.tar.bz2
or a newer version.
P.S. I am interested in feedback
Method 5
It is linked to shells that provide 100% Backward compatibility. You don’t lose anything that the original shell has but gain more features on top of it. There’s no downside so why miss out on the new features? This is the same reason why /bin/vi is usually linked to vim.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0