[Bug 45320] New: cmd creates an environment variable with an empty name

wine-bugs at winehq.org wine-bugs at winehq.org
Tue Jun 12 21:47:37 CDT 2018


https://bugs.winehq.org/show_bug.cgi?id=45320

            Bug ID: 45320
           Summary: cmd creates an environment variable with an empty name
           Product: Wine
           Version: 3.9
          Hardware: x86-64
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: cmd
          Assignee: wine-bugs at winehq.org
          Reporter: dima at gmail.com
      Distribution: ---

CMD creates an environment variable with an empty name when it starts up. That
doesn't match the behavior on Windows (at least, Win10) and breaks programs
like Python.

Apparently, CMD is trying to save the current working directory; the code was
added in
https://source.winehq.org/git/wine.git/commit/d0db751e0cb7a0526c3aecca489189f4fa600bf6,
but without an explanation.


To reproduce, run this:

#include <stdio.h>

int main(int argc, char **argv, char **envp) {
  for (char **env = envp; *env != 0; env++) {
    printf("%s\n", *env);
  }
  return 0;
}

The last line of the output will be similar to this:

=Z:=Z:\home\dima


Python gets an exception if it tries to unset that variable:

>>> import os
>>> os.environ.clear()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ProgramData\Miniconda3\lib\_collections_abc.py", line 820, in clear
    self.popitem()
  File "C:\ProgramData\Miniconda3\lib\_collections_abc.py", line 813, in
popitem
    del self[key]
  File "C:\ProgramData\Miniconda3\lib\os.py", line 680, in __delitem__
    self.unsetenv(encodedkey)
  File "C:\ProgramData\Miniconda3\lib\os.py", line 718, in <lambda>
    _unsetenv = lambda key: _putenv(key, "")
OSError: [Errno 0] Error


This is arguably a Python bug, and it happens on UNIX, too:
https://bugs.python.org/issue20658 . However, cmd should probably match the
Windows behavior and not trigger the Python bug unnecessarily.

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list