aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/env.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/os/env.c')
-rw-r--r--src/nvim/os/env.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 053c225b35..795bff66cb 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -1229,3 +1229,29 @@ bool os_shell_is_cmdexe(const char *sh)
}
return striequal("cmd.exe", path_tail(sh));
}
+
+/// Removes environment variable "name" and take care of side effects.
+void vim_unsetenv_ext(const char *var)
+{
+ os_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.
+void vim_setenv_ext(const char *name, const char *val)
+{
+ os_setenv(name, val, 1);
+ if (STRICMP(name, "HOME") == 0) {
+ init_homedir();
+ } else if (didset_vim && STRICMP(name, "VIM") == 0) {
+ didset_vim = false;
+ } else if (didset_vimruntime && STRICMP(name, "VIMRUNTIME") == 0) {
+ didset_vimruntime = false;
+ }
+}