#! is not next to demigodliness

Skip to first unread message


Mar 13, 1984, 1:00:56 AM3/13/84
The major reason for installing the #! magic-number mechanism in the kernel
is to unify all the different ways of executing a program written
in various languages. Certain magic numbers have always told the kernel
about details in the layout of native machine code; it seemed natural
to generalize a bit to allow specification of an interpreter. Thus, if
the facility is used, neither sh nor csh needs to resort to heuristics to
determine which shell scripts should be executed by whom; the script itself
announces its interpreter (yes, it can be Pascal too). If you want to execute
a program, you can do it with "exec" and not worry about whether it is a shell
script and if so, which shell.

A secondary gain is the possibility of set-uid scripts. As has been pointed
out, there are perils aplenty. $PATH is the most obvious; in the
Bourne shell, games with $IFS are also to be guarded against.

I am not now, nor have I ever been, a member of the demigodic party.

Dennis Ritchie

Reply all
Reply to author
0 new messages