"Gabriel Genellina" <[EMAIL PROTECTED]> wrote:

> En Sat, 03 Feb 2007 07:35:22 -0300, Peter Otten <[EMAIL PROTECTED]>  
> escribió:

>> #!/usr/bin/env python2.5
>>
>> python2.5 will be that single argument and no options are possible at  
>> all.
>> What might be the reasons for such a seemingly arbitrary limitation?

> The shell parses that line, not Python, so you should look into its  
> documentation.

Bzzt!  In any modestly recent Unix version (meaning fifteen years
old or younger), it has been the kernel that parsed the #! line,
not the shell.

As for *how* the kernel parses that line, it varies between Unix
versions.  Linux, at least versions 2.4 and 2.6, takes everything
after the interpreter and passes it as a single argument to the
interpreter, with leading and trailing whitespace stripped.  Thus

    #! /usr/bin/interpreter  foo bar   gazonk del  

will give the parameter "foo bar   gazonk del" to the interpreter.

SunOS 5.10 (aka Solaris 10) on the other hand, splits the line on
whitespace and passes only the first word as parameter, and would
thus give only "foo" to the interpreter for the same #! line.

I seem to remember having used some Unix flavor that allowed
multiple words as arguments, and thus passed the four words
"foo", "bar", "gazonk" and "del" as arguments for the above #!
line, but I don't remember what Unix that was.


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"Adde parvum parvo magnus acervus erit"       ! bellman @ lysator.liu.se
          (From The Mythical Man-Month)       ! Make Love -- Nicht Wahr!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to