aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/env.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-21 11:37:13 +0800
committerGitHub <noreply@github.com>2022-08-21 11:37:13 +0800
commit6b9852cc4188d9ca7bce8e7592dcfca38539c743 (patch)
tree3e3dbcffc76ecac8ffa2862a1d307483c4091f0c /src/nvim/os/env.c
parent506a3ec91359da077eee81c82d23c4805ad22f9a (diff)
downloadrneovim-6b9852cc4188d9ca7bce8e7592dcfca38539c743.tar.gz
rneovim-6b9852cc4188d9ca7bce8e7592dcfca38539c743.tar.bz2
rneovim-6b9852cc4188d9ca7bce8e7592dcfca38539c743.zip
vim-patch:8.2.4754: using cached values after unsetting some environment variables (#19872)
Problem: Still using cached values after unsetting some known environment variables. Solution: Take care of the side effects. (closes vim/vim#10194) https://github.com/vim/vim/commit/7714231bb5b15f7c85453f3945c108478de1d08a Cherry-pick vim_setenv_ext() from patch 8.2.0200.
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;
+ }
+}