Problem: Exepath() doesn't work for "bin/cat".
Solution: Check for any path separator. (Daniel Hahler, closes #4724,
closes #4710)
char_u *name = tv_get_string(&argvars[0]);
/* Check in $PATH and also check directly if there is a directory name. */
- rettv->vval.v_number = mch_can_exe(name, NULL, TRUE)
- || (gettail(name) != name && mch_can_exe(name, NULL, FALSE));
+ rettv->vval.v_number = mch_can_exe(name, NULL, TRUE);
}
static garray_T redir_execute_ga;
/* When "use_path" is false and if it's an absolute or relative path don't
* need to use $PATH. */
- if (!use_path || mch_isFullName(name) || (name[0] == '.'
- && (name[1] == '/' || (name[1] == '.' && name[2] == '/'))))
+ if (!use_path || gettail(name) != name)
{
/* There must be a path separator, files in the current directory
* can't be executed. */
- if (gettail(name) != name && executable_file(name))
+ if ((use_path || gettail(name) != name) && executable_file(name))
{
if (path != NULL)
{
elseif has('unix')
call assert_equal(1, executable('cat'))
call assert_equal(0, executable('nodogshere'))
+
+ " get "cat" path and remove the leading /
+ let catcmd = exepath('cat')[1:]
+ new
+ lcd /
+ call assert_equal(1, executable(catcmd))
+ call assert_equal('/' .. catcmd, exepath(catcmd))
+ bwipe
endif
endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1740,
/**/
1739,
/**/