develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Perl 7 - updates

Thread Previous | Thread Next
Kent Fredric
July 4, 2020 11:20
Re: Perl 7 - updates
Message ID:
On Sat, 4 Jul 2020 at 18:21, Todd Rinaldo <> wrote:

> Cool. The looks like -x will save the day here too and we can put use vX after #!/usr/local/bin/perl. Do you agree?

When you have a bashguard like:
    #!<not perl>

You have to assume the guard includes -x, because you can't rewrite
it, and that guard will *always* be dispatched to the non-perl target
first (unless you explicitly call the script with -x outside), and you
have to assume the script will pass -x because if it doesn't, it will
cause infinite recursion due to the non-perl shebang.

When you have a bashguard like:


You have to Inject the "v" between the guard and the perl code

But '-x' can't save the day here. If you put it on the leading
shebang, because the shebang already includes "#!perl", and so
invoking it with '-x" will always find the same starting point.

And that means the "guard" code, when run under the perl interpreter,
will be illegal code running before a version declaration.

eval "echo \"bad interpreter\"; exit 1"
   if 0;
print "we good";

^ This demonstrates that even if you inject a new shebang, running it
explicitly with -x still fails. ( And you can't pass -x inside the
hasbang: "Can't emulate -x on #! line". )

(There is more than one way to do a bash guard)



Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About