1

Not sure why but:

   /usr/bin/env IPYTHONDIR=/tmp/.ipython python

when running from command line works fine. But stuck as a shabang line:

   #!/usr/bin/env IPYTHONDIR=/tmp/.ipython python

Environment: Debian 7.8 x86

Anybody has ideas why?

Sergey
  • 978
  • 2
  • 11
  • 33
  • possible duplicate of [How to use multiple arguments with a shebang (i.e. #!)?](http://stackoverflow.com/questions/4303128/how-to-use-multiple-arguments-with-a-shebang-i-e) – Patrick Maupin Aug 13 '15 at 00:24
  • That should work according to http://linux.die.net/man/1/env, however python is not ipython, instead it runs ipython-script.py (at least on my platform with the Anaconda distribution). Also the shebang line you have will set IPYTHONDIR only in the environment of the process running the script its in. –  Aug 13 '15 at 00:25
  • @TrisNefzger -- the problem is not with env -- the problem is with the bash handling of `#!`. bash passes the entire rest of the command line as a single parameter. It is as if you had typed (on the command line) `/usr/bin/env 'IPYTHONDIR=/tmp/.ipython python'` – Patrick Maupin Aug 13 '15 at 00:39
  • @PatrickMaupin: Ah, I see. Thanks. What I would do is set any necessary variables on the command line just before the script name and which has shebang '/usr/bin/env/ python'. If necessary that command line could be wrapped in another script and a script could be written to automate production of such wrappers or apply them on the fly. –  Aug 13 '15 at 21:03

1 Answers1

0

Unfortunately, #! passes IPYTHONDIR=/tmp/.ipython python as a single parameter to /usr/bin/env.

One thing I have used as a workaround is to have another script that sets up variables and then invokes my real program. It is silly.

Here is some more information:

How to use multiple arguments with a shebang (i.e. #!)?

Community
  • 1
  • 1
Patrick Maupin
  • 8,024
  • 2
  • 23
  • 42