[Python-Dev] #! magic

Oleg Broytmann phd at phd.pp.ru
Sun Jan 20 23:36:57 CET 2008


On Mon, Jan 21, 2008 at 12:17:20AM +0200, Tristan Seligmann wrote:
> * Oleg Broytmann <phd at phd.pp.ru> [2008-01-20 20:12:38 +0300]:
> 
> > On Sun, Jan 20, 2008 at 06:00:31PM +0100, Christian Heimes wrote:
> > > #!/usr/bin/env python -E -s
> > 
> >    On most Unicies #! magic may have only one parameter after the program;
> > the program here is env, the parameter is python, and that's all. Adding
> > python options will result in different errors - some platforms silently
> > ignores the options, some reports an error, some tries to find "python -E -s"
> > in the PATH and report "Bad command or file name".
> 
> Distro tools shouldn't be using /usr/bin/env in any case. Does
> 
> #!/usr/bin/python -E -s
> 
> work?

   No:

Unknown option: - 
usage: /usr/bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

   -Es together work. I think this is why Unix has the tradition of
combining options.

PS. My python doesn't understand -s, so I tested a different options, but
the result is the same. There are Unix variants that understand many
options (I believe FreeBSD allows them) but most allow no more than one
parameter in #!.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-Dev mailing list