From: Gisle Aas Date: Fri, 18 Mar 2005 04:06:40 +0000 (-0800) Subject: Re: sitecustomize.pl [PATCH] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=20ef40cf6a00eee95a449854794854a93e411e3b;p=p5sagit%2Fp5-mst-13.2.git Re: sitecustomize.pl [PATCH] Message-ID: Adds a new command-line switch, -f, and a new optional compile-time setting -DUSE_SITECUSTOMIZE p4raw-id: //depot/perl@24043 --- diff --git a/INSTALL b/INSTALL index c7e0a06..fb2d5cd 100644 --- a/INSTALL +++ b/INSTALL @@ -845,6 +845,16 @@ present, at run time. Of course, you can still search other @INC directories ahead of those in APPLLIB_EXP by using any of the standard run-time methods: $PERLLIB, $PERL5LIB, -I, use lib, etc. +=item USE_SITECUSTOMIZE + +Run-time customization of @INC can be enabled with: + + sh Configure -Accflags=-DUSE_SITECUSTOMIZE + +When enabled, make perl run F<$sitelibexp/sitecustomize.pl> before +anything else. This script can then be set up to add additional +entries to @INC. + =item Man Pages In versions 5.005_57 and earlier, the default was to store module man diff --git a/ext/Devel/DProf/t/DProf.t b/ext/Devel/DProf/t/DProf.t index 3488bc8..bdd70b0 100644 --- a/ext/Devel/DProf/t/DProf.t +++ b/ext/Devel/DProf/t/DProf.t @@ -48,7 +48,7 @@ sub profile { my $opt_d = '-d:DProf'; my $t_start = new Benchmark; - open( R, "$perl \"$opt_d\" $test |" ) || warn "$0: Can't run. $!\n"; + open( R, "$perl -f \"$opt_d\" $test |" ) || warn "$0: Can't run. $!\n"; @results = ; close R or warn "Could not close: $!"; my $t_total = timediff( new Benchmark, $t_start ); diff --git a/perl.c b/perl.c index 96b3a5a..7974a42 100644 --- a/perl.c +++ b/perl.c @@ -1229,6 +1229,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) register SV *sv; register char *s; char *cddir = Nullch; + bool minus_f = FALSE; PL_fdscript = -1; PL_suidscript = -1; @@ -1322,6 +1323,11 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) sv_catpv(PL_e_script, "\n"); break; + case 'f': + minus_f = TRUE; + s++; + goto reswitch; + case 'I': /* -I handled both here and in moreswitches() */ forbid_setid("-I"); if (!*++s && (s=argv[1]) != Nullch) { @@ -1389,6 +1395,9 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) # ifdef USE_SOCKS sv_catpv(PL_Sv," USE_SOCKS"); # endif +# ifdef USE_SITECUSTOMIZE + sv_catpv(PL_Sv," USE_SITECUSTOMIZE"); +# endif # ifdef PERL_IMPLICIT_CONTEXT sv_catpv(PL_Sv," PERL_IMPLICIT_CONTEXT"); # endif @@ -1519,6 +1528,15 @@ print \" \\@INC:\\n @INC\\n\";"); } } +#ifdef USE_SITECUSTOMIZE + if (!minus_f) { + if (!PL_preambleav) + PL_preambleav = newAV(); + av_unshift(PL_preambleav, 1); + (void)av_store(PL_preambleav, 0, Perl_newSVpvf(aTHX_ "BEGIN { do '%s/sitecustomize.pl' }", SITELIB_EXP)); + } +#endif + if (PL_taint_warn && PL_dowarn != G_WARN_ALL_OFF) { PL_compiling.cop_warnings = newSVpvn(WARN_TAINTstring, WARNsize); } @@ -2342,6 +2360,7 @@ S_usage(pTHX_ char *name) /* XXX move this out into a module ? */ "-d[:debugger] run program under debugger", "-D[number/list] set debugging flags (argument is a bit mask or alphabets)", "-e program one line of program (several -e's allowed, omit programfile)", +"-f don't do $sitelib/sitecustomize.pl at startup", "-F/pattern/ split() pattern for -a switch (//'s are optional)", "-i[extension] edit <> files in place (makes backup if extension supplied)", "-Idirectory specify @INC/#include directory (several -I's allowed)", diff --git a/pod/perlrun.pod b/pod/perlrun.pod index 1e83bdc..88c5446 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -430,6 +430,17 @@ will not look for a filename in the argument list. Multiple B<-e> commands may be given to build up a multi-line script. Make sure to use semicolons where you would in a normal program. +=item B<-f> + +Disable executing F<$Config{siteperl}/sitecustomize.pl> at +startup. + +Perl can be built so that it by default will try to execute +F<$Config{siteperl}/sitecustomize.pl> at startup. This is a hook that +allows the sysadmin to customize how perl behaves. It can for +instance be used to add entries to the @INC array to make perl find +modules in non-standard locations. + =item B<-F>I specifies the pattern to split on if B<-a> is also in effect. The