[GHC] #12494: Implementation of setenv in base incorrectly claims empty environment variable not supported on Windows

GHC ghc-devs at haskell.org
Tue Aug 16 06:15:41 UTC 2016


#12494: Implementation of setenv in base incorrectly claims empty environment
variable not supported on Windows
-------------------------------------+-------------------------------------
           Reporter:  ezyang         |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:                 |           Version:  8.0.1
  libraries/base                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Relevant code:

 {{{
 -- | @setEnv name value@ sets the specified environment variable to
 @value at .
 --
 -- On Windows setting an environment variable to the /empty string/
 removes
 -- that environment variable from the environment.  For the sake of
 -- compatibility we adopt that behavior.  In particular
 --
 -- @
 -- setEnv name \"\"
 -- @
 --
 -- has the same effect as
 --
 -- @
 -- `unsetEnv` name
 -- @
 }}}

 This sounds nice and authoritative... and it's also not true.

 https://msdn.microsoft.com/en-
 us/library/windows/desktop/ms686206(v=vs.85).aspx states that only if the
 pointer is NULL (as opposed to an empty string) is the environment
 variable deleted.

 https://github.com/golang/go/issues/5610 corroborates

 So `setEnv` has been given bogus semantics that don't make sense because
 empty environment variables ARE supported on Windows.

 My suggestion is to just fix this so that setEnv takes empty environment
 variables. But this would be a BC breaking change.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12494>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list