Front page | perl.perl5.porters |
Postings from July 2009
Re: [perl #67880] #!perl -CS again
From:
Nicholas Clark
Date:
July 26, 2009 03:41
Subject:
Re: [perl #67880] #!perl -CS again
Message ID:
20090726104115.GA60303@plum.flirble.org
On Sat, Jul 25, 2009 at 11:46:43AM -0700, Father Chrysostomos wrote:
> perl 5.10.0 dies if -C occurs on the #! line. This was to avoid the
> problem of the options being present but not doing anything (see
> #34087). But this breaks many existing programs that were relying on
> the kernel to read the first line and pass the switch to perl.
>
> The attached patch changes perl to die only when the #! switch differs
> from the command line switch.
Thanks applied with 4ba71d51f72efb2af8dc9748dd62219261f2e1fd
I really don't like the
conditional_expression || expression_with_side_effects;
style in C, so I changed that to an if with bd0ab00df494c0f393ee5623b3a949ae
diff --git a/toke.c b/toke.c
index 56e9620..658d163 100644
--- a/toke.c
+++ b/toke.c
@@ -4001,11 +4001,10 @@ Perl_yylex(pTHX)
do {
bool baduni = FALSE;
if (*d1 == 'C') {
- const char *d2 = d1;
- d2++;
- parse_unicode_opts( (const char **)&d2 )
- == PL_unicode
- || (baduni = TRUE);
+ const char *d2 = d1 + 1;
+ if (parse_unicode_opts((const char **)&d2)
+ != PL_unicode)
+ baduni = TRUE;
}
if (baduni || *d1 == 'M' || *d1 == 'm') {
const char * const m = d1;
and added some more tests with 74b2b4b1788882713af5484605612fc6ec67405d.
> Since this is a 5.10 regression, is there any chance it could make its
> way into 5.10.1?
That's Dave's call.
Given how the features -C enable work, have to be done early, and can't really
be undone, and given how #! options on the command line are actually parsed:
$ cat /tmp/line1.pl
print "Warns: ", undef, "\n";
#line 1
#!perl -w
__END__
$ cat /tmp/line2.pl
print "Silent: ", undef, "\n";
#line 2
#!perl -w
__END__
$ perl /tmp/line1.pl
Use of uninitialized value in print at /tmp/line1.pl line 1.
Warns:
$ perl /tmp/line2.pl
Silent:
$
I don't think we can actually do any better than this. -C now behaves like
-T and -t, and people (and OS kernels) don't have a problem with how that
works.
On Sat, Jul 25, 2009 at 01:12:10PM -0700, Father Chrysostomos wrote:
> I think this is important enough for some people (see the woeful
> message at the end of #34087) that it deserves a mention in perldelta.
> diff -Nurp blead/pod/perl5110delta.pod bleadcopy2/pod/perl5110delta.pod
> --- blead/pod/perl5110delta.pod 2009-07-22 02:56:11.000000000 -0700
> +++ bleadcopy2/pod/perl5110delta.pod 2009-07-25 13:09:10.000000000 -0700
> @@ -209,6 +209,13 @@ kill process "0", which would terminate
> systems. Since process identifiers are always integers, killing a non-numeric
> process is now fatal.
>
> +=item C<-C> on the shebang line is once more permitted
> +
> +if it is also specified on the command line. C<-C> on the shebang line used
> +to be a silent no-op I<if> it was not also on the command line, so perl
> +5.10.0 disallowed it, which broke some scripts. Now perl checks whether it
> +is also on the command line and only dies if it is not.
> +
> =back
>
> =head1 New or Changed Diagnostics
Thanks, applied fc46f0f6acf947702bfc9ac32e05b1f4e8f4c720
Nicholas Clark