in reply to Conditionally executing different versions of Perl
The solution (or at least a solution) is to call /usr/bin/env, which itself does shebang-emulation, instead of calling your wrapper directly.
/path/to/perlwrapper:
test.pl:#!/usr/bin/perl print "wrapper about to execute @ARGV\n"; exec "/usr/bin/perl", @ARGV;
And then executing ./test.pl should work (at least, it did for me). Changing all your scripts to use env in their shebang line is a pain (you cannot just repace /usr/bin/perl with your wrapper), but it's the only way you can emulate nested shebangs. Otherwise, you'd have to make this version-delegation wrapper into a compiled binary.#!/usr/bin/env /path/to/perlwrapper print "hello world!\n";
There are also further complications: It appears that if the shebang line doesn't contain the word "perl", then perl itself will try to emulate shebangs and start an infinite loop (re-invoking your version-delegation wrapper). So I got weird results when I first named it "wrapper" instead of "perlwrapper"...
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Conditionally executing different versions of Perl
by MidLifeXis (Monsignor) on Oct 19, 2006 at 17:28 UTC |