auto homeGuard = EnvGuard("HOME"); auto configHomeGuard = EnvGuard("XDG_CONFIG_HOME"); auto configDirsGuard = EnvGuard("XDG_CONFIG_DIRS"); auto newConfigHome = "/home/myuser/data"; environment["XDG_CONFIG_HOME"] = newConfigHome; auto newConfigDirs = ["/usr/local/data", "/usr/data"]; environment["XDG_CONFIG_DIRS"] = "/usr/local/data:/usr/data"; assert(xdgAllConfigDirs() == newConfigHome ~ newConfigDirs); environment.remove("XDG_CONFIG_HOME"); environment.remove("HOME"); assert(xdgAllConfigDirs() == newConfigDirs);