Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ENV{foo}=undef #12337

Closed
p5pRT opened this issue Aug 19, 2012 · 29 comments
Closed

$ENV{foo}=undef #12337

p5pRT opened this issue Aug 19, 2012 · 29 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 19, 2012

Migrated from rt.perl.org#114504 (status was 'resolved')

Searchable as RT114504$

@p5pRT
Copy link
Author

p5pRT commented Aug 19, 2012

From @cpansprout

perldelta for 5.17.3 has this under Incompatible Changes​:

=head2 C<$ENV{foo}=undef> deletes value from environ, like C<delete $ENV{foo}>

This facilitates use of C<local()> with C<%ENV> entries. In previous versions
of Perl, C<undef> was converted to the empty string.

I don’t recall seeing this discussed. This change makes Perl less consistent with itself. For undef to be converted to the empty string is normal. For $hash{key} = undef to delete the hash element is abnormal. And I don’t see what it provides, except inconsistency. We already have delete local.

I think this should be reverted.


Flags​:
  category=core
  severity=low


Site configuration information for perl 5.17.3​:

Configured by sprout at Mon Jul 30 23​:46​:13 PDT 2012.

Summary of my perl5 (revision 5 version 17 subversion 3) configuration​:
  Snapshot of​: 7e2a0d4
  Platform​:
  osname=darwin, osvers=10.5.0, archname=darwin-2level
  uname='darwin pint.local 10.5.0 darwin kernel version 10.5.0​: fri nov 5 23​:20​:39 pdt 2010; root​:xnu-1504.9.17~1release_i386 i386 '
  config_args='-de -Dusedevel -DDEBUGGING=-g'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
  optimize='-O3 -g',
  cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lutil -lc
  perllibs=-ldl -lm -lutil -lc
  libc=, so=dylib, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'

Locally applied patches​:
 


@​INC for perl 5.17.3​:
  /usr/local/lib/perl5/site_perl/5.17.3/darwin-2level
  /usr/local/lib/perl5/site_perl/5.17.3
  /usr/local/lib/perl5/5.17.3/darwin-2level
  /usr/local/lib/perl5/5.17.3
  /usr/local/lib/perl5/site_perl
  .


Environment for perl 5.17.3​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/sprout
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/bin​:/bin​:/usr/sbin​:/sbin​:/usr/local/bin​:/usr/X11/bin​:/usr/local/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2012

From @doy

On Sun, Aug 19, 2012 at 12​:20​:21PM -0700, Father Chrysostomos wrote​:

perldelta for 5.17.3 has this under Incompatible Changes​:

=head2 C<$ENV{foo}=undef> deletes value from environ, like C<delete $ENV{foo}>

This facilitates use of C<local()> with C<%ENV> entries. In previous versions
of Perl, C<undef> was converted to the empty string.

I don’t recall seeing this discussed. This change makes Perl less consistent with itself. For undef to be converted to the empty string is normal. For $hash{key} = undef to delete the hash element is abnormal. And I don’t see what it provides, except inconsistency. We already have delete local.

I think this should be reverted.

+1

-doy

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2012

From Eirik-Berg.Hanssen@allverden.no

On Mon, Aug 20, 2012 at 11​:19 AM, Jesse Luehrs <doy@​tozt.net> wrote​:

On Sun, Aug 19, 2012 at 12​:20​:21PM -0700, Father Chrysostomos wrote​:

perldelta for 5.17.3 has this under Incompatible Changes​:

=head2 C<$ENV{foo}=undef> deletes value from environ, like C<delete
$ENV{foo}>

This facilitates use of C<local()> with C<%ENV> entries. In previous
versions
of Perl, C<undef> was converted to the empty string.

I don’t recall seeing this discussed. This change makes Perl less
consistent with itself. For undef to be converted to the empty string is
normal. For $hash{key} = undef to delete the hash element is abnormal.
And I don’t see what it provides, except inconsistency. We already have
delete local.

I think this should be reverted.

