sh --> bash symlinks
emmanuel.rouat at st.com
Wed Jan 31 05:14:35 PST 2001
I'm reading the latest LFS book and I came upon the
'Because programs and scripts don't know what shell you use
by default (could be bash, ksh, csh etc) they use the common
symlink sh which, if the system is properly setup, always points
to the system's default shell. '
This is ENTIRELY wrong. This misconception comes (presumably)
from the fact that on linux systems, the system default shell
is bash, and because on those same systems, /bin/sh indeed points
to /bin/bash (at least all linux distros I know have this).
A bit of history....
The first Unix shell was the Bourne Shell (written by Steve Bourne)
and that shell is /bin/sh . This shell was renowned for being
adequat for scripts, but horrible for interactive work (no aliases
and other fun interactive stuff).
So Steve(?) Korn wrote the Korn Shell (/bin/ksh) which is an
enhancement of sh, adding lots of interactive functionnalities (like
vi-style command line editing, aliases, etc....). But the syntax
of a korn shell script is still bourne shell style.
The same applies to bash (Bourne Again Shell) and zsh .
Those shell (sh,ksh,bash and zsh) make one family of shells.
But some people wrote csh, the C shell . The C shell and the Bourne
shell are NOT COMPATIBLE. They have numerous syntax differences. Same
for tcsh. Csh and Tcsh are not from the bourne shell family.
On all Unix systems, the startup shell is always /bin/sh , regardless
of the users default shell (which is quite often csh, alas....)
The reason linux systems have a symlink between sh and bash is that bash
knows when it has been called as /bin/sh, and in that case it will run
in a special mode: it will emulate the original Bourne shell.
So there is no reason to have an extra binary for /bin/sh, since
will do the job :-) I believe that for security reasons, some
don't use that symlink anymore, but supply a customised /bin/sh binary
(I'm not sure though...)
If , however, you symlink /bin/sh and /bin/csh , you're in BIG TROUBLE,
nearly all startup scripts are written for /bin/sh, not /bin/csh. Your
will not boot :-(
If you really want to boot on csh, then :
1) you need to rewrite your startup scripts
2) you need to recompile csh statically (not sure this is mandatory)
3) if you do this , you're not in line with the standards.
Hope this clarifies the matter.
Conclusion: /bin/sh does NOT point to the system default shell. It
/bin/bash only because bash knows how to emulate /bin/sh .
Unsubscribe: send email to lfs-discuss-request at linuxfromscratch.org
and put unsubscribe in the subject header of the message
More information about the lfs-dev