Bug #3891: Unexpected result of ENV[""] on Windows
http://redmine.ruby-lang.org/issues/show/3891

Author: Heesob Park
Status: Open, Priority: Low
Category: core, Target version: 1.9.x
ruby -v: ruby 1.9.3dev (2010-09-29 trunk 29366) [i386-mswin32_90]

I noticed that ENV[""] returns "::=::\\" on Windows.

This bug exists almost all versions of ruby from 1.8.x to 1.9.x

C:\>ruby -ve 'p ENV[""]'
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]
"::=::\\"

C:\work>ruby -ve 'p ENV[""]'
ruby 1.9.3dev (2010-09-29 trunk 29366) [i386-mswin32_90]
"::=::\\"

Here is a simple patch:

--- win32.c     2010-09-30 15:13:59.000000000 +0900
+++ win32.c.new 2010-09-30 15:16:31.000000000 +0900
@@ -3900,6 +3900,7 @@
     int len = strlen(name);
     char *env;

+    if (len==0) return NULL;
     if (envarea)
        FreeEnvironmentStrings(envarea);
     envarea = GetEnvironmentStrings();


----------------------------------------
http://redmine.ruby-lang.org