jezdez / envdir

A Python port of daemontools' envdir.
https://envdir.readthedocs.io/
MIT License
229 stars 28 forks source link

envdir.read() will not overwrite existing environment variables #2

Closed mbaechtold closed 11 years ago

mbaechtold commented 11 years ago

First of all, thank you for this neat little tool.

I think I found a little bug in the read() method at https://github.com/jezdez/envdir/blob/master/envdir/__main__.py#L55 :

If an environment variables is already set, envdir will not overwrite it.

That's because of os.environ.setdefault(name, value) in https://github.com/jezdez/envdir/blob/master/envdir/__main__.py#L63 not setting the value, if the key namealready exists in the os.environ dict:

def setdefault(self, key, failobj=None):
    if key not in self:
       self[key] = failobj
    return self[key]
jezdez commented 11 years ago

Good catch, you're absolutely right. That's what I get for not testing it well :)

jezdez commented 11 years ago

This is now released as https://pypi.python.org/pypi/envdir/0.4.1

mbaechtold commented 11 years ago

Sweet. Thank you very much.