[TUHS] History of #! interpretation in Unix

John Cowan cowan at mercury.ccil.org
Sun Jan 16 19:55:49 AEST 2011

Warren Toomey scripsit:

> Hi all, best wishes for 2011. I had an e-mail from Sven Mascheck asking about
> the history of #! interpretation in System V. I couldn't find any #!
> code in the kernels before SysVR4. 

That's correct.  The feature was added to the 8th Research edition kernel,
but didn't migrate to the System III/V line until SVR4.  Shebangs began
very early in BSD as a csh-only hack, but appeared as a config option
in kernels as early as 2.8BSD, according to Wikipedia; 4.2BSD was the
first release that turned them on by default.

Perl has always (I think) had its own shebang support; you can get Perl
to exec an arbitrary interpreter for a script provided it has a shebang.
Modern shells will use /bin/sh to run scripts that *don't* have shebangs,
except for ksh which considers itself /bin/sh-compatible, and therefore
runs such scripts itself.

I am expressing my opinion.  When my            John Cowan
honorable and gallant friend is called,         cowan at ccil.org
he will express his opinion.  This is           http://www.ccil.org/~cowan
the process which we call Debate.                   --Winston Churchill

More information about the TUHS mailing list