diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2020-09-08 20:47:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 20:47:22 -0700 |
commit | 59712f6dbecfd9a7ccd021115170d1c9313b0969 (patch) | |
tree | f215d014b599acc55f2c1d375a66bb587f9ea7b1 /test/unit/os/env_spec.lua | |
parent | df6b49b4ee5a4e4d022baf68b8e1177102243160 (diff) | |
download | rneovim-59712f6dbecfd9a7ccd021115170d1c9313b0969.tar.gz rneovim-59712f6dbecfd9a7ccd021115170d1c9313b0969.tar.bz2 rneovim-59712f6dbecfd9a7ccd021115170d1c9313b0969.zip |
win: avoid duplicate separators in $PATH #12869
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
Diffstat (limited to 'test/unit/os/env_spec.lua')
-rw-r--r-- | test/unit/os/env_spec.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua index ad05b134e0..e7cb5e5d5e 100644 --- a/test/unit/os/env_spec.lua +++ b/test/unit/os/env_spec.lua @@ -78,15 +78,22 @@ describe('env.c', function() end) describe('os_setenv_append_path', function() - itp('appends /foo/bar to $PATH', function() + itp('appends :/foo/bar to $PATH', function() local original_path = os.getenv('PATH') - eq(true, cimp.os_setenv_append_path(to_cstr('/foo/bar/baz'))) + eq(true, cimp.os_setenv_append_path(to_cstr('/foo/bar/baz.exe'))) eq(original_path..':/foo/bar', os.getenv('PATH')) end) + itp('avoids redundant separator when appending to $PATH #7377', function() + os_setenv('PATH', '/a/b/c:', true) + eq(true, cimp.os_setenv_append_path(to_cstr('/foo/bar/baz.exe'))) + -- Must not have duplicate separators. #7377 + eq('/a/b/c:/foo/bar', os.getenv('PATH')) + end) + itp('returns false if `fname` is not absolute', function() local original_path = os.getenv('PATH') - eq(false, cimp.os_setenv_append_path(to_cstr('foo/bar/baz'))) + eq(false, cimp.os_setenv_append_path(to_cstr('foo/bar/baz.exe'))) eq(original_path, os.getenv('PATH')) end) end) |