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

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

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
June 6, 2012 21:04
Subject:
Re: [perl #113046] Code embeddable in argument to -i switch
Message ID:
20120607040352.GB15659@fernweh
* Jeremy Madea <perlbug-followup@perl.org> [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 perlmonks.org

This is not actually a bug. Consider
http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=CALJW-qH4L3kNp-exwgNsTgz-QDrpymbmUhQEbkuS2=uhBQJfcg%40mail.gmail.com

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


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