+1

  Briefly discussed, July 25th.

  Questioned​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/07/msg189929.html

  Answered​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/07/msg189942.html

  But yeah, the answer seems a bit too brief. As you note, C<< delete
local >> does the job, and if only string values are accepted, I'd expect
assignment of undef to yield the empty string.

  As it is part of a bigger change, I wouldn't ask for it all to be
reverted, but this corner of the peanut gallery would also prefer the old
behaviour of assignment of undefined values. Is it doable?

Eirik

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2012

From @cpansprout

On Mon Aug 20 03​:16​:41 2012, Eirik-Berg.Hanssen@​allverden.no wrote​:

On Mon, Aug 20, 2012 at 11​:19 AM, Jesse Luehrs <doy@​tozt.net> wrote​:

On Sun, Aug 19, 2012 at 12​:20​:21PM -0700, Father Chrysostomos wrote​:

perldelta for 5.17.3 has this under Incompatible Changes​:

=head2 C<$ENV{foo}=undef> deletes value from environ, like C<delete
$ENV{foo}>

This facilitates use of C<local()> with C<%ENV> entries. In previous
versions
of Perl, C<undef> was converted to the empty string.

I don’t recall seeing this discussed. This change makes Perl less
consistent with itself. For undef to be converted to the empty
string is
normal. For $hash{key} = undef to delete the hash element is abnormal.
And I don’t see what it provides, except inconsistency. We already
have
delete local.

I think this should be reverted.

+1

Briefly discussed, July 25th.

Questioned​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/07/msg189929.html

Answered​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/07/msg189942.html

But yeah, the answer seems a bit too brief.

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo}, which
used to be buggy until Chip fixed it a few years ago. (local $^W = $^W;
still exhibits the bug.)

As you note, C<< delete
local >> does the job, and if only string values are accepted, I'd expect
assignment of undef to yield the empty string.

As it is part of a bigger change, I wouldn't ask for it all to be
reverted, but this corner of the peanut gallery would also prefer the old
behaviour of assignment of undefined values. Is it doable?

Anything’s doable. :-) It’s probably simple, too.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2012

From [Unknown Contact. See original ticket]

On Mon Aug 20 03​:16​:41 2012, Eirik-Berg.Hanssen@​allverden.no wrote​:

On Mon, Aug 20, 2012 at 11​:19 AM, Jesse Luehrs <doy@​tozt.net> wrote​:

On Sun, Aug 19, 2012 at 12​:20​:21PM -0700, Father Chrysostomos wrote​:

perldelta for 5.17.3 has this under Incompatible Changes​:

=head2 C<$ENV{foo}=undef> deletes value from environ, like C<delete
$ENV{foo}>

This facilitates use of C<local()> with C<%ENV> entries. In previous
versions
of Perl, C<undef> was converted to the empty string.

I don’t recall seeing this discussed. This change makes Perl less
consistent with itself. For undef to be converted to the empty
string is
normal. For $hash{key} = undef to delete the hash element is abnormal.
And I don’t see what it provides, except inconsistency. We already
have
delete local.

I think this should be reverted.

+1

Briefly discussed, July 25th.

Questioned​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/07/msg189929.html

Answered​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/07/msg189942.html

But yeah, the answer seems a bit too brief.

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo}, which
used to be buggy until Chip fixed it a few years ago. (local $^W = $^W;
still exhibits the bug.)

As you note, C<< delete
local >> does the job, and if only string values are accepted, I'd expect
assignment of undef to yield the empty string.

As it is part of a bigger change, I wouldn't ask for it all to be
reverted, but this corner of the peanut gallery would also prefer the old
behaviour of assignment of undefined values. Is it doable?

Anything’s doable. :-) It’s probably simple, too.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Aug 25, 2012

From @rjbs

* Father Chrysostomos via RT <perlbug-comment@​perl.org> [2012-08-20T11​:26​:08]

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo}, which
used to be buggy until Chip fixed it a few years ago. (local $^W = $^W;
still exhibits the bug.)

I also thought so.

I wonder whether Chip was not aware that "delete local" had been made to work;
that's a newer-than-5.8 change and I think it was often overlooked. (But not
by me, as I asked for it and was delighted to see it get implemented!)

Chip, can you weigh in on this?

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2012

From @cpansprout

On Fri Aug 24 18​:20​:10 2012, perl.p5p@​rjbs.manxome.org wrote​:

* Father Chrysostomos via RT <perlbug-comment@​perl.org> [2012-08-
20T11​:26​:08]

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo},
which
used to be buggy until Chip fixed it a few years ago. (local $^W =
$^W;
still exhibits the bug.)

I also thought so.

It turns out that perldelta entry that inspired this ticket is wrong.
With current bleadperl I get this​:

$ ./perl -Ilib -le '$ENV{PATH} = undef; print exists $ENV{PATH}; local
$ENV{PATH}; print exists $ENV{PATH}'
1
1

Nothing more to do here, as far as I’m concerned.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2012

From [Unknown Contact. See original ticket]

On Fri Aug 24 18​:20​:10 2012, perl.p5p@​rjbs.manxome.org wrote​:

* Father Chrysostomos via RT <perlbug-comment@​perl.org> [2012-08-
20T11​:26​:08]

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo},
which
used to be buggy until Chip fixed it a few years ago. (local $^W =
$^W;
still exhibits the bug.)

I also thought so.

It turns out that perldelta entry that inspired this ticket is wrong.
With current bleadperl I get this​:

$ ./perl -Ilib -le '$ENV{PATH} = undef; print exists $ENV{PATH}; local
$ENV{PATH}; print exists $ENV{PATH}'
1
1

Nothing more to do here, as far as I’m concerned.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 13, 2012

@cpansprout - Status changed from 'open' to 'resolved'

@p5pRT
Copy link
Author

p5pRT commented Oct 15, 2012

From @xsawyerx

On 10/13/2012 04​:03 PM, Father Chrysostomos via RT wrote​:

On Fri Aug 24 18​:20​:10 2012, perl.p5p@​rjbs.manxome.org wrote​:

* Father Chrysostomos via RT <perlbug-comment@​perl.org> [2012-08-
20T11​:26​:08]

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo},
which
used to be buggy until Chip fixed it a few years ago. (local $^W =
$^W;
still exhibits the bug.)
I also thought so.
It turns out that perldelta entry that inspired this ticket is wrong.
With current bleadperl I get this​:

$ ./perl -Ilib -le '$ENV{PATH} = undef; print exists $ENV{PATH}; local
$ENV{PATH}; print exists $ENV{PATH}'
1
1

Nothing more to do here, as far as I’m concerned.
Wasn't this also related to the CPANPLUS discussion and failing on VMS?

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2012

From @cpansprout

On Mon Oct 15 15​:04​:28 2012, xsawyerx@​gmail.com wrote​:

On 10/13/2012 04​:03 PM, Father Chrysostomos via RT wrote​:

On Fri Aug 24 18​:20​:10 2012, perl.p5p@​rjbs.manxome.org wrote​:

* Father Chrysostomos via RT <perlbug-comment@​perl.org> [2012-08-
20T11​:26​:08]

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo},
which
used to be buggy until Chip fixed it a few years ago. (local $^W =
$^W;
still exhibits the bug.)
I also thought so.
It turns out that perldelta entry that inspired this ticket is wrong.
With current bleadperl I get this​:

$ ./perl -Ilib -le '$ENV{PATH} = undef; print exists $ENV{PATH}; local
$ENV{PATH}; print exists $ENV{PATH}'
1
1

Nothing more to do here, as far as I’m concerned.
Wasn't this also related to the CPANPLUS discussion and failing on VMS?

No. The VMS issue only have to do with clobbering %ENV as a whole, as
in locaL(%ENV) or %ENV=....

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2012

From [Unknown Contact. See original ticket]

