Improve backup and restore env function + fix makefile with quotes + remove the zdotdir created file

This commit is contained in:
David Dworken
2022-11-13 16:53:37 -08:00
parent 6017eac4a3
commit 53a417296e
3 changed files with 7 additions and 2 deletions

View File

@ -150,7 +150,11 @@ func copy(src, dst string) error {
func BackupAndRestoreEnv(k string) func() {
origValue := os.Getenv(k)
return func() {
os.Setenv(k, origValue)
if origValue == "" {
os.Unsetenv(k)
} else {
os.Setenv(k, origValue)
}
}
}