On Jul 12, 2007, at 1:58 PM, Phillip J. Eby wrote: > I don't have any particular objection to using runpy for this, but I > believe that this shebang line won't actually work on certain non-BSD > OSes, such as most Linux versions, which allow you to have at most > *one* argument to a #! line, and will combine anything after the > executable portion into a single argument. This means that the only > workable form of this line for cross-platform use is: > > #!/usr/bin/python2.6 -z > > And of course that won't work if Python is somewhere else. You can't > both use env to invoke Python, *and* expect arguments to work. env > will receive a single argument of "python -m runpy -p", which it will > then try to invoke. On Mac OS and various other BSDs, your example > will work correctly, but it won't work most anywhere else, as few > OSes actually support passing individual arguments from a #! line. > See: > > http://www.in-ulm.de/~mascheck/various/shebang/
Ah, but you *can* use some quite clever quoting to get that effect. E.g. this starts up python with /usr/bin/env and a -O argument: #!/bin/sh """"exec /usr/bin/env python -O $0 "$@";" """ Credit for this trick originally belong to someone else: I found this on some website, but I don't know where anymore. I'll leave it as a exercise to the reader to figure out how it works. :) James _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com