mirror of
https://github.com/neovim/neovim.git
synced 2026-01-06 03:17:23 +10:00
vim-patch:9.1.1948: Windows: Vim adds current directory to search path
Problem: Windows: Vim always adds the current directory to search path.
This should only happen when using cmd.exe as 'shell'. For
example, powershell won't run binaries from the current
directory.
Solution: Only add current directory to system path, when using cmd.exe
as 'shell'.
related: vim/vim#10341
related: 083ec6d9a3b7
4d87c9742a
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -1875,10 +1875,12 @@ executable({expr}) *executable()*
|
||||
On MS-Windows an executable in the same directory as the Vim
|
||||
executable is always found (it's added to $PATH at |startup|).
|
||||
*NoDefaultCurrentDirectoryInExePath*
|
||||
On MS-Windows an executable in Vim's current working directory
|
||||
is also normally found, but this can be disabled by setting
|
||||
the `$NoDefaultCurrentDirectoryInExePath` environment variable.
|
||||
This is always done for |:!| commands, for security reasons.
|
||||
On MS-Windows when using cmd.exe as 'shell' an executable in
|
||||
Vim's current working directory is also normally found, which
|
||||
can be disabled by setting the
|
||||
`$NoDefaultCurrentDirectoryInExePath` environment variable.
|
||||
This is always done when executing external commands using
|
||||
e.g. |:!|, |:make|, |system()| for security reasons.
|
||||
|
||||
The result is a Number:
|
||||
1 exists
|
||||
|
||||
10
runtime/lua/vim/_meta/vimfn.lua
generated
10
runtime/lua/vim/_meta/vimfn.lua
generated
@@ -1650,10 +1650,12 @@ function vim.fn.eventhandler() end
|
||||
--- On MS-Windows an executable in the same directory as the Vim
|
||||
--- executable is always found (it's added to $PATH at |startup|).
|
||||
--- *NoDefaultCurrentDirectoryInExePath*
|
||||
--- On MS-Windows an executable in Vim's current working directory
|
||||
--- is also normally found, but this can be disabled by setting
|
||||
--- the `$NoDefaultCurrentDirectoryInExePath` environment variable.
|
||||
--- This is always done for |:!| commands, for security reasons.
|
||||
--- On MS-Windows when using cmd.exe as 'shell' an executable in
|
||||
--- Vim's current working directory is also normally found, which
|
||||
--- can be disabled by setting the
|
||||
--- `$NoDefaultCurrentDirectoryInExePath` environment variable.
|
||||
--- This is always done when executing external commands using
|
||||
--- e.g. |:!|, |:make|, |system()| for security reasons.
|
||||
---
|
||||
--- The result is a Number:
|
||||
--- 1 exists
|
||||
|
||||
@@ -2161,10 +2161,12 @@ M.funcs = {
|
||||
On MS-Windows an executable in the same directory as the Vim
|
||||
executable is always found (it's added to $PATH at |startup|).
|
||||
*NoDefaultCurrentDirectoryInExePath*
|
||||
On MS-Windows an executable in Vim's current working directory
|
||||
is also normally found, but this can be disabled by setting
|
||||
the `$NoDefaultCurrentDirectoryInExePath` environment variable.
|
||||
This is always done for |:!| commands, for security reasons.
|
||||
On MS-Windows when using cmd.exe as 'shell' an executable in
|
||||
Vim's current working directory is also normally found, which
|
||||
can be disabled by setting the
|
||||
`$NoDefaultCurrentDirectoryInExePath` environment variable.
|
||||
This is always done when executing external commands using
|
||||
e.g. |:!|, |:make|, |system()| for security reasons.
|
||||
|
||||
The result is a Number:
|
||||
1 exists
|
||||
|
||||
@@ -355,7 +355,8 @@ static bool is_executable_in_path(const char *name, char **abspath)
|
||||
|
||||
#ifdef MSWIN
|
||||
char *path = NULL;
|
||||
if (!os_env_exists("NoDefaultCurrentDirectoryInExePath", false)) {
|
||||
if (!os_env_exists("NoDefaultCurrentDirectoryInExePath", false)
|
||||
&& strstr(path_tail(p_sh), "cmd.exe") != NULL) {
|
||||
// Prepend ".;" to $PATH.
|
||||
size_t pathlen = strlen(path_env);
|
||||
path = xmallocz(pathlen + 2);
|
||||
|
||||
@@ -202,9 +202,9 @@ describe('executable() (Windows)', function()
|
||||
clear({ env = { PATHEXT = '' } })
|
||||
command('set shell=sh')
|
||||
for _, ext in ipairs(exts) do
|
||||
eq(1, call('executable', 'test_executable_' .. ext .. '.' .. ext))
|
||||
eq(0, call('executable', 'test_executable_' .. ext .. '.' .. ext))
|
||||
end
|
||||
eq(1, call('executable', 'test_executable_zzz.zzz'))
|
||||
eq(0, call('executable', 'test_executable_zzz.zzz'))
|
||||
end)
|
||||
|
||||
it("relative path, Unix-style 'shell' (backslashes)", function()
|
||||
|
||||
Reference in New Issue
Block a user