auto homeGuard = EnvGuard("HOME"); auto dataHomeGuard = EnvGuard("XDG_DATA_HOME"); auto dataDirsGuard = EnvGuard("XDG_DATA_DIRS"); auto newDataHome = "/home/myuser/data"; auto newDataDirs = ["/usr/local/data", "/usr/data"]; environment["XDG_DATA_HOME"] = newDataHome; environment["XDG_DATA_DIRS"] = "/usr/local/data:/usr/data"; assert(xdgAllDataDirs() == newDataHome ~ newDataDirs); environment.remove("XDG_DATA_HOME"); environment.remove("HOME"); assert(xdgAllDataDirs() == newDataDirs);