diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.lua | 13 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 16 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 0a003f3b84..825931938e 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2059,8 +2059,10 @@ M.funcs = { This function checks if an executable with the name {expr} exists. {expr} must be the name of the program without any arguments. + executable() uses the value of $PATH and/or the normal - searchpath for programs. *PATHEXT* + searchpath for programs. + *PATHEXT* On MS-Windows the ".exe", ".bat", etc. can optionally be included. Then the extensions in $PATHEXT are tried. Thus if "foo.exe" does not exist, "foo.exe.bat" can be found. If @@ -2070,8 +2072,13 @@ M.funcs = { then the name is also tried without adding an extension. On MS-Windows it only checks if the file exists and is not a directory, not if it's really executable. - On Windows an executable in the same directory as Vim is - always found (it is added to $PATH at |startup|). + 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. + The result is a Number: 1 exists 0 does not exist diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index b681b2f832..d0da37b8e7 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -17,7 +17,6 @@ #endif #include "auto/config.h" -#include "nvim/errors.h" #include "nvim/os/fs.h" #include "nvim/os/os_defs.h" @@ -36,6 +35,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/ascii_defs.h" +#include "nvim/errors.h" #include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/log.h" @@ -356,10 +356,16 @@ static bool is_executable_in_path(const char *name, char **abspath) } #ifdef MSWIN - // Prepend ".;" to $PATH. - size_t pathlen = strlen(path_env); - char *path = memcpy(xmallocz(pathlen + 2), "." ENV_SEPSTR, 2); - memcpy(path + 2, path_env, pathlen); + char *path = NULL; + if (!os_env_exists("NoDefaultCurrentDirectoryInExePath")) { + // Prepend ".;" to $PATH. + size_t pathlen = strlen(path_env); + path = xmallocz(pathlen + 2); + memcpy(path, "." ENV_SEPSTR, 2); + memcpy(path + 2, path_env, pathlen); + } else { + path = xstrdup(path_env); + } #else char *path = xstrdup(path_env); #endif |