patch 9.1.1948: Windows: Vim adds current directory to search path
Commit:
https://github.com/vim/vim/commit/4d87c9742a544a58c05cb34d4fbaac47e410b369
Author: Christian Brabandt <[email protected]>
Date: Mon Dec 1 20:51:35 2025 +0000
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: #10341
related: 083ec6d9a3b7
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 5f51af3ad..a6a7d8663 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -2716,10 +2716,12 @@ executable({expr})
*executable()*
executable is always found. Since this directory is added to
$PATH it should also work to execute it |win32-PATH|.
*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
diff --git a/src/os_win32.c b/src/os_win32.c
index 0a25d4850..35d69c119 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -2867,7 +2867,8 @@ executable_exists(
goto theend;
}
- if (mch_getenv("NoDefaultCurrentDirectoryInExePath") == NULL)
+ if (mch_getenv("NoDefaultCurrentDirectoryInExePath") == NULL &&
+ strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
{
STRCPY(pathbuf.string, ".;");
pathbuf.length = 2;
diff --git a/src/version.c b/src/version.c
index 545ecd309..b9c5409dc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1948,
/**/
1947,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vQYPj-00DL79-17%40256bit.org.