in reply to Re: shebang line
in thread shebang line

In all of the UNIX-style OSes I know of, shebang interpretation is left to the kernel, not to the shell. the #! is basically just another magic number for a particular executable type. The kernel execs the interpreter specified, passing the fully qualified name of the script as the last parameter.

Replies are listed 'Best First'.
Re: not the shell
by dmmiller2k (Chaplain) on Jan 04, 2002 at 21:17 UTC

    I believe you are right -- when attempting to execute a file, the kernel (in the form of the exec family of system calls), opens the file, reads some number of bytes (32 or 256, or whatever), and upon detecting a shebang, copies the command line embodied there, closes the file and builds a new command line using the shebang as the command, with the name of the original file appended and followed by any command-line arguments. The process may repeat as needed until finally some binary is executed, using a command line commensurate with all the preceding steps.

    dmm

    You can give a man a fish and feed him for a day ...
    Or, you can
    teach him to fish and feed him for a lifetime