From 93b2dae14541cd2bc39e2d4b1bb5f0cc2c0ef0c7 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Mon, 24 Oct 2011 06:14:31 -0700 Subject: 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. --- doio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'doio.c') diff --git a/doio.c b/doio.c index 06d9bcd18c..47b60ceb11 100644 --- a/doio.c +++ b/doio.c @@ -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); -- cgit v1.2.1