Fix executable indicator in file name completion on Windows.

* complete.c (stat_char) [_WIN32]: Don't use 'access' and X_OK on
	Windows, they don't work.  Instead, look at the file-name
	extension to determine whether the file is executable.
This commit is contained in:
Eli Zaretskii
2014-12-30 21:14:25 +02:00
parent 1a667e98b7
commit 05942d8a1b
2 changed files with 19 additions and 0 deletions

View File

@@ -598,8 +598,21 @@ stat_char (filename)
#endif
else if (S_ISREG (finfo.st_mode))
{
#if defined (_WIN32) && !defined (__CYGWIN__)
/* Windows 'access' doesn't support X_OK and on latest Windows
versions even invokes an invalid parameter exception. */
char *ext = strrchr (filename, '.');
if (ext
&& (_rl_stricmp (ext, ".exe") == 0
|| _rl_stricmp (ext, ".cmd") == 0
|| _rl_stricmp (ext, ".bat") == 0
|| _rl_stricmp (ext, ".com") == 0))
character = '*';
#else
if (access (filename, X_OK) == 0)
character = '*';
#endif
}
return (character);
}