shebang strange thing...

Brian Lenihan brian_l at yahoo.com
Wed Jun 25 01:46:17 EDT 2003


"Greg Ewing (using news.cis.dfn.de)" <g2h5dqi002 at sneakemail.com> wrote in message news:<bdb22c$psllg$1 at ID-169208.news.dfncis.de>...
> Erik Max Francis wrote:
> > (Mac gets even fewer points,
> > since it chose to do deliberately do smoething even more different.) 
> 
> That's debatable. At least the Mac still only uses *one*
> character for each end-of-line...

That's all fine, but the Mac does exhibit one problem I can't fathom:

If you have two or more Python installations, the first one in
your path gets invoked no matter what the shebang line says.

If the first line of a script is #!/usr/local/bin/python, I expect the
interpreter located in /usr/local/bin to execute the script, not the
one in /usr/bin, or the one in /sw/bin, but that is what you get if
you run the script as an executable.

The process list shows why - python is called without a path, e.g. as
"python".  The same behavior occurs if the shell is bash or tcsh.
As far as I know, OS X is the only "modern" Unix to behave this way.

This behavior caused me a large amount of angst until I figured out
what the problem was.  I had to resort to writing a script that
renames the pythons in /usr/bin/ and /sw/bin when I don't want them
and renames them back if and when I do.

I mostly use Python 2.3 from CVS, but I haven't been able to get
mod_python working with a Framework build yet, so I need to switch
to Fink's python once in a while.




More information about the Python-list mailing list