New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code embeddable in argument to -i switch #12128
Comments
From jdmadea@gmail.comCreated by jeremy@cpan.orgThis is a bug report for perl from jeremy@cpan.org, ----------------------------------------------------------------- Showing that code can be embedded in the argument to the -i $ perl -i' e warn 1' And this shows that, with two spaces, the bug is not exercised: $ perl -MO=Deparse -i' e warn 1' -e'warn 2' The bug was first reported by EvanCarroll on perlmonks.org http://www.perlmonks.org/?node_id=971866 Here is a patch. Inline Patch--- orig-perl.c 2012-05-22 15:43:39.000000000 -0400
+++ perl.c 2012-05-22 15:45:45.000000000 -0400
@@ -3187,11 +3187,8 @@
PL_inplace = savepvn(start, s - start);
}
- if (*s) {
- ++s;
- if (*s == '-') /* Additional switches on #! line. */
- s++;
- }
+ if (*s == '-') /* Additional switches on #! line. */
+ s++;
return s;
case 'I': /* -I handled both here and in parse_body() */
forbid_setid('I', FALSE); Perl Info
|
From @ap* Jeremy Madea <perlbug-followup@perl.org> [2012-05-25 09:50]:
Red herring.
That is what you can in fact do. If the switch you embed is a -e then
This is not actually a bug. Consider And I believe that comment in the code you propose to remove:
… is a honking big clue that Eric’s conjecture is right. In which case your proposed replacement:
… by preserving the comment while removing the functionality, makes it Now, I don’t know if we want to *keep* the feature. It is a workaround, But it is not there on accident so it shouldn’t be removed the same way |
The RT System itself - Status changed from 'new' to 'open' |
From jeremy@cpan.orgI'm sorry, but I believe you misunderstand the nature of this bug and my The switch parsing in general may or may not be considered buggy. It This fix is for a separate issue. The bug this patch fixes is that -i behaves differently from other Group #1: With dash, no space. Unpatched. $ perl -i'-e1' Patched. $ ./perl -i'-e1' Group #2: Without dash, no space. Unpatched. $ perl -i'e1' Patched. $ ./perl -i'e1' Group #3: With dash, one space. Unpatched. $ perl -i' -e1' Patched. $ ./perl -i' -e1' Group #4: Without dash, one space. Unpatched. NOTE DIFFERENT BEHAVIOR. $ perl -i' e1' Patched. (Different behavior fixed.) $ ./perl -i' e1' Group #5: With dash, two spaces. Unpatched. $ perl -i' -e1' Patched. $ ./perl -i' -e1' Group #6: Without dash, two spaces. Unpatched. $ perl -i' e1' Patched. $ ./perl -i' e1' Group #7: With dash, three spaces. Unpatched. $ perl -i' -e1' Patched. $ ./perl -i' -e1' Group #8: Without dash, three spaces. Patched. $ ./perl -i' e1' $ perl -i' e1' And so on. I believe that discrepancy in behavior probably was an accident and I do not believe this patch will break if #!/usr/bin/perl -w -i is executed as /usr/bin/perl '-i -w' foo.pl I don't have such a system though. If there is no test for that case, On Wed Jun 06 21:04:24 2012, aristotle wrote:
|
From @ap* Jeremy Madea via RT <perlbug-followup@perl.org> [2012-06-07 13:25]:
So I did.
Thanks! That was a helpful illustration.
That seems more likely to me now as well. |
From @cpansproutOn Thu Jun 07 03:38:16 2012, jmadea wrote:
Does anyone know which system that is? Is it possible to probe for it
Could you write tests for the cases that your patch changes? -- Father Chrysostomos |
From jeremy@cpan.orgOn Fri Jun 08 18:03:22 2012, sprout wrote:
Eric Brine <ikegami@adaelis.com> suggested this was a possibility in a
My initial report was poorly worded as I was still partially focused on While looking at the behavior reported by EvanCarroll, I found -i The following emit warnings: With two spaces after the argument, these do not emit warnings: I quickly found that there were other switches that behaved similarly to For instance, while these do emit warnings: The following do not: My patch changes -i to work as other switches (like -F and -C) do. In other words, after the patch, the following no longer emit warnings: You asked if I can add a test case for it. I suppose I could. But do you -j -- |
From @cpansproutOn Sat Jun 09 08:06:27 2012, jmadea wrote:
Stranger things have happened. -- Father Chrysostomos |
From [Unknown Contact. See original ticket]On Sat Jun 09 08:06:27 2012, jmadea wrote:
Stranger things have happened. -- Father Chrysostomos |
From @cpansproutOn Sun Jun 10 22:41:54 2012, sprout wrote:
Oops. I forgot the smiley: :-) -- Father Chrysostomos |
From [Unknown Contact. See original ticket]On Sun Jun 10 22:41:54 2012, sprout wrote:
Oops. I forgot the smiley: :-) -- Father Chrysostomos |
From jeremy@cpan.orgApologies for any duplicates. I think I hit the link to toggle the CC On Fri Jun 08 18:03:22 2012, sprout wrote:
Eric Brine <ikegami@adaelis.com> suggested this was a possibility in a
My initial report was poorly worded as I was still partially focused on While looking at the behavior reported by EvanCarroll, I found -i The following emit warnings: With two spaces after the argument, these do not emit warnings: I quickly found that there were other switches that behaved similarly to For instance, while these do emit warnings: The following do not: My patch changes -i to work as other switches (like -F and -C) do. In other words, after the patch, the following no longer emit warnings: You asked if I can add a test case for it. I suppose I could. But do you -j -- |
Migrated from rt.perl.org#113046 (status was 'open')
Searchable as RT113046$
The text was updated successfully, but these errors were encountered: