[TUHS] History of #! interpretation in Unix

John Cowan cowan at mercury.ccil.org
Tue Jan 18 06:47:18 AEST 2011


Warner Losh scripsit:

> The alternatives are worse.

You're making my point for me.

> 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.

Right.

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

Unfortunately not.  The current situation is that when a shell sees a
shebang-free script, it decides whether it is Posix enough to execute
that script.  So ash, bash, dash, ksh, zsh will all run shebang-free
scripts themselves, whereas csh, tcsh will defer to /bin/sh.

What I am arguing for is that *all* shells should defer to /bin/sh
to execute shebang-free scripts.  As things stand, the behavior of a
shebang-free script depends on which shell is trying to run it, whereas
it should only depend (says I) on the identity of /bin/sh.

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

Yes, and that's a Good Thing.

-- 
The experiences of the past show                John Cowan
that there has always been a discrepancy        cowan at ccil.org
between plans and performance.                  http://www.ccil.org/~cowan
        --Emperor Hirohito, August 1945



More information about the TUHS mailing list