diff options
author | erw7 <erw7.github@gmail.com> | 2019-04-01 19:29:12 +0900 |
---|---|---|
committer | erw7 <erw7.github@gmail.com> | 2019-04-01 19:29:12 +0900 |
commit | a7cc18e5635ca4a1515167d331cd582e53471636 (patch) | |
tree | bd1ce503d1354f31742fc2686f5515aed1584184 | |
parent | 7d61b2f64ffb7b31c9f59731a77de3b8cdca19a4 (diff) | |
download | rneovim-a7cc18e5635ca4a1515167d331cd582e53471636.tar.gz rneovim-a7cc18e5635ca4a1515167d331cd582e53471636.tar.bz2 rneovim-a7cc18e5635ca4a1515167d331cd582e53471636.zip |
fs.c: fix is_executable_ext
- Fix the problem of checking the extension in a UNIX like shell.
- Fix the problem of not checking the existence of the file when the
pathext contains an extension.
-rw-r--r-- | src/nvim/os/fs.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 6ac53dd45b..388faddac1 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -331,10 +331,12 @@ static bool is_executable_ext(char *name, const char *pathext, char_u **abspath) const char *ext_end = xstrchrnul(ext, ENV_SEPCHAR); size_t ext_len = (size_t)(ext_end - ext); STRLCPY(buf_end, ext, ext_len + 1); - bool in_pathext = nameext_len == ext_len - && 0 == mb_strnicmp((char_u *)nameext, (char_u *)ext, ext_len); + bool in_pathext = (strstr((char *)path_tail(p_sh), "sh") != NULL) + || (nameext_len == ext_len + && 0 == mb_strnicmp((char_u *)nameext, (char_u *)ext, ext_len)); - if (in_pathext || is_executable(os_buf, abspath)) { + if ((in_pathext && is_executable(name, abspath)) + || is_executable(os_buf, abspath)) { return true; } |