diff src/misc1.c @ 28459:52ef65c0637f v8.2.4754

patch 8.2.4754: using cached values after unsetting some environment variables Commit: https://github.com/vim/vim/commit/7714231bb5b15f7c85453f3945c108478de1d08a Author: LemonBoy <thatlemon@gmail.com> Date: Fri Apr 15 20:50:46 2022 +0100 patch 8.2.4754: using cached values after unsetting some environment variables Problem: Still using cached values after unsetting some known environment variables. Solution: Take care of the side effects. (closes #10194)
author Bram Moolenaar <Bram@vim.org>
date Fri, 15 Apr 2022 22:00:03 +0200
parents e015d650ea9f
children 8bf3198ca147
line wrap: on
line diff
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -1910,6 +1910,20 @@ vim_unsetenv(char_u *var)
 #endif
 }
 
+/*
+ * Removes environment variable "name" and take care of side effects.
+ */
+    void
+vim_unsetenv_ext(char_u *var)
+{
+    vim_unsetenv(var);
+
+    // "homedir" is not cleared, keep using the old value until $HOME is set.
+    if (STRICMP(var, "VIM") == 0)
+	didset_vim = FALSE;
+    else if (STRICMP(var, "VIMRUNTIME") == 0)
+	didset_vimruntime = FALSE;
+}
 
 /*
  * Set environment variable "name" and take care of side effects.
@@ -1922,8 +1936,7 @@ vim_setenv_ext(char_u *name, char_u *val
 	init_homedir();
     else if (didset_vim && STRICMP(name, "VIM") == 0)
 	didset_vim = FALSE;
-    else if (didset_vimruntime
-	    && STRICMP(name, "VIMRUNTIME") == 0)
+    else if (didset_vimruntime && STRICMP(name, "VIMRUNTIME") == 0)
 	didset_vimruntime = FALSE;
 }
 #endif