Is it possible to override hashbang/shebang path behavior
I have a bunch of scripts (which can't be modified) written on Windows. Windows allows relative paths in its #!
commands. We are trying to run these scripts on Unix but Bash only seems to respect absolute paths in its #!
directives. I've looked around but haven't been able to locate an option in Bash or a program designed to replace and interpreter name. Is it possible to override that functio开发者_StackOverflownality -- perhaps even by using a different shell?
Typically you can just specify the binary to execute the script, which will cause the #!
to be ignored. So, if you have a Python script that looks like:
#!..\bin\python2.6
# code would be here.
On Unix/Linux you can just say:
prompt$ python2.6 <scriptfile>
And it'll execute using the command line binary. I view the hashbang line as one which asks the operating system to use the binary specified on the line, but you can override it by not executing the script as a normal executable.
Worst case you could write some wrapper scripts that would explicitly tell the interpreter to execute the code in the script file for all the platforms that you'd be using.
精彩评论