Update one or more environment variables.
    
    Preserves the previous environment variable (if available) and can be
    applied to remote connections that offer an @environ@ attribute using the
    @on@ argument.

def environ(on=os, **kw):
    """Update one or more environment variables.
    
    Preserves the previous environment variable (if available) and can be
    applied to remote connections that offer an @environ@ attribute using the
    @on@ argument.
    """
    
    originals = list()
    
    for key in kw:
        originals.append((key, on.environ.get(key, None)))
        on.environ[key] = kw[key]
    
    yield
    
    for key, value in originals:
        if not value:
            del on.environ[key]
            continue
        
        on.environ[key] = value