From: Nicholas Clark Date: Thu, 28 Aug 2008 13:11:44 +0000 (+0000) Subject: Fix #30660: Repeated spaces on shebang line stops option parsing X-Git-Tag: accepted/trunk/20130322.191538~12841 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3133c8951f1251e8d76e1b8b31b8ec2ee12bc89;p=platform%2Fupstream%2Fperl.git Fix #30660: Repeated spaces on shebang line stops option parsing From a patch and test sent by Renée Bäcker in <48B271A3.80808@smart-websolutions.de> p4raw-id: //depot/perl@34234 --- diff --git a/perl.c b/perl.c index e41ae96..98437a3 100644 --- a/perl.c +++ b/perl.c @@ -3431,8 +3431,10 @@ Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n\n"); return s; case '*': case ' ': - if (s[1] == '-') /* Additional switches on #! line. */ - return s+2; + while( *s == ' ' ) + ++s; + if (s[0] == '-') /* Additional switches on #! line. */ + return s+1; break; case '-': case 0: diff --git a/t/run/switches.t b/t/run/switches.t index 8e1b56c..e62eda4 100644 --- a/t/run/switches.t +++ b/t/run/switches.t @@ -11,7 +11,7 @@ BEGIN { BEGIN { require "./test.pl"; } -plan(tests => 69); +plan(tests => 70); use Config; @@ -350,3 +350,19 @@ $r = runperl( stdin => 'zomtek', ); is( $r, "affe\n", '-E works outside of the block created by -n' ); + +# RT #30660 + +$filename = tempfile(); +SKIP: { + open my $f, ">$filename" or skip( "Can't write temp file $filename: $!" ); + print $f <<'SWTEST'; +#!perl -w -iok +print "$^I\n"; +SWTEST + close $f or die "Could not close: $!"; + $r = runperl( + progfile => $filename, + ); + like( $r, qr/ok/, 'Spaces on the #! line (#30660)' ); +}