forked from aniani/vim
patch 8.1.1740: exepath() doesn't work for "bin/cat"
Problem: Exepath() doesn't work for "bin/cat". Solution: Check for any path separator. (Daniel Hahler, closes #4724, closes #4710)
This commit is contained in:
@@ -3058,8 +3058,7 @@ f_executable(typval_T *argvars, typval_T *rettv)
|
|||||||
char_u *name = tv_get_string(&argvars[0]);
|
char_u *name = tv_get_string(&argvars[0]);
|
||||||
|
|
||||||
/* Check in $PATH and also check directly if there is a directory name. */
|
/* Check in $PATH and also check directly if there is a directory name. */
|
||||||
rettv->vval.v_number = mch_can_exe(name, NULL, TRUE)
|
rettv->vval.v_number = mch_can_exe(name, NULL, TRUE);
|
||||||
|| (gettail(name) != name && mch_can_exe(name, NULL, FALSE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static garray_T redir_execute_ga;
|
static garray_T redir_execute_ga;
|
||||||
|
@@ -3103,12 +3103,11 @@ mch_can_exe(char_u *name, char_u **path, int use_path)
|
|||||||
|
|
||||||
/* When "use_path" is false and if it's an absolute or relative path don't
|
/* When "use_path" is false and if it's an absolute or relative path don't
|
||||||
* need to use $PATH. */
|
* need to use $PATH. */
|
||||||
if (!use_path || mch_isFullName(name) || (name[0] == '.'
|
if (!use_path || gettail(name) != name)
|
||||||
&& (name[1] == '/' || (name[1] == '.' && name[2] == '/'))))
|
|
||||||
{
|
{
|
||||||
/* There must be a path separator, files in the current directory
|
/* There must be a path separator, files in the current directory
|
||||||
* can't be executed. */
|
* can't be executed. */
|
||||||
if (gettail(name) != name && executable_file(name))
|
if ((use_path || gettail(name) != name) && executable_file(name))
|
||||||
{
|
{
|
||||||
if (path != NULL)
|
if (path != NULL)
|
||||||
{
|
{
|
||||||
|
@@ -990,6 +990,14 @@ func Test_Executable()
|
|||||||
elseif has('unix')
|
elseif has('unix')
|
||||||
call assert_equal(1, executable('cat'))
|
call assert_equal(1, executable('cat'))
|
||||||
call assert_equal(0, executable('nodogshere'))
|
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
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -777,6 +777,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1740,
|
||||||
/**/
|
/**/
|
||||||
1739,
|
1739,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user