Fix #30660: Repeated spaces on shebang line stops option parsing
authorNicholas Clark <nick@ccl4.org>
Thu, 28 Aug 2008 13:11:44 +0000 (13:11 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 28 Aug 2008 13:11:44 +0000 (13:11 +0000)
From a patch and test sent by Renée Bäcker in
<48B271A3.80808@smart-websolutions.de>

p4raw-id: //depot/perl@34234

perl.c
t/run/switches.t

diff --git a/perl.c b/perl.c
index e41ae96..98437a3 100644 (file)
--- 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:
index 8e1b56c..e62eda4 100644 (file)
@@ -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)' );
+}