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

Re: Perl 7 - updates

Thread Previous | Thread Next
From:
Kent Fredric
Date:
July 4, 2020 11:20
Subject:
Re: Perl 7 - updates
Message ID:
CAATnKFBOW_U0sL43xFUXuBv94E-TWd+8W0SxZgY21n9pEdf7ug@mail.gmail.com
On Sat, 4 Jul 2020 at 18:21, Todd Rinaldo <toddr@cpanel.net> 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>
     <guard>
    #!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:

    #!perl
    <guard>
    <perlcode>

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.

#!perl
eval "echo \"bad interpreter\"; exit 1"
   if 0;
die "ILLEGAL CODE";
#!perl
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)

-- 
Kent

KENTNL - https://metacpan.org/author/KENTNL

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About