On Mon Oct 15 15​:04​:28 2012, xsawyerx@​gmail.com wrote​:

On 10/13/2012 04​:03 PM, Father Chrysostomos via RT wrote​:

On Fri Aug 24 18​:20​:10 2012, perl.p5p@​rjbs.manxome.org wrote​:

* Father Chrysostomos via RT <perlbug-comment@​perl.org> [2012-08-
20T11​:26​:08]

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo},
which
used to be buggy until Chip fixed it a few years ago. (local $^W =
$^W;
still exhibits the bug.)
I also thought so.
It turns out that perldelta entry that inspired this ticket is wrong.
With current bleadperl I get this​:

$ ./perl -Ilib -le '$ENV{PATH} = undef; print exists $ENV{PATH}; local
$ENV{PATH}; print exists $ENV{PATH}'
1
1

Nothing more to do here, as far as I’m concerned.
Wasn't this also related to the CPANPLUS discussion and failing on VMS?

No. The VMS issue only have to do with clobbering %ENV as a whole, as
in locaL(%ENV) or %ENV=....

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2012

From @chipdude

On Fri, Aug 24, 2012 at 09​:19​:40PM -0400, Ricardo Signes wrote​:

* Father Chrysostomos via RT <perlbug-comment@​perl.org> [2012-08-20T11​:26​:08]

I do recall that now, but I did not understand it at the time. I
assumed it had something to do with local $ENV{foo} = $ENV{foo}, which
used to be buggy until Chip fixed it a few years ago. (local $^W = $^W;
still exhibits the bug.)

I also thought so.

I wonder whether Chip was not aware that "delete local" had been made to work...
[...]
Chip, can you weigh in on this?

Indeed I wasn't aware. The below code works (no die) on 5.14​:

  # Test that $ENV{X} = undef does *not* need a special case
  $ENV{X} = 'x';
  {
  delete local $ENV{X};
  die "Unhappy 1" if `env` =~ /^X=/m;
  }
  die "Unhappy 2" unless `env` =~ /^X=/m;

So special case of C<$ENV{X}=undef> performing unsetenv is a mistake and
should be removed.
--
Chip Salzenberg

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2012

@cpansprout - Status changed from 'resolved' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Feb 8, 2013

From @rjbs

On Tue Oct 16 09​:44​:42 2012, rev.chip@​gmail.com wrote​:

So special case of C<$ENV{X}=undef> performing unsetenv is a mistake
and should be removed.

This has yet to be resolved.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2013

From @kentfredric

On Fri Feb 08 07​:59​:37 2013, rjbs wrote​:

On Tue Oct 16 09​:44​:42 2012, rev.chip@​gmail.com wrote​:

So special case of C<$ENV{X}=undef> performing unsetenv is a mistake
and should be removed.

This has yet to be resolved.

I gave a shot at patching this and it seemed like the code required was
far too simple. But it works.

Included is tests for the undef =~ "" behaviour, and tests pass.

I read C<man setenv> and it doesn't seem to specify anywhere that
setenv( name, NULL ) deletes the key, but that seems to be what this
code suggests happens.

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2013

From @kentfredric

0001-mg.c-revert-ENV-x-undef-behaviour-to-be-empty-string.patch
From 0c265b21c8a971f03c7c90a8c325621f586a96d0 Mon Sep 17 00:00:00 2001
From: Kent Fredric <kentfredric@gmail.com>
Date: Sun, 17 Feb 2013 06:07:59 +1300
Subject: [PATCH] mg.c : revert ENV{x} = undef behaviour to be empty string,
 not key deletion

pod/perldelta.pod: document reversion of ENV{foo} = undef behaviour  in delta
t/op/magic.t: add a test for ENV{foo} = undef
---
 mg.c              | 2 +-
 pod/perldelta.pod | 7 +++++++
 t/op/magic.t      | 6 +++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/mg.c b/mg.c
index e4711e7..6811727 100644
--- a/mg.c
+++ b/mg.c
@@ -1101,7 +1101,7 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg)
     dVAR;
     STRLEN len = 0, klen;
     const char * const key = MgPV_const(mg,klen);
