How to manage python shebang on mixed systems?

Peter J. Holzer hjp-python at hjp.at
Wed Nov 9 09:52:51 EST 2022


On 2022-11-07 21:27:26 +0000, Chris Green wrote:
> Barry Scott <barry at barrys-emacs.org> wrote:
> > env is always available as /usr/bin/env - I think its spec'ed in posix that way.
> > 
> > The only reason that things are in /bin are for systems that need a subset of
> > programs to boot the system to point it can mount /usr. env is not going to be
> > needed for that use case.
> > 
> Given that the problem system is running a very old Linux I'm not sure
> what chance there is that it's fully posix compliant.

It doesn't have to be fully posix compliant. Just reasonably posix
compliant.


> If using "#!/usr/bin/env python3" is a way of avoiding problems if
> python3 isn't in /usr/bin then why is it any better depending on env
> being in /usr/bin.

Because env is a standard unix utility which has been in the same place
for 30 years or so and is unlikely to be somewhere else or missing
completely. Python3 OTOH is not a standard unix utility. It may not be
there at all or it may be installed in /usr/local or /opt or even in the
user's home directory.

(Yes, of course "standard unix utilities" may be missing, too. For
example on an embedded system there might only be the bare minimum to
run the application. I even had a redhat system once which didn't have
grep installed.)

(Personally I avoid using env: I don't want my scripts to depend on the
PATH. But that's a different issue.)

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20221109/c2fc4f5d/attachment.sig>


More information about the Python-list mailing list