[Starlingx-discuss] MultiOS: call of python via #!/usr/bin/env

Jeremy Stanley fungi at yuggoth.org
Wed Sep 11 13:35:30 UTC 2019


On 2019-09-11 11:06:52 +0200 (+0200), Dominig ar Foll (Intel Open Source) wrote:
> We have a error raised by the Open Build System from OpenSUSE
> (OBS) due to the use of "#!/usr/bin/env" as interpreter. This
> stops the OBS to correctly detect dependencies. The use of
> /usr/bin/env is tricky as it creates an undefined  build/run
> dependency on the target.
> 
> Could someone explains why such trick is used ?

The short answer is that, historically, it was hard to guess what
the full path to a particular script interpreter might be on any
given system, but env is pretty much always at a known location so
can be used to perform a dynamic path search for the named
interpreter executable. This was a popular technique to improve
script portability, but has also fallen victim to "cargo cult"
behavior in the years since... developers just repeat the pattern
without considering whether there's still any reason to do so.

> I would need to get rid of it. Just want to find what will be
> required to be changed.
> 
> If this is just to call python2 then #!/usr/bin/python2 would do.
[...]

Assuming the interpreter you want will always be available at
/usr/bin/python2 on systems where these scripts are meant to be run,
that's the recommended solution, yes. You can also use some
distbuild-time routine to patch the shebang lines of all scripts to
refer to the correct interpreter path for the target system if it
differs from the norm.
-- 
Jeremy Stanley
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: not available
URL: <http://lists.starlingx.io/pipermail/starlingx-discuss/attachments/20190911/dfa4cf5d/attachment.sig>


More information about the Starlingx-discuss mailing list