On Saturday, November 24, 2001, at 03:21 pm, Pete French wrote:
> this is one of the great beauties of UNIX, the fact that you can take
> interpretted code and run it in a way that is directly equivalent to
> a compiled binary file as far as the system is concernned.
I'd be inclined to quarrel with this interpretation, Pete. What the
kernel is doing isn't taking the script and running it as a binary --
specifically its:
1. looking for the hash bang and reading what comes after that.
2. loading that code as if it were a binary (er, which it is. eg sh, awk
or sed)
3. ducking out and letting the binary get on with doing its thing (eg
running the script).
The script remains a script. It isn't magically turned into a binary by
hash-bang; it still has to be interpreted by the actual binary runtime
environment provided by sh, awk or sed, and the bytestream the kernel gets
to see is no different from what it would see if the same script were run
conventionally using "sh <script>".
So, yes, the kernel is smart to recognise hash-bang as "run what follows
on this line". But once that is done, what follows (sh, awk or sed or
whatever) also has to be smart to recognise that in this case the -f flag
refers to the following lines of script, not to an external script file
that needs sh assistance to load).
I think...
--
el bid
|