#!/bin/env problem Was: Re: Backwards emulation rather than backwards compatibility?
Dave Kuhlman
dkuhlman at rexx.com
Tue May 28 17:43:53 EDT 2002
While we're thinking about this, here is something I stubbed my toe
on today:
I typically start my scripts with a first line like the following:
#! /usr/bin/env python
Quite a few files in Python2.2.1/Lib do likewise.
But, when I tried to add an option to be passed to the Python
interpreter by changing the first line to:
#!/usr/bin/env python -t
I get an error message:
/usr/bin/env: python -t: No such file or directory
Shouldn't I be able to pass a flag to the Python interpreter?
Looking at the env man page did not help. And, quotes around
"python -t" did not help. Is there another "trick"?
So I guess I am just asking for a solution to one more problem in
addition to the one Chris is describing.
I'm on Linux, by the way.
- Dave
Chris Barker wrote:
>
>
> Christopher Browne wrote:
>> Wouldn't it be easier to simply change the first line to:
>> #!/usr/bin/python1.5
>
> Only on *nix....
>
> I'd love to see a platform independent way of doing this. Maybe
> all we need to do is have the Python interpreter front-end look
> for that classic *nix line, and then dispatch the script to the
> correct interpreter for you. And have it work the same way on all
> platforms.
>
> Yes, it's too late to have code like this in old scripts, but it
> only gets worse with each new version. This was brought up two
> versions ago (2.0). Also, while someone would have to go back and
> add a line to all their old scripts, this is a whole lot less work
> than checking each for incompatability with new features. OF
> course, that being said, RedHat seems to be incapable of adding a
> "1.5" to all their config scripts, so maybe there is more to it
> than I imagine.
>
> All we need is a very simple dispatching front end, that looks for
> a key at the top of the __main__ script, and invokes the correct
> interpreter. A sysadmin could decide how many versions they want
> to support, but it should be easy to have a half a dozen non each
> machine. This really is a problem that needs to be addressed, and
> it just seems so easy!
>
> -Chris
>
>
>
>
--
Dave Kuhlman
dkuhlman at rexx.com
http://www.rexx.com/~dkuhlman
More information about the Python-list
mailing list