mirror of
https://github.com/neovim/neovim.git
synced 2025-11-26 04:00:45 +00:00
win: Append process dir to $PATH
This allows executables to be found by :!, system(), and executable() if
they live next to ("sibling" to) nvim.exe. This is what gvim on Windows
does, and also matches the behavior of Win32 SearchPath().
c4a249a736/src/os_win32.c (L354-L370)
This commit is contained in:
@@ -238,9 +238,7 @@ int main(int argc, char **argv)
|
||||
// Check if we have an interactive window.
|
||||
check_and_set_isatty(¶ms);
|
||||
|
||||
// Get the name with which Nvim was invoked, with and without path.
|
||||
set_vim_var_string(VV_PROGPATH, argv[0], -1);
|
||||
set_vim_var_string(VV_PROGNAME, (char *) path_tail((char_u *) argv[0]), -1);
|
||||
init_path(argv[0]);
|
||||
|
||||
event_init();
|
||||
/*
|
||||
@@ -1194,9 +1192,27 @@ static void check_and_set_isatty(mparm_T *paramp)
|
||||
paramp->err_isatty = os_isatty(fileno(stderr));
|
||||
TIME_MSG("window checked");
|
||||
}
|
||||
/*
|
||||
* Get filename from command line, given that there is one.
|
||||
*/
|
||||
|
||||
// Sets v:progname and v:progpath. Also modifies $PATH on Windows.
|
||||
static void init_path(char *exename)
|
||||
{
|
||||
char exepath[MAXPATHL] = { 0 };
|
||||
size_t exepathlen = MAXPATHL;
|
||||
// Make v:progpath absolute.
|
||||
if (os_exepath(exepath, &exepathlen) != 0) {
|
||||
EMSG2(e_intern2, "init_path()");
|
||||
}
|
||||
set_vim_var_string(VV_PROGPATH, exepath, -1);
|
||||
set_vim_var_string(VV_PROGNAME, (char *)path_tail((char_u *)exename), -1);
|
||||
|
||||
#ifdef WIN32
|
||||
// Append the process start directory to $PATH, so that ":!foo" finds tools
|
||||
// shipped with Windows package. This also mimics SearchPath().
|
||||
os_setenv_append_path(exepath);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Get filename from command line, if any.
|
||||
static char_u *get_fname(mparm_T *parmp, char_u *cwd)
|
||||
{
|
||||
#if !defined(UNIX)
|
||||
|
||||
Reference in New Issue
Block a user