Re: SPUG:-s option doesn't always work!
Yitzchak Scott-Thoennes [Wed, 4 Jun 2003 00:08:32 +0000 (17:08 -0700)]
Message-ID: <wrZ3+gzkg2iX092yn@efn.org>

p4raw-id: //depot/perl@19695

t/run/switches.t
toke.c

index bfae4eb..9ea84a7 100644 (file)
@@ -126,12 +126,11 @@ $filename = 'swstest.tmp';
 SKIP: {
     open my $f, ">$filename" or skip( "Can't write temp file $filename: $!" );
     print $f <<'SWTEST';
-#!perl -s
-print $x
+#!perl -sn
+BEGIN { print $x; exit }
 SWTEST
     close $f or die "Could not close: $!";
     $r = runperl(
-       switches    => [ '-s' ],
        progfile    => $filename,
        args        => [ '-x=foo' ],
     );
diff --git a/toke.c b/toke.c
index 4d694cd..d57dc0c 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2727,6 +2727,14 @@ Perl_yylex(pTHX)
                            }
                            d = moreswitches(d);
                        } while (d);
+                       if (PL_doswitches && !switches_done) {
+                           int argc = PL_origargc;
+                           char **argv = PL_origargv;
+                           do {
+                               argc--,argv++;
+                           } while (argc && argv[0][0] == '-' && argv[0][1]);
+                           init_argv_symbols(argc,argv);
+                       }
                        if ((PERLDB_LINE && !oldpdb) ||
                            ((PL_minus_n || PL_minus_p) && !(oldn || oldp)))
                              /* if we have already added "LINE: while (<>) {",