-    const char *s = NULL;
+    const char *s = "";
 
     PERL_ARGS_ASSERT_MAGIC_SETENV;
 
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 3fc33ac..c7d6e34 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -53,6 +53,13 @@ XXX For a release on a stable branch, this section aspires to be:
     If any exist, they are bugs, and we request that you submit a
     report.  See L</Reporting Bugs> below.
 
+=head2 C<$ENV{foo} = undef> no longer deletes value from environ
+
+5.17.3 Introduced a change where assiging C<undef> to an C<%ENV> key was equivalent
+to C<delete $ENV{foo}>.
+
+This release reverts that change.
+
 [ List each incompatible change as a =head2 entry ]
 
 =head1 Deprecations
diff --git a/t/op/magic.t b/t/op/magic.t
index 990de55..5421d01 100644
--- a/t/op/magic.t
+++ b/t/op/magic.t
@@ -5,7 +5,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    plan (tests => 178);
+    plan (tests => 179);
 }
 
 # Test that defined() returns true for magic variables created on the fly,
@@ -647,9 +647,13 @@ SKIP: {
 	}
 
 	$ENV{__NoNeSuCh} = 'foo';
+	$ENV{__NoNeSuCh2} = 'foo';
 	$0 = 'bar';
 	env_is(__NoNeSuCh => 'foo', 'setting $0 does not break %ENV');
 
+	$ENV{__NoNeSuCh2} = undef;
+	env_is(__NoNeSuCh2 => '', 'setting a key as undef does not delete it');
+
 	# stringify a glob
 	$ENV{foo} = *TODO;
 	env_is(foo => '*main::TODO', 'ENV store of stringified glob');
-- 
1.7.12.4

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2013

From @kentfredric

Just regenerated the patch with a cleanup of the ENV variable I added for
my test. I didn't see that the first time around. VMS is *weird*

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2013

From @kentfredric

0001-mg.c-revert-ENV-x-undef-behaviour-to-be-empty-string.patch
From 0c265b21c8a971f03c7c90a8c325621f586a96d0 Mon Sep 17 00:00:00 2001
From: Kent Fredric <kentfredric@gmail.com>
Date: Sun, 17 Feb 2013 06:07:59 +1300
Subject: [PATCH] mg.c : revert ENV{x} = undef behaviour to be empty string,
 not key deletion

pod/perldelta.pod: document reversion of ENV{foo} = undef behaviour  in delta
t/op/magic.t: add a test for ENV{foo} = undef
---
 mg.c              | 2 +-
 pod/perldelta.pod | 7 +++++++
 t/op/magic.t      | 6 +++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/mg.c b/mg.c
index e4711e7..6811727 100644
--- a/mg.c
+++ b/mg.c
@@ -1101,7 +1101,7 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg)
     dVAR;
     STRLEN len = 0, klen;
     const char * const key = MgPV_const(mg,klen);
-    const char *s = NULL;
+    const char *s = "";
 
     PERL_ARGS_ASSERT_MAGIC_SETENV;
 
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 3fc33ac..c7d6e34 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -53,6 +53,13 @@ XXX For a release on a stable branch, this section aspires to be:
     If any exist, they are bugs, and we request that you submit a
     report.  See L</Reporting Bugs> below.
 
+=head2 C<$ENV{foo} = undef> no longer deletes value from environ
+
+5.17.3 Introduced a change where assiging C<undef> to an C<%ENV> key was equivalent
+to C<delete $ENV{foo}>.
+
+This release reverts that change.
+
 [ List each incompatible change as a =head2 entry ]
 
 =head1 Deprecations
diff --git a/t/op/magic.t b/t/op/magic.t
index 990de55..5421d01 100644
--- a/t/op/magic.t
+++ b/t/op/magic.t
@@ -5,7 +5,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    plan (tests => 178);
+    plan (tests => 179);
 }
 
 # Test that defined() returns true for magic variables created on the fly,
