Ben Finney <[EMAIL PROTECTED]> writes: > The shebang line (the initial line of the file beginning with "#!") > takes advantage of OS kernels that determine how to execute a file > based on the first few bytes of the file. The shebang line tells the > kernel that this file should be executed by passing it as input to a > process started by another command. > > The specified command takes the form of a fully-qualified file path, > and zero or one arguments to the program. That command is then > executed by the kernel, and the Python program file is passed as > input to the resulting process.
As was pointed out later in the thread, this description is partially untrue. The program isn't passed as input to the interpreter. Instead, the path to the program is appended as a command-line argument to the interpreter. Thus the kernel starts a command of the form: <word after the shebang> <optional single argument after the first word> <path to the program> Examples: filename: /home/foo/bar.py shebang line: #! /usr/bin/python command line invoked: /usr/bin/python /home/foo/bar.py filename: /home/foo/Makefile shebang line: #! /usr/bin/make -f command line invoked: /usr/bin/make -f /home/foo/Makefile For more information on shebang processing, see <URL:http://foldoc.org/index.cgi?shebang> for a basic description, and <URL:http://www.in-ulm.de/~mascheck/various/shebang/> for lots of gory detail. -- \ "There's no excuse to be bored. Sad, yes. Angry, yes. | `\ Depressed, yes. Crazy, yes. But there's no excuse for boredom, | _o__) ever." -- Viggo Mortensen | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list