
Oleg Broytmann wrote:
On Tue, Mar 04, 2008 at 10:35:42PM +1000, Nick Coghlan wrote:
not needing an explicit interpreter option makes it more shebang friendly
Sorry, I missed something here. How does one combine a zipfile with a shebang script?!
Very carefully ;)
As a more helpful answer, the ZIP spec allows additional data to be included in the file before the ZIP header. A more common way of using this is to add a zip file on to the end of an ELF executable while still using normal zipfile utilities to read the data in the zip file section and ignore the executable part.
It turns out you can actually use the same trick to prepend a shebang line like "/usr/bin/env python" and a newline character - the whole zip file is still a binary file, but that doesn't prevent the shell from reading that first line of text and handing the file over to Python for execution.
The fact that this actually works was also news to me when the issue I linked in my previous post was first brought to my attention :)
Cheers, Nick.