diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-10-24 06:14:31 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-10-24 06:15:07 -0700 |
commit | 93b2dae14541cd2bc39e2d4b1bb5f0cc2c0ef0c7 (patch) | |
tree | fcd31000dcf19da71fc0aba7ec82bbfb647e2707 /doio.c | |
parent | e27aa02b637769bf2276f7915bcaceba353e4a2e (diff) | |
download | perl-93b2dae14541cd2bc39e2d4b1bb5f0cc2c0ef0c7.tar.gz |
Make <~> work again under miniperl
Commit a3342be368 localised %ENV before calling csh for glob. But
that causes <~> to stop working. So this commit clears out %ENV
*except* for $ENV{HOME}.
It relies on the way magic works: Before localising the %ENV hash, it
retrieves its $ENV{HOME} element, which is a magical scalar. It calls
get-magic to store the value in the scalar itself, localises %ENV, and
then calls set-magic on the element, to signal (deceitfully) that an assignment has just happened. So the cached value in the magical sca-
lar is used and assigned to the env var.
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -2379,7 +2379,13 @@ Perl_vms_start_glob #endif #endif /* !CSH */ #endif /* !DOSISH */ - save_hash(gv_fetchpvs("ENV", 0, SVt_PVHV)); + { + GV * const envgv = gv_fetchpvs("ENV", 0, SVt_PVHV); + SV ** const home = hv_fetchs(GvHV(envgv), "HOME", 0); + if (home && *home) SvGETMAGIC(*home); + save_hash(gv_fetchpvs("ENV", 0, SVt_PVHV)); + if (home && *home) SvSETMAGIC(*home); + } (void)do_open(PL_last_in_gv, (char*)SvPVX_const(tmpcmd), SvCUR(tmpcmd), FALSE, O_RDONLY, 0, NULL); fp = IoIFP(io); |