diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-04-01 21:00:59 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-04-01 21:00:59 +0200 |
commit | c7f025536e9e5b7b95b55d09094febb627395d05 (patch) | |
tree | 18ecd63ab3352c3089125ad435d5aa2f6d493655 /src/os_unix.c | |
parent | a1706c958e69086f5c9eb7d79779ed839441ff60 (diff) | |
download | vim-c7f025536e9e5b7b95b55d09094febb627395d05.zip |
updated for version 7.4.235
Problem: It is not easy to get the full path of a command.
Solution: Add the exepath() function.
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 48f45b0eb..63d39493b 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2992,8 +2992,9 @@ executable_file(name) * Return -1 if unknown. */ int -mch_can_exe(name) +mch_can_exe(name, path) char_u *name; + char_u **path; { char_u *buf; char_u *p, *e; @@ -3003,7 +3004,18 @@ mch_can_exe(name) if (mch_isFullName(name) || (name[0] == '.' && (name[1] == '/' || (name[1] == '.' && name[2] == '/')))) { - return executable_file(name); + if (executable_file(name)) + { + if (path != NULL) + { + if (name[0] == '.') + *path = FullName_save(name, TRUE); + else + *path = vim_strsave(name); + } + return TRUE; + } + return FALSE; } p = (char_u *)getenv("PATH"); @@ -3032,7 +3044,16 @@ mch_can_exe(name) STRCAT(buf, name); retval = executable_file(buf); if (retval == 1) + { + if (path != NULL) + { + if (buf[0] == '.') + *path = FullName_save(buf, TRUE); + else + *path = vim_strsave(buf); + } break; + } if (*e != ':') break; @@ -5592,7 +5613,7 @@ mch_expand_wildcards(num_pat, pat, num_file, file, flags) continue; /* Skip files that are not executable if we check for that. */ - if (!dir && (flags & EW_EXEC) && !mch_can_exe(p)) + if (!dir && (flags & EW_EXEC) && !mch_can_exe(p, NULL)) continue; if (--files_free == 0) @@ -6090,7 +6111,7 @@ mch_expand_wildcards(num_pat, pat, num_file, file, flags) continue; /* Skip files that are not executable if we check for that. */ - if (!dir && (flags & EW_EXEC) && !mch_can_exe((*file)[i])) + if (!dir && (flags & EW_EXEC) && !mch_can_exe((*file)[i], NULL)) continue; p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir)); @@ -6317,7 +6338,7 @@ gpm_close() /* Reads gpm event and adds special keys to input buf. Returns length of * generated key sequence. - * This function is made after gui_send_mouse_event + * This function is styled after gui_send_mouse_event(). */ static int mch_gpm_process() |