From 59712f6dbecfd9a7ccd021115170d1c9313b0969 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 8 Sep 2020 20:47:22 -0700 Subject: win: avoid duplicate separators in $PATH #12869 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems like redundant env var separators (";" on Windows) in $PATH can cause weird behavior. From #7377: > After some time, system(['win32yank', '-o']) and system('win32yank -o') > start returning different results: specifically first returns an > empty string. > > 1. $PATH weirdly contains double semicolon followed by path to the > “installation directory” (unpacked directory from archive). > 2. If I run `let $PATH=substitute($PATH, ';;', ';', 'g')` the problem is fixed. close #7377 ref 224f99b85d311ebd31451db13b66e4a3c7e51938 --- src/nvim/os/env.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim') diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 082ad58223..879266e3d4 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -1176,7 +1176,9 @@ bool os_setenv_append_path(const char *fname) temp[0] = NUL; } else { xstrlcpy(temp, path, newlen); - xstrlcat(temp, ENV_SEPSTR, newlen); + if (ENV_SEPCHAR != path[pathlen - 1]) { + xstrlcat(temp, ENV_SEPSTR, newlen); + } } xstrlcat(temp, os_buf, newlen); os_setenv("PATH", temp, 1); -- cgit