[TUHS] History of #! interpretation in Unix

Warner Losh imp at bsdimp.com
Tue Jan 18 02:35:34 AEST 2011


On 01/16/2011 14:37, John Cowan wrote:
> Sven Mascheck scripsit:
>> With /bin/sh you actually meant any shell calling "itself"?
>> Otherwise I'm afraid, I have some difficulties following you.
> I mean that whereas (t)csh uses /bin/sh to run scripts with no
> shebangs, the Posix-compatible shells execute scripts with no
> shebangs directly.  And this is Bad.

The alternatives are worse.

On a sysIII system, you had the situation where scripts would be 
executed by whatever your shell.  So if you put a script on the system, 
you had to make sure everybody used csh and write it in csh, or you had 
to make sure nobody did and write it in /bin/sh.

The current situation says that 'you must opt-in' to a different shell, 
which leads to more predictable behavior.

Later, #! processing moved into the kernel so that interpreters would 
execute things directly.

To cope with that confusing mess, the perl env hack was born so that the 
perl scripts could execute anywhere, independent of the shell driving it.

Warner



More information about the TUHS mailing list