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:
Justin M. Keyes
2017-02-02 13:16:15 +01:00
parent 7d58aba80c
commit 224f99b85d
10 changed files with 120 additions and 31 deletions

View File

@@ -238,9 +238,7 @@ int main(int argc, char **argv)
// Check if we have an interactive window.
check_and_set_isatty(&params);
// 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)