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.
This commit is contained in:
erw7 2019-04-01 19:29:12 +09:00
parent 7d61b2f64f
commit a7cc18e563

View File

@ -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;
}