From: Nicholas Clark Date: Tue, 15 Sep 2009 12:56:31 +0000 (+0100) Subject: Avoid setting $! if the sitecustomize script doesn't exist. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=404ad9dc9dfa2116d2907212d3650df6870ff9bc;p=p5sagit%2Fp5-mst-13.2.git Avoid setting $! if the sitecustomize script doesn't exist. --- diff --git a/perl.c b/perl.c index 7876adf..6cf99f1 100644 --- a/perl.c +++ b/perl.c @@ -1942,8 +1942,13 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) #ifdef USE_SITECUSTOMIZE if (!minus_f) { + /* SITELIB_EXP is a function call on Win32. + The games with local $! are to avoid setting errno if there is no + sitecustomize script. */ + const char *const sitelib = SITELIB_EXP; (void)Perl_av_create_and_unshift_one(aTHX_ &PL_preambleav, - Perl_newSVpvf(aTHX_ "BEGIN { do '%s/sitecustomize.pl' }", SITELIB_EXP)); + Perl_newSVpvf(aTHX_ + "BEGIN { do {local $!; -f '%s/sitecustomize.pl'} && do '%s/sitecustomize.pl' }", sitelib, sitelib)); } #endif