New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem with '-s' on #! line #4554
Comments
From sdouglas@arm.com----------------------------------------------------------------- --- foo --- If I invoke this as But if I invoke this as I do not expect the '-s' switch on the '#!' line to be ignored. man perlrun
Indeed, if I add other switches like this: The '-n' and '-w' have the expected effects no matter which of the two ways I I've tried this on perl 5.6.1, 5.004_04 and 5.002 on Solaris/SunOS 5.6. Using perl 5.6.1 (ActiveState build 629) on Win2000 neither invocation obeys the [Invoking it as Perl Info
|
From @schwernThat would be a bug. The problem appears to be that PL_doswitches is Weeell... instead of calling S_init_postdump_symbols() before parsing, Heh, found this in toke.c Perl_croak(aTHX_ "Believe me, you don't want to use \"-u\" on a Macintosh"); -- Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/ |
From @rgarciaBut if you invoke it as
This wouldn't be sufficient. Perl_moreswitches() is also called for command-line /* init_postdump_symbols not currently designed to be called */ Problem : init_postdump_symbols() handles different things (ARGV, ENV, $$). |
From @schwernThat sounds like a good idea. Also, we could split out the #! parsing from the rest of the -- Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/ |
From @rgarciaThen, when the lexer encounters an -s on the shebang line, if Inline Patch--- perl.c.orig Sat Nov 3 02:01:26 2001
+++ perl.c Wed Nov 7 22:04:14 2001
@@ -3370,17 +3370,10 @@
PL_osname = savepv(OSNAME);
}
-STATIC void
-S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register char **env)
+void
+Perl_init_argv_symbols(pTHX_ register int argc, register char **argv)
{
char *s;
- SV *sv;
- GV* tmpgv;
-#ifdef NEED_ENVIRON_DUP_FOR_MODIFY
- char **dup_env_base = 0;
- int dup_env_count = 0;
-#endif
-
argc--,argv++; /* skip name of script */
if (PL_doswitches) {
for (; argc > 0 && **argv == '-'; argc--,argv++) {
@@ -3398,6 +3391,30 @@
sv_setiv(GvSV(gv_fetchpv(argv[0]+1,TRUE, SVt_PV)),1);
}
}
+ if ((PL_argvgv = gv_fetchpv("ARGV",TRUE, SVt_PVAV))) {
+ GvMULTI_on(PL_argvgv);
+ (void)gv_AVadd(PL_argvgv);
+ av_clear(GvAVn(PL_argvgv));
+ for (; argc > 0; argc--,argv++) {
+ SV *sv = newSVpv(argv[0],0);
+ av_push(GvAVn(PL_argvgv),sv);
+ if (PL_widesyscalls)
+ (void)sv_utf8_decode(sv);
+ }
+ }
+}
+
+STATIC void
+S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register char **env)
+{
+ char *s;
+ SV *sv;
+ GV* tmpgv;
+#ifdef NEED_ENVIRON_DUP_FOR_MODIFY
+ char **dup_env_base = 0;
+ int dup_env_count = 0;
+#endif
+
PL_toptarget = NEWSV(0,0);
sv_upgrade(PL_toptarget, SVt_PVFM);
sv_setpvn(PL_toptarget, "", 0);
@@ -3407,6 +3424,9 @@
PL_formtarget = PL_bodytarget;
TAINT;
+
+ init_argv_symbols(argc,argv);
+
if ((tmpgv = gv_fetchpv("0",TRUE, SVt_PV))) {
#ifdef MACOS_TRADITIONAL
/* $0 is not majick on a Mac */
@@ -3422,17 +3442,6 @@
#else
sv_setpv(GvSV(tmpgv),PL_origargv[0]);
#endif
- if ((PL_argvgv = gv_fetchpv("ARGV",TRUE, SVt_PVAV))) {
- GvMULTI_on(PL_argvgv);
- (void)gv_AVadd(PL_argvgv);
- av_clear(GvAVn(PL_argvgv));
- for (; argc > 0; argc--,argv++) {
- SV *sv = newSVpv(argv[0],0);
- av_push(GvAVn(PL_argvgv),sv);
- if (PL_widesyscalls)
- (void)sv_utf8_decode(sv);
- }
- }
if ((PL_envgv = gv_fetchpv("ENV",TRUE, SVt_PVHV))) {
HV *hv;
GvMULTI_on(PL_envgv);
--- toke.c.orig Wed Nov 7 07:20:49 2001
+++ toke.c Wed Nov 7 21:52:22 2001
@@ -2688,6 +2688,7 @@
while (SPACE_OR_TAB(*d)) d++;
if (*d++ == '-') {
+ bool switches_done = PL_doswitches;
do {
if (*d == 'M' || *d == 'm') {
char *m = d;
@@ -2710,6 +2711,14 @@
if (PERLDB_LINE)
(void)gv_fetchfile(PL_origfilename);
goto retry;
+ }
+ 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);
}
}
}
--- embed.pl.orig Wed Nov 7 03:05:25 2001
+++ embed.pl Wed Nov 7 21:43:10 2001
@@ -1334,6 +1334,7 @@
Ap |I32 |ibcmp |const char* a|const char* b|I32 len
Ap |I32 |ibcmp_locale |const char* a|const char* b|I32 len
p |bool |ingroup |Gid_t testgid|Uid_t effective
+p |void |init_argv_symbols|int|char **
p |void |init_debugger
Ap |void |init_stacks
Ap |void |init_tm |struct tm *ptm |
From @floatingatollThis patch appears to be what was required to solve the problem, at the time; the bug [1] http://bugs6.perl.org/rt2/NoAuth/Display.html?id=7876 What's the status of this patch? - R. [RT_System - Wed Nov 7 05:24:45 2001]:
|
From @rgs
Change 12900 on 2001/11/08 by jhi@alpha |
@rgs - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#7876 (status was 'resolved')
Searchable as RT7876$
The text was updated successfully, but these errors were encountered: