develooper Front page | perl.perl5.porters | Postings from June 2012

Re: [perl #113046] Code embeddable in argument to -i switch

Thread Previous | Thread Next
Aristotle Pagaltzis
June 6, 2012 21:04
Re: [perl #113046] Code embeddable in argument to -i switch
Message ID:
* Jeremy Madea <> [2012-05-25 09:50]:
> Example:
> $ perl -i'.bak -e warn 1;' -e'warn 2'
> 1 at -e line 1.
> 2 at -e line 2.
> Showing that code can be embedded in the argument to the -i command
> line switch.

Red herring.

> Other switches can be embedded as well.

That is what you can in fact do. If the switch you embed is a -e then
of course that will let you embed code, but ultimately this is about
switches, not code.

> The bug was first reported by EvanCarroll on

This is not actually a bug. Consider;

And I believe that comment in the code you propose to remove:

> -       if (*s) {
> -           ++s;
> -           if (*s == '-')      /* Additional switches on #! line. */
> -               s++;
> -       }

… is a honking big clue that Eric’s conjecture is right.

In which case your proposed replacement:

> +       if (*s == '-')  /* Additional switches on #! line. */
> +           s++;

… by preserving the comment while removing the functionality, makes it
a lie.

Now, I don’t know if we want to *keep* the feature. It is a workaround,
and in and of itself the behaviour is crazy.

But it is not there on accident so it shouldn’t be removed the same way
as something that were.

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