summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYitzchak Scott-Thoennes <sthoenna@efn.org>2003-06-03 17:08:32 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-05 18:50:51 +0000
commitf0b2cf552638278613953870ec9b5623f83b321d (patch)
tree6c6026cb33c07d128046a103bf3fceb19cbc108e
parent84c133a0c99ec2d2efc517f14b45051d3bfe4074 (diff)
downloadperl-f0b2cf552638278613953870ec9b5623f83b321d.tar.gz
Re: SPUG:-s option doesn't always work!
Message-ID: <wrZ3+gzkg2iX092yn@efn.org> p4raw-id: //depot/perl@19695
-rw-r--r--t/run/switches.t5
-rw-r--r--toke.c8
2 files changed, 10 insertions, 3 deletions
diff --git a/t/run/switches.t b/t/run/switches.t
index bfae4eb60a..9ea84a7c73 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 4d694cdfcb..d57dc0cef9 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 (<>) {",