@@ -647,9 +647,13 @@ SKIP: {
 	}
 
 	$ENV{__NoNeSuCh} = 'foo';
+	$ENV{__NoNeSuCh2} = 'foo';
 	$0 = 'bar';
 	env_is(__NoNeSuCh => 'foo', 'setting $0 does not break %ENV');
 
+	$ENV{__NoNeSuCh2} = undef;
+	env_is(__NoNeSuCh2 => '', 'setting a key as undef does not delete it');
+
 	# stringify a glob
 	$ENV{foo} = *TODO;
 	env_is(foo => '*main::TODO', 'ENV store of stringified glob');
-- 
1.7.12.4

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2013

From [Unknown Contact. See original ticket]

Just regenerated the patch with a cleanup of the ENV variable I added for
my test. I didn't see that the first time around. VMS is *weird*

@p5pRT
Copy link
Author

p5pRT commented Feb 17, 2013

From @cpansprout

On Sat Feb 16 10​:46​:39 2013, kentfredric wrote​:

Just regenerated the patch with a cleanup of the ENV variable I added for
my test. I didn't see that the first time around. VMS is *weird*

Thank you. Applied as 888a67f.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Feb 17, 2013

From [Unknown Contact. See original ticket]

On Sat Feb 16 10​:46​:39 2013, kentfredric wrote​:

Just regenerated the patch with a cleanup of the ENV variable I added for
my test. I didn't see that the first time around. VMS is *weird*

Thank you. Applied as 888a67f.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Feb 17, 2013

@cpansprout - Status changed from 'open' to 'resolved'

@p5pRT
Copy link
Author

p5pRT commented Feb 21, 2013

@rjbs - Status changed from 'resolved' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Feb 21, 2013

From @rjbs

This was applied, but only after not being smoke-me'd first.

It breaks Win32, t/op/magic.t

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Feb 21, 2013

From @tonycoz

On Wed Feb 20 18​:56​:12 2013, rjbs wrote​:

This was applied, but only after not being smoke-me'd first.

It breaks Win32, t/op/magic.t

Steve fixed it, see​:

http​://www.nntp.perl.org/group/perl.daily-build.reports/2013/02/msg137334.html

Re-closing.

Tony

@p5pRT
Copy link
Author

p5pRT commented Feb 21, 2013

@tonycoz - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Feb 21, 2013
@p5pRT
Copy link
Author

p5pRT commented Feb 23, 2013

From @craigberry

On Sat, Feb 16, 2013 at 12​:46 PM, Kent Fredric via RT
<perlbug-comment@​perl.org> wrote​:

Just regenerated the patch with a cleanup of the ENV variable I added for
my test. I didn't see that the first time around. VMS is *weird*

If you're referring to the snippets of eccentricity in mg.c and hv.c,
that's only the tip of the iceberg; the darker magic is in vms/vms.c.

I'm actually not sure what to do about this change on VMS.
t/op/magic.t now fails like so​:

ok 157 - setting $0 does not break %ENV
not ok 158 - setting a key as undef does not delete it
# Failed test 158 - setting a key as undef does not delete it at
op/magic.t line 69
# got "\000\n"
# expected "\n"
ok 159 - ENV store of stringified glob

What's happening here is that when we set an environment variable to
undef, we're actually storing a null byte as the value in the "real"
(external to Perl) environment. This is necessary because storing
zero-length values is not allowed. It's possible because the native
interfaces do not use C (ASCIZ) strings but always specify string
lengths on input and output.

When we retrieve such a value from Perl, we correctly recognize that
the value exists but is undefined​:

$ perl -e "$ENV{XYZ}='foo'; $ENV{XYZ}=undef; print qq/exists but
undef\n/ if exists $ENV{XYZ} && !defined $ENV{XYZ};"
exists but undef

but the env_is() subroutine in magic.t is retrieving that null byte by
running an external command. I guess I will just hack up env_is() to
handle this special case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant