diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-02-05 01:11:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-05 01:11:06 +0100 |
commit | bb2f36d038ccb375249a078997f68840ddcc66ef (patch) | |
tree | a080d374a6b38607806ca553d00b2d3e8b590c36 /src/nvim/main.c | |
parent | 3d3b1641d0cae3244c09d4602ab96d290dd0928a (diff) | |
parent | 18127f64c421a2c4da100a9e40d49c31a9a5170a (diff) | |
download | rneovim-bb2f36d038ccb375249a078997f68840ddcc66ef.tar.gz rneovim-bb2f36d038ccb375249a078997f68840ddcc66ef.tar.bz2 rneovim-bb2f36d038ccb375249a078997f68840ddcc66ef.zip |
Merge #6038 from justinmk/win32-executable
win: executable()
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r-- | src/nvim/main.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index c7a60d07c1..6194e5f948 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -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) |