From: Yitzchak Scott-Thoennes Date: Wed, 4 Jun 2003 00:08:32 +0000 (-0700) Subject: Re: SPUG:-s option doesn't always work! X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f0b2cf552638278613953870ec9b5623f83b321d;p=p5sagit%2Fp5-mst-13.2.git Re: SPUG:-s option doesn't always work! Message-ID: p4raw-id: //depot/perl@19695 --- diff --git a/t/run/switches.t b/t/run/switches.t index bfae4eb..9ea84a7 100644 --- a/t/run/switches.t +++ b/t/run/switches.t @@ -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 --- 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 (<>) {",