Thanks drl for the idea. It is similar to what I am doing now, which is running sed scripts to substitute interpreters in shebangs.
It is really strange that such an issue has lingered for a long time without a solution. I can imagine a couple of things that could solve this:
- Changes to the exec() system function that porter referred to, such that it can handle environment variables. This might be too hard.
- Create a program that takes the name of an environment variable and runs the executable that the environment variables points to. So if the program is called envexec, the shebang would look like this:
I imagine that one of the requirements of such a program is that it doesn't create a sub-shell on which to execute that command, but rather execute the interpreter in the same shell the system would execute it under if it was normally configured in the shebang.
Does anyone know of any programs around that do that? Or, for that matter, an easy way to implement such a program?