[CentOS] Real sh? Or other efficient shell for non-interactive scripts

Mon Apr 27 09:35:16 UTC 2015
Joerg Schilling <Joerg.Schilling at fokus.fraunhofer.de>

Gordon Messmer <gordon.messmer at gmail.com> wrote:

> I'm reasonably certain that a script with no shebang will run with 
> /bin/sh.  I interpret your statement to mean that if a user is using ksh 
> and enters the path to such a script, it would also run in ksh.  That 
> would only be true if you "sourced" the script from your shell.

The historical way is: there is only one shell and all scripts are Bourne Shell 
scripts.

Then csh came out and some people really thought is was a good idea to write 
csh scripts. So someone decided to mark csh scripts with an initial "#".
Note that at that time, the Bourne Shell did not support "#" as a comment sign
and thus scripts with an inital "#" have been illegal Bourne Shell scripts.

Later BSD came out with #!name and all but AT&T adopted to this.

In the mid 1980s, AT&T introduced an initial ":" to mark Bourne Shell scripts.

In 1989, with the beginning of SVr4, even AT&T introduced #!name, but the AT&T 
variant of the OS did not correct their scripts, so if you are on a UnixWare 
installation, you will have fun.

Unfortunately, POSIX cannot standardize #!name. This is because POSIX does not 
standardize PATHs and because the scripts marked that way would need to be 
scripts that call the POSIX shell. The official method to get a POSIX shell is 
to call this:

	sh			# to make sure you have a Bourne Shell alike
	PATH=`getconf PATH`	# to get a POSIX compliant PATH
	sh			# to get a POSIX shell, that muust be the first
				# 'sh' in the POSIX PATH

/bin/sh definitely does not start a POSIX shell.....

Jörg

-- 
 EMail:joerg at schily.net                    (home) Jörg Schilling D-13353 Berlin
       joerg.schilling at fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
 URL:  http://cdrecord.org/private/ http://sourceforge.net/projects/schilytools/files/'