summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorHans Mulder <hansm@euronet.nl>1997-05-29 20:30:44 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-06-11 12:00:00 +1200
commit66b1d5575fd5eb6242bac2e9a08b163be8b1b960 (patch)
tree494f32324f1768f55f5912b08ed6164b414f00ae /t
parent5117ca915f2c72e17e52c313797ad394bd76c418 (diff)
downloadperl-66b1d5575fd5eb6242bac2e9a08b163be8b1b960.tar.gz
ENV leaks on win32 (was Re: Comments on ENV patch sought)
Subject: [PATCH] for NETaa13787: %ENV=(); doesn't clear the environment Perl maintains two representations of the environment: (A) a hash named %ENV, used by the perl script (B) a char** named environ, which is passed to child processes Obviously, the intent is to keep tho two in sync. This fails in two situations: (1) A list assignment to %ENV clears (A) but not (B); (2) Assigning to $0 has the side effect of deleting the key NoNeSuCh form (B) but not from (A). $ perl -e '%ENV=(); print "home\n" if exists $ENV{HOME}; exec "echo \$HOME";' /Users/hansm $ perl -e '$ENV{NoNeSuCh} = "foo"; $0 = "bar"; exec "echo \$NoNeSuCh";' $ perl -e '$ENV{NoNeSuCh} = "foo"; exec "echo \$NoNeSuCh";' foo $ I've complained about rpoblem (1) before; and Larry assigned it bug ID NETaa13787 when he entered it into DDTS. The patch below attempts to remedy both problems, at least on Unix platforms. I don't know how to handle the environment on VMS and WIN32; my code simply calls DIE('unimplemented"), which is honest but won't make users on those plaforms happy. p5p-msgid: 199705292240.AAA01135@mail.euronet.nl Signed-off-by: Peter Prymmer <pvhp@forte.com>
Diffstat (limited to 't')
-rwxr-xr-xt/op/magic.t15
1 files changed, 14 insertions, 1 deletions
diff --git a/t/op/magic.t b/t/op/magic.t
index c2be2e5e68..89634a7f02 100755
--- a/t/op/magic.t
+++ b/t/op/magic.t
@@ -22,7 +22,7 @@ sub ok {
$Is_MSWin32 = ($^O eq 'MSWin32');
$PERL = ($Is_MSWin32 ? '.\perl' : './perl');
-print "1..28\n";
+print "1..30\n";
eval '$ENV{"foo"} = "hi there";'; # check that ENV is inited inside eval
if ($Is_MSWin32) { ok 1, `cmd /x /c set foo` eq "foo=hi there\n"; }
@@ -142,3 +142,16 @@ EOF
ok 26, $] >= 5.00319, $];
ok 27, $^O;
ok 28, $^T > 850000000, $^T;
+
+if ($Is_MSWin32) {
+ ok 29, 1;
+ ok 30, 1;
+}
+else {
+ %ENV = ();
+ ok 29, `echo \$foo` eq "\n";
+
+ $ENV{NoNeSuCh} = "foo";
+ $0 = "bar";
+ ok 30, `echo \$NoNeSuCh` eq "foo\n";
+}