mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 12:38:33 +00:00
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:
@@ -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);
|
const char *ext_end = xstrchrnul(ext, ENV_SEPCHAR);
|
||||||
size_t ext_len = (size_t)(ext_end - ext);
|
size_t ext_len = (size_t)(ext_end - ext);
|
||||||
STRLCPY(buf_end, ext, ext_len + 1);
|
STRLCPY(buf_end, ext, ext_len + 1);
|
||||||
bool in_pathext = nameext_len == ext_len
|
bool in_pathext = (strstr((char *)path_tail(p_sh), "sh") != NULL)
|
||||||
&& 0 == mb_strnicmp((char_u *)nameext, (char_u *)ext, ext_len);
|
|| (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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user