[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a "script-relative" version of env
From: |
E R |
Subject: |
a "script-relative" version of env |
Date: |
Fri, 27 May 2011 12:27:22 -0500 |
Hi all,
This is not a bash bug, but I am hoping the people on this list would
find the question interesting...
I have found it useful to have a "script-relative" version of
/usr/bin/env. Whereas env determines an interpreter's location based
on PATH, this version would determine the interpreter's location based
on the location of the script.
Example - the shebang line:
#!/usr/bin/relexec ../bin/perl
would execute the interpreter ../bin/perl relative to the location of
the script. The argv array of relexec will be:
argv[0] = "/usr/bin/relexec"
argv[1] = "../bin/perl"
argv[2] = "/some/path/to/script"
In this case relexec would exec /some/path/to/bin/perl with the
arguments in argv starting from argv[2].
If anyone is interested I can explain why/how I use this.
Questions:
- Does something like this already exist?
- I've noticed that the argument passed to the she-bang interpreter
always seems to be an absolute path when commands are executed from a
shell. Are there cases where that will not be true?
- a "script-relative" version of env,
E R <=